power13
Contributor
Contributor

Deploy VM from template which is located in a content library

Hello together,

I would like to deply a new VM from a tempate which is loacted in the vSphere content library.

I have seen there are already prepared workflows in vRealize Orchestrator to deploy a VM from another VM or a VM template.

One prepared workflow for example is under vCenter --> Virtual Machine management --> Clone --> Windows Customizatio --> Clone, Windows with single NIC and credential. To deploy a VM with this workflow, I need to select in the inventory the source VM, which is cloned. Unfortunately, I can not select the VM temlate which was distributed / synchronized from the content library.

Is there a way, how I can deploy a new VM with vRealize Orchestrator from a tempate which is distributed / synchronized from a vSphere content library? All suggestions are welcome.

I am using vRealize Orchestrator version 7.0.1.

0 Kudos
5 Replies
tschoergez
Leadership
Leadership

Hi,

the tasks that involve Content Library do not use the regular vCenter API (which would be exposed through the vCenter Plugin into vRO), but it's a separate, REST based API.

You should be able to use the HTTP-REST Plugin of vRO to develop workflows against the Content Library API.

Check these examples:

https://github.com/vmware/content-library-api-samples

http://blogs.vmware.com/developer/2015/05/content-library-blog-series.html

Regards,

Joerg

0 Kudos
iiliev
VMware Employee
VMware Employee

In latest vRO releases there is vAPI plug-in which provides a way to access the newer API, including content library API.

0 Kudos
power13
Contributor
Contributor

Thank you for your hint. To use the vAPI plugin, is the vCloud Suite needed?

0 Kudos
iiliev
VMware Employee
VMware Employee

Well, vAPI plug-in is a generic plug-in that can communicate with any vAPI endpoint, so technically speaking there is no hard dependency on vCloud Suite.

On the other hand, Content Library is part of vSphere/vCenter. Apart from vCloud Suite there might be also other VMware products that provide access to it, but I don't have a list of these products. You may need to check the documentation or talk with your VMware contact.

0 Kudos
NarendarKT
Contributor
Contributor

Please use below script to get depoy the VM from content library after adding the vapi end point in vmware orachestrator.

input & out put parameters:

                                                                                                                                                    
NameTypeDescription
datastoreVC:DatastoreThe datastore to deploy to
endpointVAPI:VAPIEndpointThe VAPI endpoint to use
folderVC:VmFolderThe folder to deploy to
hostVC:HostSystemThe target host for deployment
hostnamestringName of the new VM
ovfLibraryItemIdstringid of the content library item
respoolVC:ResourcePool  

Resource pool to deploy to

  

vmObject VC:VirtualMachine VM created details

Script :

// Set the VAPI endpoint to the first endpoint returned
 
if (endpoint == null) {
throw "Unable to locate a VAPI endpoint";
}
var client = endpoint.client();
 
try {
var itemSvc = new com_vmware_content_library_item(client)
var findItemSpec = new com_vmware_content_library_item_find__spec()
findItemSpec.name = TemplateName
var results = itemSvc.find(findItemSpec)
 
if (!Array.isArray(results) || !results.length) {
throw new Error("Content Library template " + TemplateName + " was not found")
}
 
var ovfLibraryItemId = results.shift()
 
// create a DeploymentTarget
var deploymentTarget = new com_vmware_vcenter_ovf_library__item_deployment__target();
 
deploymentTarget.folder_id = folder.id;
deploymentTarget.host_id = host.id;
deploymentTarget.resource_pool_id = respool.id;
 
// create a ResourcePoolDeploymentSpec
var resourcePoolDeploymentSpec = new com_vmware_vcenter_ovf_library__item_resource__pool__deployment__spec();
resourcePoolDeploymentSpec.accept_all_EULA = true;
resourcePoolDeploymentSpec.name = hostname;
resourcePoolDeploymentSpec.default_datastore_id = datastore.id;
 
// deploy the ovf
var ovfSvc = new com_vmware_vcenter_ovf_library__item(client);
var result = ovfSvc.deploy(null, ovfLibraryItemId, deploymentTarget, resourcePoolDeploymentSpec);
 
// return the vmObject
vmObject = VcPlugin.getAllVirtualMachines(null, "xpath:matches(id, '" + result.resource_id.id + "')")[0];
 
}
finally {
client.close();
}

 
0 Kudos