1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

B #5077: Destroy VM if reconfigure or poweron actions fail in clone_vm

This commit is contained in:
mcabrerizo 2017-03-24 13:02:05 +01:00
parent 5e9dbba515
commit 57bc086cb8

View File

@ -2677,20 +2677,31 @@ private
end
begin
# Reconfigure the VM
reconfigure_vm(vm, xml, true, hostname)
rescue Exception => e
vm.Destroy_Task.wait_for_completion
raise "Could not reconfigure the VM after a clone has been created: #{e.message}"
end
begin
# Power on the VM
vm.PowerOnVM_Task.wait_for_completion
rescue Exception => e
vm.Destroy_Task.wait_for_completion
raise "Could not power on the VM: #{e.message}"
end
reconfigure_vm(vm, xml, true, hostname)
# Power on the VM
vm.PowerOnVM_Task.wait_for_completion
# Set to yes the running flag
config_array = [{:key=>"opennebula.vm.running",:value=>"yes"}]
spec = RbVmomi::VIM.VirtualMachineConfigSpec(
{:extraConfig =>config_array})
vm.ReconfigVM_Task(:spec => spec).wait_for_completion
begin
# Set the running flag to yes
config_array = [{:key=>"opennebula.vm.running",:value=>"yes"}]
spec = RbVmomi::VIM.VirtualMachineConfigSpec({:extraConfig =>config_array})
vm.ReconfigVM_Task(:spec => spec).wait_for_completion
rescue Exception => e
vm.Destroy_Task.wait_for_completion
raise "Could not set opennebula.vm.running: #{e.message}"
end
return vm.config.uuid
end