To use this function add it to the class library file named vCenterServerService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: vCenterServerService.ts
privateVcVirtualMachineReconfigure(objVcVirtualMachine:VcVirtualMachine,objVcVirtualMachineConfigSpec:VcVirtualMachineConfigSpec):boolean{
try{
Locking.lock(`${objVcVirtualMachine.name}-Modification`);
letobjVcTask:VcTask=objVcVirtualMachine.reconfigVM_Task(objVcVirtualMachineConfigSpec);
this.WaitForVcTaskEnd(objVcTask,1);
Locking.unlock(`${objVcVirtualMachine.name}-Modification`);
returntrue;
}
catch (objException){
Utilities.logException(objException,this.objLogger,"VcVirtualMachineReconfigure");
Locking.unlock(`${objVcVirtualMachine.name}-Modification`);
if (objExceptioninstanceofVcConcurrentAccess){
this.objLogger.error(`Thrown if the changeVersion does not match the server's changeVersion for the configuration.`);
}
elseif (objExceptioninstanceofVcCpuHotPlugNotSupported){
this.objLogger.error(`Thrown if the current configuration of the VM does not support hot - plugging of CPUs.`);
}
elseif (objExceptioninstanceofVcDuplicateName){
this.objLogger.error(`Thrown if the specified name already exists in the parent folder.`);
}
elseif (objExceptioninstanceofVcFileFault){
this.objLogger.error(`Thrown if there is a problem creating or accessing the virtual machine's files for this operation. Typically a more specific fault like NoDiskSpace or FileAlreadyExists is thrown.`);
}
elseif (objExceptioninstanceofVcInsufficientResourcesFault){
this.objLogger.error(`Thrown if this operation would violate a resource usage policy.`);
}
elseif (objExceptioninstanceofVcInvalidDatastore){
this.objLogger.error(`Thrown if the operation cannot be performed on the target datastores.`);
}
elseif (objExceptioninstanceofVcInvalidName){
this.objLogger.error(`Thrown if the specified name is invalid.`);
}
elseif (objExceptioninstanceofVcInvalidPowerState){
this.objLogger.error(`Thrown if the power state is poweredOn and the virtual hardware cannot support the configuration changes.`);
}
elseif (objExceptioninstanceofVcInvalidState){
this.objLogger.error(`Thrown if the operation cannot be performed in the current state of the virtual machine.For example, because the virtual machine's configuration is not available.`);
}
elseif (objExceptioninstanceofVcMemoryHotPlugNotSupported){
this.objLogger.error(`Thrown if the current configuration of the VM does not support hot - plugging of memory.`);
}
elseif (objExceptioninstanceofVcRuntimeFault){
this.objLogger.error(`Thrown if any type of runtime fault is thrown that is not covered by the other faults; for example, a communication error.`);
}
elseif (objExceptioninstanceofVcTaskInProgress){
this.objLogger.error(`Thrown if the virtual machine is busy.`);
}
elseif (objExceptioninstanceofVcTooManyDevices){
this.objLogger.error(`Thrown if the device specifications exceed the allowed limits.`);
}
elseif (objExceptioninstanceofVcVmConfigFault){
this.objLogger.error(`Thrown if the spec is invalid.Typically, a more specific subclass is thrown.`);
}
elseif (objExceptioninstanceofVcVmWwnConflict){
this.objLogger.error(`Thrown if the WWN of the virtual machine has been used by other virtual machines.`);
}
returnfalse;
}
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
