To use this function add it to the class library file named OrchestratorPluginSRMService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: OrchestratorPluginSRMService.ts
Public Function: SRMSiteGet
public SRMSiteGet(objVcVirtualMachine: VcVirtualMachine): SRMSite {
let objVcSdkConnection: VcSdkConnection = objVcVirtualMachine.sdkConnection;
let strVcSdkConnection: string = objVcSdkConnection.toString();
let arrSRMSite: SRMSite[] = this.SRMSitesGet();
let arrSRMSiteForVcVirtualMachine: SRMSite[] = arrSRMSite.filter((objSRMSite: SRMSite): boolean => {
return objSRMSite.name === strVcSdkConnection;
});
let objSRMSiteForVcVirtualMachine: SRMSite = arrSRMSiteForVcVirtualMachine[0];
let objSRMSite: SRMSite = null;
let arrSRMSiteByDeploymentId: SRMSite[] = null;
if (!objSRMSiteForVcVirtualMachine) {
let strVcSdkConnectionInstanceUuid: string = objVcSdkConnection.instanceUuid;
arrSRMSiteByDeploymentId = arrSRMSite.filter((objSRMSite: SRMSite): boolean => {
return objSRMSite.deploymentId.startsWith(strVcSdkConnectionInstanceUuid) === true;
});
if (arrSRMSiteByDeploymentId.length > 1) {
throw new GeneralError(`We found more than 1 SRM Site using the vCenter Virtual Machine InstanceUuid '${strVcSdkConnectionInstanceUuid}'.`);
}
if (arrSRMSiteByDeploymentId.length === 0) {
throw new GeneralError(`We cannot found SRM Site using the vCenter Virtual Machine InstanceUuid '${strVcSdkConnectionInstanceUuid}'.`);
}
objSRMSite = arrSRMSiteByDeploymentId[0];
} else {
objSRMSite = objSRMSiteForVcVirtualMachine;
}
if (!objSRMSite) {
throw new GeneralError(`Cannot find SRM Site for VM '${objVcVirtualMachine.name}'. Make sure that all vCenter, SRM and Replication plugins are configured.`);
}
return objSRMSite;
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
