VMware {code} Community
macquivr
Contributor
Contributor

remove snapshots

How do I use the web service SDK (I'm using the java variety) to delete a snapshot that is not the current snapshot of a VM.

RemoveSnapshot_Task seems to delete only a VMs current snapshot, so how do I delete a 'named' snapshot?

(Similarly, how do I revert to a snapshot that is not the current snapshot but somewhere else in the VM's snapshot management tree)

- JT

Reply
0 Kudos
4 Replies
lamw
Community Manager
Community Manager

If you take a look at the vSphere API documentation, you'll see the following:

RemoveSnapshot_Task does not delete the current snapshot, it requires that you pass in a reference to one of the snapshots, so you can delete (commit) a specific snapshot. This requires that you go through the snapshot tree for a given VM (recursively) and locate the snapshot that you're interested in.

RevertToSnapshot_Task is what you'll want to use to "Go To" a specific snapshot and again, it also requires you to specify the snapshot that you're interested in.

If you want some sample to take a look at, check out vSphere SDK for Perl Utilities which has a utility called snapshotmanager.pl where these methods are implemented.

=========================================================================

William Lam

VMware vExpert 2009,2010

VMware scripts and resources at:

Twitter: @lamw

Getting Started with the vMA (tips/tricks)

Getting Started with the vSphere SDK for Perl

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
macquivr
Contributor
Contributor

Right, yes, sorry, I see that removeSnapshot_Task is actually a part of VirtualMachineSnapshot and I was confusing it a little with removeAllSnapshots from the VirtualMachine managedEntity. I guess I just asked the wrong question,so here goes, take 2...

Given a VirtualMachine managedEntity how do I get its 'snapshot tree' using java SDK web services (so that I can traverse it and look for a 'named' snapshot')

- JT

Reply
0 Kudos
lamw
Community Manager
Community Manager

Take a look at the rootSnapshotList which is an array of snapshots, you'll need to recursively traverse it to locate the snapshot in question.

=========================================================================

William Lam

VMware vExpert 2009,2010

VMware scripts and resources at:

Twitter: @lamw

Getting Started with the vMA (tips/tricks)

Getting Started with the vSphere SDK for Perl

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
macquivr
Contributor
Contributor

great, thanks, I'll have a look.

- JT

Reply
0 Kudos