Deploy a Virtual Machine from a VM
Template in a Content Library
By using the
vSphere
Automation
APIs, you can deploy a virtual machine
from a VM template stored in a content library. - Verify that you have administrative privileges on yourvCenter Serverinstance.
- Verify that you created avSphere Automationsession to yourvCenter Serverinstance.
To deploy a virtual machine from a VM template in a
content library,
use the
. You can specify the power state and customize the guest operation
system prior to the virtual machine deployment. POST
https://<
HTTP
requestvcenter_ip_address_or_fqdn
>/api/vcenter/vm-template/library-items/<vm_template_item_id
>?action=deployFor information about the available and
mandatory parameters, see the
API
Reference
documentation. - Review the information stored in the VM template library item.You can use the. If you did not save the ID of your item, you can select the UUID of your VM template item by using theGET https://<HTTP requestvcenter_ip_address_or_fqdn>/api/vcenter/vm-template/library-items/<vm_template_item_id>vSphere Client. The URN ends with the ID of the item and has the following format:urn:vapi:com.vmware.content.library.Item:<.VMTemplateItemID>
- Get the ID of the host on which you want to deploy the virtual machine.You can use the.GET https://<HTTP requestvcenter_ip_address_or_fqdn>/api/vcenter/host
- Get the ID of the resource pool to which you want to add your virtual machine.You can use the.https://<HTTP requestvcenter_ip_address_or_fqdn>/api/vcenter/resource-pool
- Get the ID of theVIRTUAL_MACHINEfolder to which you want to add your virtual machine.You can use the.GET https://<HTTP requestvcenter_ip_address_or_fqdn>/api/vcenter/folder
- Get the ID of the datastore on which you want to store log, configuration, and disk files of the virtual machine.You can use the.GET https://<HTTP requestvcenter_ip_address_or_fqdn>/api/vcenter/datastore
- Create a deployment specification.You can use thebody of the.POST https://<HTTP requestvcenter_ip_address_or_fqdn>/api/vcenter/vm-template/library-items/<vm_template_item_id>?action=deploy
- Specify a name and description of the virtual machine that you want to deploy.
- Specify the place in your inventory on which you want to deploy the virtual machine such as anESXihost, resource pool, and VM folder.You can use the. You must use the IDs of your inventory objects.placementparameter in the body of the request
- Specify the datastore on which you want to store the log, configuration, and disk files of the virtual machine. You must use the ID of the datastore.You can use the.vm_home_storage, anddisk_storageparameters in the body of the request
- Specify the guest operating system and hardware customization specifications that you want to apply to the virtual machine during the deployment process. Add this information to the deployment specification.You can use the. You can get a list of the guest operating system customization specifications that are available in yourguest_customizationandhardware_customizationparameters in the body of the requestvCenter Serverby using the.GET https://<HTTP requestvcenter_ip_address_or_fqdn>/api/vcenter/guest/customization-specs
- Include the placement and storage specifications in the deployment specification.
- Deploy a virtual machine from your VM template.You can use the.POST https://<HTTP requestvcenter_ip_address_or_fqdn>/api/vcenter/vm-template/library-items/<vm_template_item_id>?action=deploy
If the operation is successful, the ID of the
deployed virtual machine is returned. For information about the possible exceptions,
see the
API Reference
documentation.