VMware {code} Community
kaizer200
Contributor
Contributor

How To Remove snapshot via perl toolkit

Hello colleagues,

I'm trying for some time to write a script in the ESX perl vi toolkit, which will remove a snapshot , but with no succsess.

The snapshot could be in the "RootSnapshotList" (which is the latest snapshot), or in the ChildSnapshotList of the VirtualMahine.

it could be great if you could post an example of such sample code.

Thanks in advance

Reply
0 Kudos
3 Replies
njain
Expert
Expert

VI Perl Toolkit provides a ready to run utility, snapshotmanager.pl, that can be used to achieve the desired functionality stated above. You can also refer to this utility at

Hope this information is helpful.

Reply
0 Kudos
kaizer200
Contributor
Contributor

Hi njain, thanks for your answer. indeed - sanpshotmanager.pl is helpfull when one wants to delete one snapshot (a scalar variable). But - I'm now facing with a situation when several snapshot one vm machine could much a remove cratiria.
in short - the .pl script need to be able to find 1 to n snapshots which meet a craiteria. I've looked inside snapshotmanager.pl script, and found that sub find_snapshot_name is doing the work of finding the relevant VM's snapshot. But - how can this sub should change to find and return array of snapshots?
thanks in advance
Reply
0 Kudos
njain
Expert
Expert

As you would have noticed that the virtual machine snapshots are stored as a tree structure. The subroutine "find_snapshot_name" traverses through this tree to match the snapshot name entered by the user and returns the reference of that particular node. You can edit this subroutine to change the matching criteria and put all the relevant snapshots (that match the criteria) in a separate array. Once the filtering is done, you can return this array from the subroutine.

Hope this information is helpful.

Reply
0 Kudos