To use this function add it to the class library file named vRealizeAutomation.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: vRealizeAutomation.ts
Function CustomPropertyExists
Description: Orchestrator Function to Check if a Custom Property Exists
public CustomPropertyExists(objVcVirtualMachine:VcVirtualMachine, strCustomPropertyName:string): boolean {
let objVcVirtualMachineConfigInfo:VcVirtualMachineConfigInfo = objVcVirtualMachine.config;
let arrvCACVirtualMachine:vCACVirtualMachine[] = Server.findAllForType("vCAC:VirtualMachine", "VMUniqueID eq '" + objVcVirtualMachineConfigInfo.instanceUuid + "'") as vCACVirtualMachine[];
let objvCACVirtualMachine:vCACVirtualMachine = arrvCACVirtualMachine[0];
let objvCACEntity:VCACEntity = objvCACVirtualMachine.getEntity();
let objvCACHost:vCACHost = Server.findForType("vCAC:VCACHost", objvCACEntity.hostId);
let arrVCACEntityProperties:VCACEntity[] = objvCACEntity.getLink(objvCACHost, "VirtualMachineProperties");
let blnStatus:boolean = false;
for ( let i = 0; i < arrVCACEntityProperties.length; i++ )
{
let objVCACEntityProperties:VCACEntity = arrVCACEntityProperties[i];
let strPropertyName:string = objVCACEntityProperties.getProperty("PropertyName");
if ( strPropertyName == strCustomPropertyName )
{
blnStatus = true;
break;
}
}
return blnStatus;
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
