To use this function add it to the class library file named vCenterVAPIService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: vCenterVAPIService.ts
Function getDynamicIDFromVirtualMachine
private getDynamicIDFromVirtualMachine(objVcVirtualMachine: VcVirtualMachine): com_vmware_vapi_std_dynamic__ID {
let objVAPIStandardDynamicID: com_vmware_vapi_std_dynamic__ID = new com_vmware_vapi_std_dynamic__ID();
objVAPIStandardDynamicID.id = objVcVirtualMachine.id;
objVAPIStandardDynamicID.type = objVcVirtualMachine.vimType;
return objVAPIStandardDynamicID;
}Function listAttachedTags
private listAttachedTags(objVAPIClient: VAPIClient, objVcVirtualMachine: VcVirtualMachine): com_vmware_cis_tagging_tag__model[] {
let objDynamicID: com_vmware_vapi_std_dynamic__ID = this.getDynamicIDFromVirtualMachine(objVcVirtualMachine);
let objVAPITaggingTagAssociation: com_vmware_cis_tagging_tag__association = new com_vmware_cis_tagging_tag__association(objVAPIClient);
let arrAttachedTagID: string[] = objVAPITaggingTagAssociation.list_attached_tags(objDynamicID);
let objVAPITaggingTag: com_vmware_cis_tagging_tag = new com_vmware_cis_tagging_tag(objVAPIClient);
let arrVAPITagModel: com_vmware_cis_tagging_tag__model[] = arrAttachedTagID.map((strTagID: string): com_vmware_cis_tagging_tag__model => {
let objVAPITagModel: com_vmware_cis_tagging_tag__model = objVAPITaggingTag.get(strTagID);
return objVAPITagModel;
});
return arrVAPITagModel;
}Function listAttachedTagIDsFromSpecificCategoryID
private listAttachedTagsFromSpecificCategoryID(objVAPIClient: VAPIClient, objVcVirtualMachine: VcVirtualMachine, strCategoryID: string): string[] {
let arrVAPITagModel: com_vmware_cis_tagging_tag__model[] = this.listAttachedTags(objVAPIClient, objVcVirtualMachine);
arrVAPITagModel = arrVAPITagModel.filter((objVAPITagModel: com_vmware_cis_tagging_tag__model): boolean => {
return objVAPITagModel.category_id === strCategoryID;
});
let arrVAPITagID: string[] = arrVAPITagModel.map((objVAPITagModel: com_vmware_cis_tagging_tag__model): string => {
return objVAPITagModel.id;
});
return arrVAPITagID;
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
