Orchestrator Function: vCenter VAPI Plugin Content Library Item Deploy

by Simon Sparks · 18 January 2026

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

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

Filename: vCenterVAPIService.ts

Function ContentLibraryItemDeployOVF

public ContentLibraryItemDeployOVF(objVAPIContentLibraryModel: com_vmware_content_library__model, strHostname: string, objVcVmFolder: VcVmFolder, objVcDatastore: VcDatastore, objVcHostSystem: VcHostSystem, objVcResourcePool: VcResourcePool): VcVirtualMachine {

    let objVAPIVCenterOVFLibraryItemDeploymentTarget: com_vmware_vcenter_ovf_library__item_deployment__target = new com_vmware_vcenter_ovf_library__item_deployment__target();
    objVAPIVCenterOVFLibraryItemDeploymentTarget.folder_id = objVcVmFolder.id;
    objVAPIVCenterOVFLibraryItemDeploymentTarget.host_id = objVcHostSystem.id;
    objVAPIVCenterOVFLibraryItemDeploymentTarget.resource_pool_id = objVcResourcePool.id;

    let objVAPIVCenterOVFLibraryItemResourcePoolDeploymentSpec: com_vmware_vcenter_ovf_library__item_resource__pool__deployment__spec = new com_vmware_vcenter_ovf_library__item_resource__pool__deployment__spec();
    objVAPIVCenterOVFLibraryItemResourcePoolDeploymentSpec.accept_all_EULA = true;
    objVAPIVCenterOVFLibraryItemResourcePoolDeploymentSpec.name = strHostname;
    objVAPIVCenterOVFLibraryItemResourcePoolDeploymentSpec.default_datastore_id = objVcDatastore.id;

    let objVAPIVCenterOvfLibraryItem: com_vmware_vcenter_ovf_library__item = new com_vmware_vcenter_ovf_library__item(this.objVAPIClient);

    let objVAPIVCenterOVFLibraryItemDeploymentResult: com_vmware_vcenter_ovf_library__item_deployment__result = objVAPIVCenterOvfLibraryItem.deploy(null, objVAPIContentLibraryModel.id, objVAPIVCenterOVFLibraryItemDeploymentTarget, objVAPIVCenterOVFLibraryItemResourcePoolDeploymentSpec);

    let objVAPIVCenterOVFLibraryItemDeployableIdentity: com_vmware_vcenter_ovf_library__item_deployable__identity = objVAPIVCenterOVFLibraryItemDeploymentResult.resource_id;

    let strXPathQuery: string = `xpath:matches(id, '${objVAPIVCenterOVFLibraryItemDeployableIdentity.id}')`;

    let arrVcVirtualMachine: VcVirtualMachine[] = VcPlugin.getAllVirtualMachines(null, strXPathQuery);

    let objVcVirtualMachine: VcVirtualMachine = arrVcVirtualMachine.find((objVcVirtualMachine: VcVirtualMachine):boolean=>{
        return objVcVirtualMachine.id === objVAPIVCenterOVFLibraryItemDeployableIdentity.id;
    });

    return objVcVirtualMachine;
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like