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

bug #3464: deeps search the tree of snapshots

Also the delete method does not remove children so the snapshots
in that tree can be accessed when the parent is deleted.

(cherry picked from commit d62783a7f8d50ba48fd2931b19cd59e3380659e8)
This commit is contained in:
Javi Fontan 2015-01-09 12:33:54 +01:00
parent bacef184e7
commit 15877c3ee8

View File

@ -702,6 +702,24 @@ class VCenterVm
return snapshot_name
end
############################################################################
# Find VM snapshot
# @param list root list of VM snapshots
# @param snaphot_name name of the snapshot
############################################################################
def self.find_snapshot(list, snapshot_name)
list.each do |i|
if i.name == snapshot_name
return i.snapshot
elsif !i.childSnapshotList.empty?
snap = find_snapshot(i.childSnapshotList, snapshot_name)
return snap if snap
end
end
nil
end
############################################################################
# Delete VM snapshot
# @param deploy_id vcenter identifier of the VM
@ -714,13 +732,14 @@ class VCenterVm
vm = connection.find_vm_template(deploy_id)
snapshot = vm.snapshot.rootSnapshotList.find {|s|
s.name == snapshot_name
}.snapshot
list = vm.snapshot.rootSnapshotList
snapshot = find_snapshot(list, snapshot_name)
return nil if !snapshot
delete_snapshot_hash = {
:_this => snapshot,
:removeChildren => true
:removeChildren => false
}
snapshot.RemoveSnapshot_Task(delete_snapshot_hash).wait_for_completion
@ -738,9 +757,10 @@ class VCenterVm
vm = connection.find_vm_template(deploy_id)
snapshot = vm.snapshot.rootSnapshotList.find {|s|
s.name == snapshot_name
}.snapshot
list = vm.snapshot.rootSnapshotList
snapshot = find_snapshot(list, snapshot_name)
return nil if !snapshot
revert_snapshot_hash = {
:_this => snapshot