1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-24 21:34:01 +03:00

feature #457: fixes for host hook on error

This commit is contained in:
Tino Vázquez 2011-01-18 18:37:02 +01:00
parent 9d7c8f6471
commit 181115799e

View File

@ -65,27 +65,14 @@ host_name = host.name
# Loop through all vms
vms = VirtualMachinePool.new(client)
exit -1 if OpenNebula.is_error?(host)
exit -1 if OpenNebula.is_error?(vms)
vms.info
vm_ids_array = vms.retrieve_elements("/VM_POOL/VM[STATE=3]/HISTORY[HOSTNAME=\"#{host_name}\"]/../ID and /VM_POOL/VM[STATE=\"3\"]")
vm_ids_array = vms.retrieve_elements("/VM_POOL/VM[STATE=3]/HISTORY[HOSTNAME=\"#{host_name}\"]/../ID")
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
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\"]")
if vm_ids_array
vm_ids_array.each do |vm_id|
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, client)
vm.info
@ -98,4 +85,21 @@ if force == "y"
end
end
if force == "y"
vm_ids_array = vms.retrieve_elements("/VM_POOL/VM[STATE=5]/HISTORY[HOSTNAME=\"#{host_name}\"]/../ID")
if vm_ids_array
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
end