mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-26 10:03:37 +03:00
feature #457: new force option for suspended VMs
This commit is contained in:
parent
366b578a7f
commit
9d7c8f6471
@ -331,12 +331,14 @@ VM_HOOK = [
|
||||
# This hook is used to perform recovery actions when a host fails. The VMs
|
||||
# running in the host can be deleted (use -d option) or resubmitted (-r) in
|
||||
# other host
|
||||
# Last argument (force) can be "y", so suspended VMs in the host will be
|
||||
# resubmitted/deleted, or "n", so suspended VMs in the host will be ignored
|
||||
|
||||
HOST_HOOK = [
|
||||
name = "error",
|
||||
on = "ERROR",
|
||||
command = "host_error.rb",
|
||||
arguments = "$HID -r",
|
||||
arguments = "$HID -r n",
|
||||
remote = no ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
@ -46,6 +46,10 @@ if !(mode=ARGV[1]) # By default, resubmit VMs
|
||||
mode = "-r"
|
||||
end
|
||||
|
||||
if !(force=ARGV[2]) # By default, don't resubmit/finalize suspended VMs
|
||||
force = "n"
|
||||
end
|
||||
|
||||
begin
|
||||
client = Client.new()
|
||||
rescue Exception => e
|
||||
@ -79,4 +83,19 @@ vm_ids_array.each do |vm_id|
|
||||
end
|
||||
end
|
||||
|
||||
if force == "y"
|
||||
vm_ids_array = vms.retrieve_elements("/VM_POOL/VM[STATE=3]/HISTORY[HOSTNAME=\"#{host_name}\"]/../ID and /VM_POOL/VM[STATE=\"5\"]")
|
||||
|
||||
vm_ids_array.each do |vm_id|
|
||||
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, client)
|
||||
vm.info
|
||||
|
||||
if mode == "-r"
|
||||
vm.resubmit
|
||||
elsif mode == "-d"
|
||||
vm.finalize
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user