mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-23 17:33:56 +03:00
* B #5339 Azure exceptions code restructure * B #5339 replaced azure driver STDERR * B #5339 new handle_exceptions function inside oca * B #5339 changed az exception calls * B #5339 changed ec2 exception calls * B #5339 few changes related to im poll
This commit is contained in:
parent
936ef46d03
commit
a5a9d9a574
@ -34,6 +34,5 @@ az_drv = AzureDriver.new(host)
|
||||
begin
|
||||
az_drv.monitor_all_vms
|
||||
rescue => e
|
||||
STDERR.puts "Error monitoring Azure host: #{e.message}"
|
||||
exit -1
|
||||
OpenNebula.handle_driver_exception("im poll", e, host)
|
||||
end
|
||||
|
@ -36,9 +36,5 @@ begin
|
||||
ec2_drv.monitor_all_vms
|
||||
rescue Exception => e
|
||||
|
||||
OpenNebula.log_error(e.message)
|
||||
STDERR.puts "********** STACK TRACE ************"
|
||||
STDERR.puts e.backtrace
|
||||
STDERR.puts "***********************************"
|
||||
exit -1
|
||||
OpenNebula.handle_driver_exception("im poll", e, host)
|
||||
end
|
||||
|
@ -47,4 +47,23 @@ module OpenNebula
|
||||
return opts
|
||||
end
|
||||
|
||||
# >> /var/log/one/oned.log
|
||||
def self.handle_driver_exception(action, ex, host, did = nil, id = nil, file = nil)
|
||||
|
||||
file ||= ""
|
||||
id ||= ""
|
||||
did ||= ""
|
||||
OpenNebula::log_error(action + " of VM #{id} #{did} on host #{host} #{file} "+
|
||||
"due to \"#{ex.message}\"" +
|
||||
"\n********* STACK TRACE *********\n" +
|
||||
"\t#{ex.backtrace.join("\n\t")}" +
|
||||
"\n*******************************\n")
|
||||
|
||||
OpenNebula.error_message("There is a problem: #{ex.message}")
|
||||
exit (-1)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
@ -407,11 +407,9 @@ private
|
||||
all_az_elements[0].elements["TYPE"].text.downcase.eql? "azure"
|
||||
az = all_az_elements[0]
|
||||
else
|
||||
STDERR.puts(
|
||||
"Cannot find Azure element in VM template "<<
|
||||
"or couldn't find any Azure location matching "<<
|
||||
"one of the templates.")
|
||||
exit(-1)
|
||||
raise "Cannot find Azure element in VM template "<<
|
||||
"or couldn't find any Azure location matching "<<
|
||||
"one of the templates."
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -32,11 +32,10 @@ require 'az_driver'
|
||||
deploy_id = ARGV[0]
|
||||
host = ARGV[1]
|
||||
|
||||
az_drv = AzureDriver.new(host)
|
||||
|
||||
begin
|
||||
az_drv = AzureDriver.new(host)
|
||||
az_drv.cancel(deploy_id)
|
||||
rescue => e
|
||||
STDERR.puts "Error canceling Azure VM [#{deploy_id}]: " + e.message
|
||||
exit -1
|
||||
OpenNebula.handle_driver_exception("Cancel", e, host, deploy_id)
|
||||
end
|
||||
|
@ -34,19 +34,19 @@ dfile = ARGV[0]
|
||||
host = ARGV[1]
|
||||
id = ARGV[2]
|
||||
|
||||
vm = OpenNebula::VirtualMachine.new_with_id(id, OpenNebula::Client.new)
|
||||
vm.info
|
||||
|
||||
lcm_state = vm.lcm_state_str
|
||||
deploy_id = vm.deploy_id
|
||||
|
||||
az_drv = AzureDriver.new(host)
|
||||
|
||||
text=File.read(dfile)
|
||||
|
||||
begin
|
||||
vm = OpenNebula::VirtualMachine.new_with_id(id, OpenNebula::Client.new)
|
||||
vm.info
|
||||
|
||||
lcm_state = vm.lcm_state_str
|
||||
deploy_id = vm.deploy_id
|
||||
|
||||
az_drv = AzureDriver.new(host)
|
||||
|
||||
text=File.read(dfile)
|
||||
|
||||
puts az_drv.deploy(id, host, text, lcm_state, deploy_id)
|
||||
|
||||
rescue => e
|
||||
STDERR.puts "Error deploying Azure VM: " + e.message
|
||||
exit -1
|
||||
OpenNebula.handle_driver_exception("Deploy", e, host, deploy_id, id, dfile)
|
||||
end
|
||||
|
@ -33,11 +33,10 @@ deploy_id = ARGV[0]
|
||||
host = ARGV[1]
|
||||
id = ARGV[2]
|
||||
|
||||
az_drv = AzureDriver.new(host)
|
||||
|
||||
begin
|
||||
az_drv = AzureDriver.new(host)
|
||||
az_drv.poll(id, deploy_id)
|
||||
rescue => e
|
||||
STDERR.puts "Error polling Azure VM [#{deploy_id}]: " + e.message
|
||||
exit -1
|
||||
OpenNebula.handle_driver_exception("Poll", e, host, deploy_id, id)
|
||||
end
|
||||
|
@ -32,11 +32,10 @@ require 'az_driver'
|
||||
deploy_id = ARGV[0]
|
||||
host = ARGV[1]
|
||||
|
||||
az_drv = AzureDriver.new(host)
|
||||
|
||||
begin
|
||||
az_drv = AzureDriver.new(host)
|
||||
az_drv.reboot(deploy_id)
|
||||
rescue => e
|
||||
STDERR.puts "Error rebooting Azure VM [#{deploy_id}]: " + e.message
|
||||
exit -1
|
||||
OpenNebula.handle_driver_exception("Reboot", e, host, deploy_id)
|
||||
end
|
||||
|
@ -33,11 +33,10 @@ checkpoint_file = ARGV[0]
|
||||
host = ARGV[1]
|
||||
deploy_id = ARGV[2]
|
||||
|
||||
az_drv = AzureDriver.new(host)
|
||||
|
||||
begin
|
||||
az_drv = AzureDriver.new(host)
|
||||
az_drv.restore(deploy_id)
|
||||
rescue => e
|
||||
STDERR.puts "Error restoring Azure VM [#{deploy_id}]: " + e.message
|
||||
exit -1
|
||||
OpenNebula.handle_driver_exception("Restore", e, host, deploy_id)
|
||||
end
|
||||
|
@ -33,10 +33,9 @@ deploy_id = ARGV[0]
|
||||
file = ARGV[1]
|
||||
host = ARGV[2]
|
||||
|
||||
az_drv = AzureDriver.new(host)
|
||||
begin
|
||||
az_drv = AzureDriver.new(host)
|
||||
az_drv.save(deploy_id)
|
||||
rescue => e
|
||||
STDERR.puts "Error saving Azure VM [#{deploy_id}]: " + e.message
|
||||
exit -1
|
||||
OpenNebula.handle_driver_exception("Save", e, host, deploy_id, nil, file)
|
||||
end
|
||||
|
@ -34,17 +34,17 @@ deploy_id = ARGV[0]
|
||||
host = ARGV[1]
|
||||
vm_id = ARGV[-2]
|
||||
|
||||
az_drv = AzureDriver.new(host)
|
||||
|
||||
vm = OpenNebula::VirtualMachine.new_with_id(vm_id, OpenNebula::Client.new)
|
||||
vm.info
|
||||
|
||||
lcm_state = vm.lcm_state_str
|
||||
|
||||
begin
|
||||
vm = OpenNebula::VirtualMachine.new_with_id(vm_id, OpenNebula::Client.new)
|
||||
vm.info
|
||||
|
||||
lcm_state = vm.lcm_state_str
|
||||
|
||||
az_drv = AzureDriver.new(host)
|
||||
az_drv.shutdown(deploy_id, lcm_state)
|
||||
rescue => e
|
||||
STDERR.puts "Error shutting down Azure VM [#{deploy_id}]: " + e.message
|
||||
exit -1
|
||||
OpenNebula.handle_driver_exception("Shutdown", e, host, deploy_id, vm_id)
|
||||
end
|
||||
|
||||
|
@ -38,7 +38,7 @@ begin
|
||||
ec2_drv = EC2Driver.new(host)
|
||||
ec2_drv.cancel(deploy_id)
|
||||
rescue Exception => e
|
||||
handle_exception("Cancel", e, host, deploy_id)
|
||||
OpenNebula.handle_driver_exception("Cancel", e, host, deploy_id)
|
||||
end
|
||||
|
||||
|
||||
|
@ -48,5 +48,5 @@ begin
|
||||
puts ec2_drv.deploy(id, host, text, lcm_state, deploy_id)
|
||||
|
||||
rescue Exception => e
|
||||
handle_exception("Deploy", e, host, deploy_id, id, dfile)
|
||||
OpenNebula.handle_driver_exception("Deploy", e, host, deploy_id, id, dfile)
|
||||
end
|
||||
|
@ -49,21 +49,6 @@ require 'opennebula'
|
||||
|
||||
require 'thread'
|
||||
|
||||
# >> /var/log/one/oned.log
|
||||
def handle_exception(action, ex, host, did, id = nil, file = nil)
|
||||
|
||||
file ||= ""
|
||||
id ||= ""
|
||||
OpenNebula::log_error(action + " of VM #{id} #{did} on host #{host} #{file} "+
|
||||
"due to \"#{ex.message}\"")
|
||||
OpenNebula.error_message("There is a problem: #{ex.message}")
|
||||
|
||||
STDERR.puts "********* STACK TRACE *********"
|
||||
STDERR.puts ex.backtrace
|
||||
STDERR.puts "*******************************"
|
||||
exit (-1)
|
||||
end
|
||||
|
||||
begin
|
||||
PUBLIC_CLOUD_EC2_CONF = YAML::load(File.read(EC2_DRIVER_CONF))
|
||||
rescue Exception => e
|
||||
|
@ -38,5 +38,5 @@ begin
|
||||
ec2_drv = EC2Driver.new(host)
|
||||
ec2_drv.poll(id, deploy_id)
|
||||
rescue Excetion => e
|
||||
handle_exception("Poll", e, host, deploy_id, id)
|
||||
OpenNebula.handle_driver_exception("Poll", e, host, deploy_id, id)
|
||||
end
|
||||
|
@ -37,6 +37,6 @@ begin
|
||||
ec2_drv = EC2Driver.new(host)
|
||||
ec2_drv.reboot(deploy_id)
|
||||
rescue Exception => e
|
||||
handle_exception("Reboot", e, host, deploy_id)
|
||||
OpenNebula.handle_driver_exception("Reboot", e, host, deploy_id)
|
||||
end
|
||||
|
||||
|
@ -38,5 +38,5 @@ begin
|
||||
ec2_drv = EC2Driver.new(host)
|
||||
ec2_drv.restore(deploy_id)
|
||||
rescue Exception => e
|
||||
handle_exception("Restore", e, host, deploy_id)
|
||||
OpenNebula.handle_driver_exception("Restore", e, host, deploy_id)
|
||||
end
|
||||
|
@ -38,6 +38,6 @@ begin
|
||||
ec2_drv = EC2Driver.new(host)
|
||||
ec2_drv.save(deploy_id)
|
||||
rescue Exception => e
|
||||
handle_exception("Save", e, host, deploy_id, nil, file)
|
||||
OpenNebula.handle_driver_exception("Save", e, host, deploy_id, nil, file)
|
||||
end
|
||||
|
||||
|
@ -44,7 +44,7 @@ begin
|
||||
|
||||
ec2_drv.shutdown(deploy_id, lcm_state)
|
||||
rescue Exception => e
|
||||
handle_exception("Save", e, host, deploy_id, vm_id)
|
||||
OpenNebula.handle_driver_exception("Shutdown", e, host, deploy_id, vm_id)
|
||||
end
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user