I am trying to return createTime (the time a snapshot was taken) for each virtual machine.
I've tried traversing the tree just like every other metric, but it won't return it.
Currently, I have this loop.
foreach my $vm_view (@$vm_views) {
The Dumper for $snapshot returns me rootSnapshotList, which has createTime inside it.
The Dumper for $snap_time returns me the same thing, but without 'rootSnapshotList'.
If I add ->createTime to the line my $snap_time... it just says cannot call method on unblessed reference... the dumper says bless.
Not really sure what other info is relevant, PLEASE HELP!
Hi,
rootSnapshotList is an array as noted in the vSphere API Ref http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc_50%2Fvim.vm.Snapsho..., you will need to iterate through it to return createTime property.
You can take a look at the snapshotmanager.pl http://www.vmware.com/support/developer/viperltoolkit/viperl41/doc/snapshotmanager.html which is part of the vSphere SDK for Perl and there is a "list" operation which has the code to list all snapshots for a given VM.
Hi,
rootSnapshotList is an array as noted in the vSphere API Ref http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc_50%2Fvim.vm.Snapsho..., you will need to iterate through it to return createTime property.
You can take a look at the snapshotmanager.pl http://www.vmware.com/support/developer/viperltoolkit/viperl41/doc/snapshotmanager.html which is part of the vSphere SDK for Perl and there is a "list" operation which has the code to list all snapshots for a given VM.
Thanks, had JUST figured this out as you responded.
Silly of me not to do a 0 .. $#
For anyone in the future who sees this thread and is having a similar issue, you've got to have the line as
my $i #iterator
foreach $i (0 .. $#{$vm_view->snapshot->rootSnapshotList}) {
my $your_var = $vm_view->snapshot->rootSnapshotList->[$i]->createTime #or any other property
}
Wrote that code real quick - it may not compile.