To use this function add it to the class library file named vCenterServerService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: vCenterServerService.ts
Public Function: VcClusterComputeResourceGetBestVcHostSystem
public VcClusterComputeResourceGetBestVcHostSystem(objVcClusterComputeResource: VcClusterComputeResource): VcHostSystem {
let arrVcHostSystem: VcHostSystem[] = this.VcHostSystemGetAllByVcClusterComputeResource(objVcClusterComputeResource);
arrVcHostSystem.sort((objVcHostSystemA: VcHostSystem, objVcHostSystemB: VcHostSystem): 1 | -1 | 0 => {
let objVcHostListSummaryA: VcHostListSummary = objVcHostSystemA.summary;
let objVcHostListSummaryB: VcHostListSummary = objVcHostSystemB.summary;
let objVcHostListSummaryQuickStatsA: VcHostListSummaryQuickStats = objVcHostListSummaryA.quickStats;
let objVcHostListSummaryQuickStatsB: VcHostListSummaryQuickStats = objVcHostListSummaryB.quickStats;
if (objVcHostListSummaryQuickStatsA.overallCpuUsage < objVcHostListSummaryQuickStatsB.overallCpuUsage) {
return -1;
} else if (objVcHostListSummaryQuickStatsA.overallCpuUsage > objVcHostListSummaryQuickStatsB.overallCpuUsage) {
return 1;
}
return 0;
});
if (arrVcHostSystem.length != null && arrVcHostSystem.length > 1) {
let objVcHostSystemUsable: VcHostSystem = arrVcHostSystem.pop();
this.objLogger.info(`We have chosen to use VcHostSystem '${objVcHostSystemUsable.name}' which has an overall CPU usage of '${objVcHostSystemUsable.summary.quickStats.overallCpuUsage}' MHz to perform the compute and storage vMotion.`);
return objVcHostSystemUsable;
}
else {
return null;
}
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
