To use this function add it to the class library file named vCenterServerService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: vCenterServerService.ts
publicVcVirtualMachineClone(objVcVirtualMachine:VcVirtualMachine,strCloneName:string,objVcFolder:VcFolder):void{
letobjVcVirtualMachineRuntimeInfo:VcVirtualMachineRuntimeInfo=objVcVirtualMachine.runtime;
letarrVcDatastore:VcDatastore[]=objVcVirtualMachine.datastore;
letobjVcVirtualMachineRelocateSpec:VcVirtualMachineRelocateSpec=newVcVirtualMachineRelocateSpec();
objVcVirtualMachineRelocateSpec.transform=VcVirtualMachineRelocateTransformation["sparse"];
objVcVirtualMachineRelocateSpec.pool=objVcVirtualMachine.resourcePool;
objVcVirtualMachineRelocateSpec.host=objVcVirtualMachineRuntimeInfo.host;
objVcVirtualMachineRelocateSpec.datastore=arrVcDatastore[0];
letobjVcVirtualMachineCloneSpec:VcVirtualMachineCloneSpec=newVcVirtualMachineCloneSpec();
objVcVirtualMachineCloneSpec.powerOn=false;
objVcVirtualMachineCloneSpec.memory=false;
objVcVirtualMachineCloneSpec.template=false;
objVcVirtualMachineCloneSpec.location=objVcVirtualMachineRelocateSpec;
letobjVcTask:VcTask=objVcVirtualMachine.cloneVM_Task(objVcFolder,strCloneName,objVcVirtualMachineCloneSpec);
this.WaitForVcTaskEnd(objVcTask,2);
this.objLogger.info("Cloning task started for:"+strCloneName);
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
