Im not very familiar with VMO
I need to convert the Managed Object - VirtualMachineSnapshot to Data Object - VirtualMachineSnapshotTree
actually i want to extract the value createTime from a snapshot
That value can be found in VirtualMachineSnapshotTree
Thanks in advance
To extract the createTime property of VirtualMachineSnapshotTree, you can refer to below steps:
var snapshot = new VcVirtualMachineSnapshotInfo() ;
snapshot = VM.snapshot; // VM is the VirtualMachine MO
var snapshotList = snapshot.rootSnapshotList; // This gives the array of VirtualMachineSnapshotTree
var createTime = snapshotList.createTime; // From the first index of the array, you can retrieve the create time
You cannot convert a managed object into a data object.
I hope this helps!
Angela hi, and thanks for the response
The solution works as long there are only one snapshot for a virtual machine
But, if there is a child snapshot it returns the same date and time of the parent snapshot
" var createTime = snapshotList.createTime; // From the first index of the array, you can retrieve the create time"
how can i extract the child snapshot create time from the list too??
To retrieve the child snapshots, refer:
var childsnapshotList = snapshotList.childSnapshotList;
The childsnapshotList variable will be an array which holds the child snapshots, each child child snapshot will be of type VirtualMachineSnapshotTree. You can then fetch the createTime property for each of them.