You can make a copy of a vApp by cloning it. If the vApp is deployed when you clone it, the clone procedure also clones the memory state of the virtual machines in the vApp.

The cloneVApp request makes a copy of the vApp referenced in the Source element of the CloneVappParams request body. The request specifies a new name and, optionally, a new description for the copy.

The request can optionally include an IsSourceDelete element whose value specifies whether to delete the source vApp after the copy is complete. If IsSourceDelete is missing from the request body, or present with a value of false, the source object remains in place after the copy is complete. Setting IsSourceDelete to true effectively moves or renames the vApp.

The request can also include a SourcedItem element for each VM that you want to modify during the cloning process. In each SourcedItem element, you must specify the target VM in a Source element and the new values of the properties that you want to modify. For example, if you want to configure a new storage profile for a cloned VM, use the StorageProfile element in the SourcedItem element. If you want to configure a VDC compute policy for a cloned VM, use the VdcComputePolicy element in the SourcedItem element. For information about VDC compute policies, see Managing VM-Host Affinity Rules and VDC Compute Policies.

If the vApp is deployed when you clone it and the target VDC is backed by the same provider VDC as the source VDC, the clone is created with the following properties:

Memory state of all virtual machines in the source vApp is preserved in the clone.

The clone is suspended and connected to an isolated network.

This operation requires the rights included in the predefined vApp Author role or an equivalent set of rights.

1

Retrieve the XML representation of the VDC in which you want to deploy the cloned vApp.

Use a request like this one, where id is the identifier of the VDC:

GET https://vcloud.example.com/vdc/id

You can create the clone in the same VDC that holds the source vApp, or in a different VDC.

2

Examine the response to locate the Link element that contains the URL for cloning a vApp.

This element has a rel attribute value of add and a type attribute value of application/vnd.vmware.vcloud.cloneVAppParams+xml, as shown here:

<Link
   rel="add"
   type="application/vnd.vmware.vcloud.cloneVAppParams+xml"
   href="https://vcloud.example.com/api/vdc/12/action/cloneVApp"/>
3

Create a CloneVappParams element that references the vApp to clone and specifies details of the clone operation.

See Example: Clone a vApp.

4

POST the CloneVappParams element to the action/cloneVApp link of the VDC in which you want to create the clone.

This request creates a copy of the vApp created in Example: Instantiate a vApp Template and Modify Virtual Machine Name, Description, and Storage Profile in another VDC. Because the ParentNetwork in the Source vApp is not available in the VDC specified in the action/cloneVApp request, the CloneVAppParams request body must include InstantiationParams that specify a new ParentNetwork for the vApp network, one that is available in the target VDC. The request also includes a SourcedItem specifying a new storage profile and a VDC compute policy for the virtual machine in the vApp.

Note

If the vApp is deployed when you clone it, any network configuration you specify in the CloneVAppParams is ignored and the clone is created with a connection to an isolated network.

Request:

POST https://vcloud.example.com/api/vdc/12/action/cloneVApp
Content-Type: application/vnd.vmware.vcloud.cloneVAppParams+xml
...
<?xml version="1.0" encoding="UTF-8"?>
<CloneVAppParams
   xmlns="http://www.vmware.com/vcloud/v1.5"
   xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
   name="cloned"
   deploy="false"
   powerOn="false">
   <Description>Cloned vApp Example</Description>
   <InstantiationParams>
      <NetworkConfigSection>
         <ovf:Info>Configuration parameters for logical networks</ovf:Info>
         <NetworkConfig networkName="vAppNetwork">
            <Configuration>
               <ParentNetwork href="https://vcloud.example.com/api/network/101"/>
               <FenceMode>bridged</FenceMode>
            </Configuration>
         </NetworkConfig>
      </NetworkConfigSection>
   </InstantiationParams>
   <Source href="https://vcloud.example.com/api/vApp/vapp-7"/>
   <IsSourceDelete>false</IsSourceDelete>
   <SourcedItem>
      <Source href="https://vcloud.example.com/api/vAppTemplate/vm-4"/>
      <StorageProfile href="https://vcloud.example.com/api/vdcStorageProfile/45">
      </StorageProfile>
      <VdcComputePolicy href="https://vcloud.example.com/cloudapi/vdcComputePolicies/74" name="policy_vmGroup2_cluster1">
      </VdcComputePolicy>
   </SourcedItem>
</CloneVAppParams>

The response is a sparsely populated VApp element in the target VDC. When the Task embedded in the response is complete, the vApp has been cloned.

Response:

201 Created
Content-Type: application/vnd.vmware.vcloud.vApp+xml
...
<VApp
   xmlns="http://www.vmware.com/vcloud/v1.5"
   xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
   deployed="false"
   status="0"
   name="cloned"
   type="application/vnd.vmware.vcloud.vApp+xml"
   href="https://vcloud.example.com/api/vApp/vapp-103">
   ...
   <Link
      rel="up"
      type="application/vnd.vmware.vcloud.vdc+xml"
      href="https://vcloud.example.com/api/vdc/12"/>
   ...
   <Description>Cloned vApp Example</Description>
   ...
   <Tasks>
      <Task
         status="running"
         operation="Copying Virtual Application cloned (103)"
         ... >
      </Task>
   </Tasks>
   ...
</VApp>