Last active
March 23, 2016 12:50
-
-
Save chelnak/915bc872fb8b1e7d7a45 to your computer and use it in GitHub Desktop.
Get snapshot information for a vCAC virtual machine http://www.helloitscraig.co.uk/2016/03/retrieve-snapshot-information-vcacvirtualmachine.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| 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