5.1

Table Of Contents
Procedure
1 Choose whether to import the virtual machine as a vApp or vApp template.
The VimServer element that represents the vCenter server from which you import the virtual machine
contains two links that import virtual machines. One has the following form, and imports the virtual
machine as a vApp.
<vcloud:Link
rel="add"
type="application/vnd.vmware.admin.importVmAsVAppParams+xml"
href="https://vcloud.example.com/api/admin/extension/vimServer/9/importVmAsVApp" />
The other has the following form, and imports the virtual machine as a vApp template.
<vcloud:Link
rel="add"
type="application/vnd.vmware.admin.importVmAsVAppTemplateParams+xml"
href="https://vcloud.example.com/api/admin/extension/vimServer/9/importVmAsVAppTemplate" />
2 (Optional) If you plan to import the virtual machine as a vApp template, identify a catalog where you
want to place a reference to the template.
Import a Virtual Machine as a vApp
To import a virtual machine as a vApp, a system administrator can make a request to the importVmAsVApp link
of the VimServer that manages the virtual machine.
Prerequisites
n
Verify that you are logged in to the vCloud API as a system administrator.
n
Identify the virtual machine to import. See “Retrieve a List of Virtual Machines from a vCenter Server,”
on page 205.
Procedure
1 Create an ImportVmAsVAppParams element that specifies the VmMoRef of the source virtual machine and a
target vDC to hold the imported vApp.
2 POST the ImportVmAsVAppParams element to the importVmAsVApp link of the source vCenter server.
Example: Import a Virtual Machine as a vApp
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,” on page 206. The request body is an ImportVmAsVAppParams 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 and a
VmMoRef element that contains the managed object reference of the virtual machine to import. The response is
an unresolved vApp body that contains a Task that tracks the import.
Request:
POST https://vcloud.example.com/api/admin/extension/vimServer/9/importVmAsVapp
Content-type: application/vnd.vmware.admin.importVmAsVAppParams+xml
...
<?xml version="1.0" encoding="UTF-8"?>
<ImportVmAsVAppParams
xmlns="http://www.vmware.com/vcloud/extension/v1.5"
name="ImportedWin2K8"
sourceMove="false">
Chapter 7 Managing and Monitoring a Cloud
VMware, Inc. 229