Created
February 7, 2017 09:54
-
-
Save chelnak/92d134920cdc394ec8eb5dbf29fef9e9 to your computer and use it in GitHub Desktop.
Update IaaS Virtual Machine State
This file contains 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
/* | |
- Update IaaS Virtual Machine State | |
- Input: virtualMachineName [String] | |
*/ | |
var state = "Off"; | |
var vCACVirtualMachine = Server.findAllForType("vCAC:VirtualMachine", "VirtualMachineName eq '" + virtualMachineName + "'"); | |
if (vCACVirtualMachine.length == 0) { | |
throw "Could not find vCACVirtualMachine with name " + virtualMachineName; | |
} | |
var vCACEntity = vCACVirtualMachine[0].getEntity(); | |
var hostId = vCACEntity.hostId; | |
var modelName = vCACEntity.modelName; | |
var entitySetName = vCACEntity.entitySetName; | |
var entityIdString = vCACEntity.keyString; | |
var properties = vCACEntity.getProperties(); | |
properties.put("VirtualMachineState", state); | |
System.getModule("com.vmware.library.vcac").updateVCACEntity(hostId,modelName,entitySetName,entityIdString,properties,null,null); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment