Update IaaS Virtual Machine State
/*
- 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);