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
publicCustomPropertyExists(objVcVirtualMachine:VcVirtualMachine,strCustomPropertyName:string):boolean{
letobjVcVirtualMachineConfigInfo:VcVirtualMachineConfigInfo=objVcVirtualMachine.config;
letarrvCACVirtualMachine:vCACVirtualMachine[]=Server.findAllForType("vCAC:VirtualMachine","VMUniqueID eq '"+objVcVirtualMachineConfigInfo.instanceUuid+"'")asvCACVirtualMachine[];
letobjvCACVirtualMachine:vCACVirtualMachine=arrvCACVirtualMachine[0];
letobjvCACEntity:VCACEntity=objvCACVirtualMachine.getEntity();
letobjvCACHost:vCACHost=Server.findForType("vCAC:VCACHost",objvCACEntity.hostId);
letarrVCACEntityProperties:VCACEntity[]=objvCACEntity.getLink(objvCACHost,"VirtualMachineProperties");
letblnStatus:boolean=false;
for (leti=0;i<arrVCACEntityProperties.length;i++ )
{
letobjVCACEntityProperties:VCACEntity=arrVCACEntityProperties[i];
letstrPropertyName:string=objVCACEntityProperties.getProperty("PropertyName");
if (strPropertyName==strCustomPropertyName )
{
blnStatus=true;
break;
}
}
returnblnStatus;
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
