To use this function add it to the class library file named vCenterServerService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: vCenterServerService.ts
Description: Orchestrator Function to Find a Virtual Machine DRS Group and Add New Virtual Machines
Function AddVcVirtualMachineToExistingVcClusterVmGroup
public AddVcVirtualMachineToExistingVcClusterVmGroup(objVcClusterComputeResource: VcClusterComputeResource, arrVcVirtualMachineNew: VcVirtualMachine[], strVcClusterVmGroupName: string, strDataCenterName: string): void {
let objVcClusterConfigInfoEx: VcClusterConfigInfoEx = objVcClusterComputeResource.configurationEx as VcClusterConfigInfoEx;
let arrVcClusterGroupInfo: VcClusterGroupInfo[] = objVcClusterConfigInfoEx.group;
let arrVcClusterVmGroup: VcClusterVmGroup[] = arrVcClusterGroupInfo.filter((objVcClusterGroupInfo: VcClusterGroupInfo): objVcClusterGroupInfo is VcClusterVmGroup => {
return objVcClusterGroupInfo instanceof VcClusterVmGroup;
});
let objVcClusterVmGroup: VcClusterVmGroup = arrVcClusterVmGroup.find((objVcClusterVmGroup: VcClusterVmGroup): boolean => {
return objVcClusterVmGroup.name == strVcClusterVmGroupName;
});
let arrVcVirtualMachine: VcVirtualMachine[] = objVcClusterVmGroup.vm;
arrVcVirtualMachine = arrVcVirtualMachine.concat(arrVcVirtualMachineNew);
objVcClusterVmGroup.vm = arrVcVirtualMachine;
let objVcClusterGroupSpec: VcClusterGroupSpec = new VcClusterGroupSpec();
objVcClusterGroupSpec.operation = VcArrayUpdateOperation.edit;
objVcClusterGroupSpec.info = objVcClusterVmGroup;
let arrVcClusterGroupSpec: VcClusterGroupSpec[] = [];
arrVcClusterGroupSpec.push(objVcClusterGroupSpec);
let objVcClusterConfigSpecEx: VcClusterConfigSpecEx = new VcClusterConfigSpecEx();
objVcClusterConfigSpecEx.groupSpec = arrVcClusterGroupSpec;
let objVcTask: VcTask = objVcClusterComputeResource.reconfigureCluster_Task(objVcClusterConfigSpecEx, true);
this.WaitForVcTaskEnd(objVcTask, 1);
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
