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 d62783a7f8)
This commit is contained in:
Javi Fontan committed 2015-01-09 12:36:35 +01:00
1 parent bacef184e7
commit 15877c3ee8
1 file changed
+27 -7
+27 -7
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