Function: vCenter Virtual Machine Check vMotion Validity

by Simon Sparks · 21 February 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

Description: Orchestrator Function to check the validity of a vMotion operation before executing it.

Private Function: CheckVMotion

private CheckVMotion(objVcVirtualMachine: VcVirtualMachine, objVcHostSystem: VcHostSystem, objVcResourcePool: VcResourcePool, objVcVirtualMachinePowerState: VcVirtualMachinePowerState): void {

    let objVcSdkConnection: VcSdkConnection = objVcVirtualMachine.sdkConnection;

    let objVcVirtualMachineProvisioningChecker: VcVirtualMachineProvisioningChecker = objVcSdkConnection.vmProvisioningChecker;

    let arrTestType: string[] = ["datastoreTests", "hostTests", "networkTests", "resourcePoolTests", "sourceTests"];

    let objVcTask: VcTask = objVcVirtualMachineProvisioningChecker.checkMigrate_Task(objVcVirtualMachine, objVcHostSystem, objVcResourcePool, objVcVirtualMachinePowerState, arrTestType);

    objVcTask = this.WaitForVcTaskEnd(objVcTask, 1);

    let objVcTaskInfo: VcTaskInfo = objVcTask.info;

    let objVcTaskInfoState: VcTaskInfoState = objVcTaskInfo.state;

    let objVcLocalizedMethodFault: VcLocalizedMethodFault = objVcTaskInfo.error;

    let objVcMethodFault: VcMethodFault = objVcLocalizedMethodFault.fault;

    if (objVcTaskInfoState === VcTaskInfoState["error"] && objVcMethodFault) {
        this.objLogger.info(`${objVcTaskInfoState.name}`);
        this.objLogger.info(`${objVcTaskInfoState.value}`);

        this.objLogger.info(`${objVcLocalizedMethodFault.localizedMessage}`);
        this.objLogger.info(`${objVcLocalizedMethodFault.message}`);

        this.objLogger.info(`${objVcMethodFault.localizedMessage}`);
        this.objLogger.info(`${objVcMethodFault.message}`);
    }
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like