To import a virtual machine as a vApp template, a system administrator can make a request to the importVmAsVAppTemplate link of the VimServer that manages the virtual machine.

This operation is restricted to system administrators.

Identify the virtual machine to import. See Retrieve a List of Virtual Machines from a vCenter Server.

1

Create an ImportVmAsVAppTemplateParams element that specifies the VmMoRef of the source virtual machine, a target VDC to hold the imported vApp template, and an optional catalog where you want to place a reference to the template.

2

POST the ImportVmAsVAppTemplateParams element to the importVmAsVAppTemplate link of the source vCenter server.

This example imports one of the virtual machines shown in the response portion of Example: Retrieve a List of Virtual Machines from a vCenter Server as a vApp template. The request body is an ImportVmAsVAppTemplateParams element whose sourceMove attribute specifies that the source virtual machine should remain in vCenter inventory after the import is complete. The request body includes the href of the VDC that receives the import, a VmMoRef element that contains the managed object reference of the virtual machine to import, and a Catalog element that references the catalog to which the imported template should be added. The response is an unresolved VAppTemplate body that contains a Task that tracks the import.

Request:

POST https://vcloud.example.com/api/admin/extension/vimServer/9/importVmAsVappTemplate
Content-type: application/vnd.vmware.admin.importVmAsVAppTemplateParams+xml
...
<?xml version="1.0" encoding="UTF-8"?>
<ImportVmAsVAppTemplateParams
   xmlns="http://www.vmware.com/vcloud/extension/v1.5"
   name="ImportedWin2K8"
   sourceMove="false">
   <VmMoRef>vm-43</VmMoRef>
   <Vdc
      href="http://vcloud.example.com/api/vdc/2" />
   <Catalog
      href="http://vcloud.example.com/api/catalog/32" />
</ImportVmAsVAppTemplateParams>

Response:

201 Created
Content-Type: application/vnd.vmware.vcloud.vAppTemplate+xml
...
<VAppTemplate ...
   status="0"
   name="ImportedWin2K8"
   type="application/vnd.vmware.vcloud.vAppTemplate+xml"
   href="https://vcloud.example.com/api/vAppTemplate/vappTemplate-64" ... >
   ...
   <Description />
   <Tasks>
      <Task
         operation=”Busy Virtual Application Template Win2K8 ”>
         ... 
      </Task>
   </Tasks>
</VAppTemplate>