Skip to content

Instantly share code, notes, and snippets.

@chelnak
Last active March 23, 2016 12:50
Show Gist options
  • Select an option

  • Save chelnak/915bc872fb8b1e7d7a45 to your computer and use it in GitHub Desktop.

Select an option

Save chelnak/915bc872fb8b1e7d7a45 to your computer and use it in GitHub Desktop.
/*
Name: getvCACVirtualMachineSnapshots
Input: vCACHost - vCAC:VCACHost
Input: vCACVirtualMachine - vCAC:VirtualMachine
Output: Array/Properties
Description: Get snapshot information for a vCAC virtual machine
*/
//Get snapshot entities from the virtual machine
var properties = new Properties();
properties.put("VirtualMachineID", vCACVirtualMachine.virtualMachineID);
var vmEntity = vCACEntityManager.readModelEntity(vCACHost.id, "ManagementModelEntities.svc", "VirtualMachines", properties, null);
var vmSnapshotEntities = vmEntity.getLink(vCACHost,"VMSnapshots");
//Push snapshot properties to an array
var virtualMachineSnapshots = [];
for(var i = 0; i < vmSnapshotEntities.length; i++){
var snapshotProperties = vmSnapshotEntities[i].getProperties();
virtualMachineSnapshots.push(snapshotProperties);
//Log snapshot properties to the console
for (var j = 0; j < snapshotProperties.keys.length; j++) {
System.log(snapshotProperties.keys[j] + " : " + snapshotProperties.get(snapshotProperties.keys[j]));
}
}
return virtualMachineSnapshots;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment