Function: vCenter Virtual Machine Reconfigure

by Simon Sparks · 5 January 2026

To use this function add it to the class library file named PluginVCVirtualMachineService.ts

GitHub Repository: https://github.com/SimonSparksUK/Orchestrator

Filename: PluginVCVirtualMachineService.ts

Function: Reconfigure

private Reconfigure(objVcVirtualMachine: VcVirtualMachine, objVcVirtualMachineConfigSpec: VcVirtualMachineConfigSpec): boolean {

	try {
		Locking.lock(`${objVcVirtualMachine.name}-Modification`);

		let objVcTask: VcTask = objVcVirtualMachine.reconfigVM_Task(objVcVirtualMachineConfigSpec);

		this.WaitForVcTaskEnd(objVcTask, 1);

		Locking.unlock(`${objVcVirtualMachine.name}-Modification`);

		return true;
	}
	catch (objException) {
		Utilities.logException(objException, this.objLogger, "VcVirtualMachineReconfigure");

		Locking.unlock(`${objVcVirtualMachine.name}-Modification`);

		if (objException instanceof VcConcurrentAccess) {
			this.objLogger.error(`Thrown if the changeVersion does not match the server's changeVersion for the configuration.`);
		}
		else if (objException instanceof VcCpuHotPlugNotSupported) {
			this.objLogger.error(`Thrown if the current configuration of the VM does not support hot - plugging of CPUs.`);
		}
		else if (objException instanceof VcDuplicateName) {
			this.objLogger.error(`Thrown if the specified name already exists in the parent folder.`);
		}
		else if (objException instanceof VcFileFault) {
			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.`);
		}
		else if (objException instanceof VcInsufficientResourcesFault) {
			this.objLogger.error(`Thrown if this operation would violate a resource usage policy.`);
		}
		else if (objException instanceof VcInvalidDatastore) {
			this.objLogger.error(`Thrown if the operation cannot be performed on the target datastores.`);
		}
		else if (objException instanceof VcInvalidName) {
			this.objLogger.error(`Thrown if the specified name is invalid.`);
		}
		else if (objException instanceof VcInvalidPowerState) {
			this.objLogger.error(`Thrown if the power state is poweredOn and the virtual hardware cannot support the configuration changes.`);
		}
		else if (objException instanceof VcInvalidState) {
			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.`);
		}
		else if (objException instanceof VcMemoryHotPlugNotSupported) {
			this.objLogger.error(`Thrown if the current configuration of the VM does not support hot - plugging of memory.`);
		}
		else if (objException instanceof VcRuntimeFault) {
			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.`);
		}
		else if (objException instanceof VcTaskInProgress) {
			this.objLogger.error(`Thrown if the virtual machine is busy.`);
		}
		else if (objException instanceof VcTooManyDevices) {
			this.objLogger.error(`Thrown if the device specifications exceed the allowed limits.`);
		}
		else if (objException instanceof VcVmConfigFault) {
			this.objLogger.error(`Thrown if the spec is invalid.Typically, a more specific subclass is thrown.`);
		}
		else if (objException instanceof VcVmWwnConflict) {
			this.objLogger.error(`Thrown if the WWN of the virtual machine has been used by other virtual machines.`);
		}

		return false;
	}
}
TypeScript

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like