To use this function add it to the class library file named vCenterService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: vCenterService.ts
Function VcVirtualMachineCustomAttributeValueGet
Description: Orchestrator Function to Get the Current Value of a Custom Attribute
publicVcVirtualMachineCustomAttributeValueGet(objVcVirtualMachine:VcVirtualMachine,strVcCustomFieldName:string):string{
letobjVcSdkConnection: VcSdkConnection=objVcVirtualMachine.vimHost;
letobjVcCustomFieldsManager: VcCustomFieldsManager=objVcSdkConnection.customFieldsManager;
letarrVcCustomFieldDef: VcCustomFieldDef[]=objVcCustomFieldsManager.field;
letobjVcCustomFieldDef: VcCustomFieldDef=arrVcCustomFieldDef.find((objVcCustomFieldDef: VcCustomFieldDef):boolean=>{
returnobjVcCustomFieldDef.name===strVcCustomFieldName;
});
letarrVcCustomFieldValue: VcCustomFieldValue[]=objVcVirtualMachine.customValue;
letobjCustomFieldValue: VcCustomFieldValue=arrVcCustomFieldValue.find((objVcCustomFieldValue: VcCustomFieldValue):boolean=>{
returnobjVcCustomFieldValue.key===objVcCustomFieldDef.key;
});
//@ts-ignore
letstrReturnValue:string=objCustomFieldValue.value;
returnstrReturnValue;
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
