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 CustomPropertyGetValue
Description: Orchestrator Workflow Script to Get the Current Value of a Custom Property in vRealize Automation v7.x
publicCustomPropertyGetValue(objVcVirtualMachine:VcVirtualMachine,strPropertyNameToFind:string):string{
letobjVcVirtualMachineConfigInfo:VcVirtualMachineConfigInfo=objVcVirtualMachine.config;
letarrvCACVirtualMachine:vCACVirtualMachine[]=Server.findAllForType("vCAC:VirtualMachine","VMUniqueID eq '"+objVcVirtualMachineConfigInfo.instanceUuid+"'")asvCACVirtualMachinep[];
letobjvCACVirtualMachine:vCACVirtualMachine=arrvCACVirtualMachine[0];
letobjvCACEntity:VCACEntity=objvCACVirtualMachine.getEntity();
letobjvCACHost:vCACHost=Server.findForType("vCAC:VCACHost",objvCACEntity.hostId);
letarrVCACEntityProperties:VCACEntity[]=objvCACEntity.getLink(objvCACHost,"VirtualMachineProperties");
varstrReturnValue:string="";
for (vari=0;i<arrVCACEntityProperties.length;i++){
varobjVCACEntityProperties:VCACEntity=arrVCACEntityProperties[i];
varstrPropertyName:string=objVCACEntityProperties.getProperty("PropertyName");
varstrPropertyValue:string=objVCACEntityProperties.getProperty("PropertyValue");
if (strPropertyName==strPropertyNameToFind){
strReturnValue=strPropertyValue;
break;
}
}
returnstrReturnValue;
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
