mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
F #4913: Pass vmm action error message to the driver (ERROR attr) so you don't have to look for it in the log
This commit is contained in:
parent
35fbc4d0d8
commit
1aaf04e45c
@ -49,8 +49,9 @@ begin
|
||||
vm.attach_disk
|
||||
|
||||
rescue Exception => e
|
||||
STDERR.puts "Attach image for VM #{vm_ref} on vCenter cluster #{vc_cluster_name} "\
|
||||
"failed due to \"#{e.message}\"\n#{e.backtrace}"
|
||||
message = "Attach image for VM #{vm_ref} on vCenter cluster #{vc_cluster_name} "\
|
||||
"failed due to \"#{e.message}\"\n#{e.backtrace}"
|
||||
STDERR.puts error_message(message)
|
||||
exit -1
|
||||
ensure
|
||||
vi_client.close_connection if vi_client
|
||||
|
@ -49,9 +49,10 @@ begin
|
||||
vm.attach_nic
|
||||
|
||||
rescue Exception => e
|
||||
STDERR.puts "Attach NIC for VM #{vm_ref} on vCenter cluster #{vc_cluster_name} "\
|
||||
"failed due to \"#{e.message}\"\n#{e.backtrace}"
|
||||
exit(-1)
|
||||
message = "Attach NIC for VM #{vm_ref} on vCenter cluster #{vc_cluster_name} "\
|
||||
"failed due to \"#{e.message}\"\n#{e.backtrace}"
|
||||
STDERR.puts error_message(message)
|
||||
exit -1
|
||||
ensure
|
||||
vi_client.close_connection if vi_client
|
||||
end
|
||||
|
@ -49,9 +49,10 @@ begin
|
||||
vm.poweroff_hard
|
||||
|
||||
rescue Exception => e
|
||||
STDERR.puts "Cancel VM #{vm_ref} failed due to "\
|
||||
"\"#{e.message}\"\n#{e.backtrace}"
|
||||
exit(-1)
|
||||
message = "Cancel VM #{vm_ref} failed due to "\
|
||||
"\"#{e.message}\"\n#{e.backtrace}"
|
||||
STDERR.puts error_message(message)
|
||||
exit -1
|
||||
ensure
|
||||
vi_client.close_connection if vi_client
|
||||
end
|
||||
|
@ -68,8 +68,6 @@ begin
|
||||
# Resize unmanaged disks
|
||||
vm.resize_unmanaged_disks
|
||||
|
||||
|
||||
|
||||
vm.reconfigure
|
||||
vm.poweron
|
||||
vm.set_running(true)
|
||||
@ -77,8 +75,9 @@ begin
|
||||
puts vm['_ref']
|
||||
|
||||
rescue Exception => e
|
||||
STDERR.puts "Deploy of VM #{vm_id} on vCenter cluster #{cluster_name} " +
|
||||
"with #{dfile} failed due to \"#{e.message}\"\n#{e.backtrace}"
|
||||
message = "Deploy of VM #{vm_id} on vCenter cluster #{cluster_name} " +
|
||||
"with #{dfile} failed due to \"#{e.message}\"\n#{e.backtrace}"
|
||||
STDERR.puts error_message(message)
|
||||
exit -1
|
||||
ensure
|
||||
vi_client.close_connection if vi_client
|
||||
|
@ -47,8 +47,9 @@ begin
|
||||
"snapshot of the virtual machine." if vm.has_snapshots?
|
||||
|
||||
rescue Exception => e
|
||||
STDERR.puts "Detach DISK for VM #{vm_ref} on vCenter cluster #{vc_cluster_name} "\
|
||||
"failed due to \"#{e.message}\"\n#{e.backtrace}"
|
||||
message = "Detach DISK for VM #{vm_ref} on vCenter cluster #{vc_cluster_name} "\
|
||||
"failed due to \"#{e.message}\"\n#{e.backtrace}"
|
||||
STDERR.puts error_message(message)
|
||||
exit -1
|
||||
ensure
|
||||
vi_client.close_connection if vi_client
|
||||
|
@ -49,8 +49,9 @@ begin
|
||||
vm.detach_nic
|
||||
|
||||
rescue Exception => e
|
||||
STDERR.puts "Detach NIC for VM #{vm_ref} on vCenter cluster #{vc_cluster_name} "\
|
||||
"failed due to \"#{e.message}\"\n#{e.backtrace}"
|
||||
message = "Detach NIC for VM #{vm_ref} on vCenter cluster #{vc_cluster_name} "\
|
||||
"failed due to \"#{e.message}\"\n#{e.backtrace}"
|
||||
STDERR.puts error_message(message)
|
||||
exit -1
|
||||
ensure
|
||||
vi_client.close_connection if vi_client
|
||||
|
@ -46,9 +46,10 @@ begin
|
||||
puts vm.info
|
||||
|
||||
rescue Exception => e
|
||||
STDERR.puts "Cannot poll info for VM #{vm_ref} on vCenter cluster "\
|
||||
"#{vc_cluster_name} failed due to "\
|
||||
"\"#{e.message}\"\n#{e.backtrace}"
|
||||
message = "Cannot poll info for VM #{vm_ref} on vCenter cluster "\
|
||||
"#{vc_cluster_name} failed due to "\
|
||||
"\"#{e.message}\"\n#{e.backtrace}"
|
||||
STDERR.puts error_message(message)
|
||||
exit -1
|
||||
ensure
|
||||
vi_client.close_connection if vi_client
|
||||
|
@ -43,9 +43,10 @@ begin
|
||||
vm.reboot
|
||||
|
||||
rescue Exception => e
|
||||
STDERR.puts "Guest reboot of VM #{vm_ref} on vCenter cluster "\
|
||||
"#{vc_cluster_name} failed due to "\
|
||||
"\"#{e.message}\"\n#{e.backtrace}"
|
||||
message = "Guest reboot of VM #{vm_ref} on vCenter cluster "\
|
||||
"#{vc_cluster_name} failed due to "\
|
||||
"\"#{e.message}\"\n#{e.backtrace}"
|
||||
STDERR.puts error_message(message)
|
||||
exit -1
|
||||
ensure
|
||||
vi_client.close_connection if vi_client
|
||||
|
@ -43,9 +43,10 @@ begin
|
||||
vm.regenerate_context
|
||||
|
||||
rescue Exception => e
|
||||
STDERR.puts "Reconfiguration of VM #{vm_ref} on vCenter cluster "\
|
||||
"#{vc_cluster_name} failed due to "\
|
||||
"\"#{e.message}\"\n#{e.backtrace}"
|
||||
message = "Reconfiguration of VM #{vm_ref} on vCenter cluster "\
|
||||
"#{vc_cluster_name} failed due to "\
|
||||
"\"#{e.message}\"\n#{e.backtrace}"
|
||||
STDERR.puts error_message(message)
|
||||
exit -1
|
||||
ensure
|
||||
vi_client.close_connection if vi_client
|
||||
|
@ -43,9 +43,10 @@ begin
|
||||
vm.reset
|
||||
|
||||
rescue Exception => e
|
||||
STDERR.puts "Reset of VM #{vm_ref} on vCenter cluster "\
|
||||
"#{vc_cluster_name} failed due to "\
|
||||
"\"#{e.message}\"\n#{e.backtrace}"
|
||||
message = "Reset of VM #{vm_ref} on vCenter cluster "\
|
||||
"#{vc_cluster_name} failed due to "\
|
||||
"\"#{e.message}\"\n#{e.backtrace}"
|
||||
STDERR.puts error_message(message)
|
||||
exit -1
|
||||
ensure
|
||||
vi_client.close_connection if vi_client
|
||||
|
@ -45,9 +45,10 @@ begin
|
||||
vm.set_running(true)
|
||||
|
||||
rescue Exception => e
|
||||
STDERR.puts "Restore of VM #{vm_ref} on vCenter cluster "\
|
||||
"#{vc_cluster_name} failed due to "\
|
||||
"\"#{e.message}\"\n#{e.backtrace}"
|
||||
message = "Restore of VM #{vm_ref} on vCenter cluster "\
|
||||
"#{vc_cluster_name} failed due to "\
|
||||
"\"#{e.message}\"\n#{e.backtrace}"
|
||||
STDERR.puts error_message(message)
|
||||
exit -1
|
||||
ensure
|
||||
vi_client.close_connection if vi_client
|
||||
|
@ -62,9 +62,10 @@ begin
|
||||
vm.suspend
|
||||
|
||||
rescue Exception => e
|
||||
STDERR.puts "Save of VM #{vm_ref} on vCenter cluster "\
|
||||
"#{vc_cluster_name} failed due to "\
|
||||
"\"#{e.message}\"\n#{e.backtrace}"
|
||||
message = "Save of VM #{vm_ref} on vCenter cluster "\
|
||||
"#{vc_cluster_name} failed due to "\
|
||||
"\"#{e.message}\"\n#{e.backtrace}"
|
||||
STDERR.puts error_message(message)
|
||||
exit -1
|
||||
ensure
|
||||
vi_client.close_connection if vi_client
|
||||
|
@ -59,9 +59,10 @@ begin
|
||||
vm.shutdown #Undeploy, Poweroff or Terminate
|
||||
|
||||
rescue Exception => e
|
||||
STDERR.puts "Shutdown of VM #{vm_ref} on vCenter cluster "\
|
||||
"#{vc_cluster_name} failed due to "\
|
||||
"\"#{e.message}\"\n#{e.backtrace}"
|
||||
message = "Shutdown of VM #{vm_ref} on vCenter cluster "\
|
||||
"#{vc_cluster_name} failed due to "\
|
||||
"\"#{e.message}\"\n#{e.backtrace}"
|
||||
STDERR.puts error_message(message)
|
||||
exit -1
|
||||
ensure
|
||||
vi_client.close_connection if vi_client
|
||||
|
@ -62,9 +62,10 @@ begin
|
||||
puts vm.create_snapshot(snap_id, snap_name)
|
||||
|
||||
rescue Exception => e
|
||||
STDERR.puts "Snapshot of VM #{vm_ref} on vCenter cluster "\
|
||||
"#{vc_cluster_name} failed due to "\
|
||||
"\"#{e.message}\"\n#{e.backtrace}"
|
||||
message = "Snapshot of VM #{vm_ref} on vCenter cluster "\
|
||||
"#{vc_cluster_name} failed due to "\
|
||||
"\"#{e.message}\"\n#{e.backtrace}"
|
||||
STDERR.puts error_message(message)
|
||||
exit -1
|
||||
ensure
|
||||
vi_client.close_connection if vi_client
|
||||
|
@ -44,10 +44,11 @@ begin
|
||||
vm.delete_snapshot(snap_id)
|
||||
|
||||
rescue Exception => e
|
||||
STDERR.puts "Snapshot of VM #{vm_ref} on vCenter cluster "\
|
||||
"#{vc_cluster_name} could not be deleted due to "\
|
||||
"\"#{e.message}\"\n#{e.backtrace}"
|
||||
exit(-1)
|
||||
message = "Snapshot of VM #{vm_ref} on vCenter cluster "\
|
||||
"#{vc_cluster_name} could not be deleted due to "\
|
||||
"\"#{e.message}\"\n#{e.backtrace}"
|
||||
STDERR.puts error_message(message)
|
||||
exit -1
|
||||
ensure
|
||||
vi_client.close_connection if vi_client
|
||||
end
|
||||
|
@ -44,10 +44,11 @@ begin
|
||||
vm.revert_snapshot(snap_id)
|
||||
|
||||
rescue Exception => e
|
||||
STDERR.puts "Snapshot of VM #{vm_ref} on vCenter cluster "\
|
||||
"#{vc_cluster_name} could not be reverted due "\
|
||||
"to \"#{e.message}\"\n#{e.backtrace}"
|
||||
exit(-1)
|
||||
message = "Snapshot of VM #{vm_ref} on vCenter cluster "\
|
||||
"#{vc_cluster_name} could not be reverted due "\
|
||||
"to \"#{e.message}\"\n#{e.backtrace}"
|
||||
STDERR.puts error_message(message)
|
||||
exit -1
|
||||
ensure
|
||||
vi_client.close_connection if vi_client
|
||||
end
|
||||
|
@ -63,9 +63,17 @@ require 'importer'
|
||||
# Helper functions #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
def error_message(message)
|
||||
error_str = "ERROR MESSAGE --8<------\n"
|
||||
error_str << message
|
||||
error_str << "\nERROR MESSAGE ------>8--"
|
||||
|
||||
return error_str
|
||||
end
|
||||
|
||||
def check_valid(parameter, label)
|
||||
if parameter.nil? || parameter.empty?
|
||||
STDERR.puts "The parameter '#{label}' is required for this action."
|
||||
STDERR.puts error_message("The parameter '#{label}' is required for this action.")
|
||||
exit -1
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user