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

F #4913: Persistent disks in a snapshooted VM are detached after all snapshots are removed and before VM is destroyed

This commit is contained in:
mcabrerizo 2017-04-12 12:44:18 +02:00
parent 0084ffc57c
commit 2494c5f67b
2 changed files with 15 additions and 0 deletions

View File

@ -216,6 +216,17 @@ else
vm.poweroff_hard if vm.is_powered_on?
# If the VM has snapshots the TM could not detach disks so we
# will try to detach persistent disks once we have removed all snapshots
# that way they won't be removed
if vm.has_snapshots?
vm.remove_all_snapshots
disks = one_vm.retrieve_xmlelements("TEMPLATE/DISK[PERSISTENT=\"YES\"]")
disks.each do |d|
vm.detach_disk(d)
end
end
vm.destroy
rescue Exception => e
STDERR.puts "Error unregistering vm #{vmid} (#{vm_ref})."\

View File

@ -2312,6 +2312,10 @@ class VirtualMachine < Template
@item.PowerOffVM_Task.wait_for_completion
end
def remove_all_snapshots
@item.RemoveAllSnapshots_Task.wait_for_completion
end
def set_running(state)
value = state ? "yes" : "no"