VMware {code} Community
tantal
Contributor
Contributor
Jump to solution

listing snapshot files and hierarchy using VI SDK

Hello,

How do I get the entire snapshot tree for a VM and the list of files for each node of this snapshot hierarchy?

I can get the snapshot tree from "snapshot" property of the VirtualMachine MO in form of a hierarchy of MORefs to VirtualMachineSnapshot (e.g. snapshot-110 on VirtualCenter). However, the VirtualMachineSnapshot contains a single VirtualMachineConfigInfo property, which seems devoid of any filenames.

The actual files for a snapshot are available from the layout.snapshot property of the VirtualMachine MO, but the list of snapshots is flat (no hierarchy). More so, the key used to identify the snapshot is completely different from the one using to identify the VirtualMachineSnapshot.

Example:

VirtualMachineSnapshot MOR value: snapshot-110

VirtualMachineFileLayoutSnapshotLayout: /vmfs/volumes/45543259-083b70c4-c6ef-0002a5ef184f/newVM/newVM.vmx-snapshot-2

So, there is no apparent link between these two objects that are logically connected to the same thing.

The question is: is this a bug? If not, how do I get both the hierarchy and the files for each node using VI SDK? I know it can be done with a script that greps vmdk files, but I'm interested in doing it from VI SDK.

I am using Virtualcenter 2.0.1 and ESX server 3.0.1

Reply
0 Kudos
1 Solution

Accepted Solutions
jnhall
Enthusiast
Enthusiast
Jump to solution

Maybe snapshotmanager.pl does what you want?

http://www.vmware.com/support/developer/viperltoolkit/doc/perl_toolkit_utilities_idx.html

If not, maybe the source code will be helpful to you.

View solution in original post

Reply
0 Kudos
4 Replies
jnhall
Enthusiast
Enthusiast
Jump to solution

Maybe snapshotmanager.pl does what you want?

http://www.vmware.com/support/developer/viperltoolkit/doc/perl_toolkit_utilities_idx.html

If not, maybe the source code will be helpful to you.

Reply
0 Kudos
tantal
Contributor
Contributor
Jump to solution

Thank you for your response.

The missing information in the config property was a consequence of a documented bug (and my complex test case).

Here is a summary of my findings:

VirtualMachineSnapshot has a single property, "config". The VI SDK reference describes this as "Information about the configuration of this virtual machine when this snapshot was

taken. The datastore paths for the virtual machine disks point to the head of the disk

chain that represents the disk at this given snapshot. The fileInfo.fileLayout

field is not set."

This information is available in config.hardware.device[<disk-key>].backing.fileName property.

However, if a VM has two disks in different datastores, this field contains only "[] ", which looks like a blank template for "[<datastore name>] <path-to-disk>". If all disks of a VM are contained to a single datastore, then the field resolves to correct datastore and path.

Reply
0 Kudos
jnhall
Enthusiast
Enthusiast
Jump to solution

Thanks - I will make sure to keep track of this.

Reply
0 Kudos
bmani27
Enthusiast
Enthusiast
Jump to solution

Hi,

I just replied to a similar discussion http://communities.vmware.com/message/897099. For me, the "snapshot" attribute of the VirtualMachineSnapshotTree object and the "key" attribute of the VirtualMachineFileLayoutSnapshotLayout object are the same of the value like this "vmfs/volumes/xxxxx/xxxxx.vmx-snapshot-31". Is there any problem with SDK version or am I missing something? I am using VI SDK 2.5.

Thanks,

Mani

Reply
0 Kudos