The VMware Cloud Director API supports recomposition of a vApp to add, remove, and reconfigure its virtual machines. To recompose a vApp, make a recomposeVApp request, supplying a RecomposeVAppParams element as the request body.
The RecomposeVAppParams element allows an arbitrary number of DeleteItem and ReconfigureItem elements, but is otherwise identical to ComposeVAppParams.
<Link rel="recompose" type="application/vnd.vmware.vcloud.recomposeVAppParams+xml" href="https://vcloud.example.com/api/vApp/vapp-33/action/recomposeVApp" />To recompose a vApp, POST a recomposeVApp request to this link. The request body is a RecomposeVAppParams element, which can include all the information allowed in a ComposeVAppParams, as well as the following additional elements:
- ReconfigureItem elements that reconfigure virtual machines in the vApp. By including ReconfigureItem elements, you can enable a recomposeVApp request to make the same kinds of virtual machine configuration changes you can make with a reconfigureVm request. See Update Multiple Sections of a Virtual Machine
- DeleteItem elements remove virtual machines from the vApp
Prerequisites
This operation requires the rights included in the predefined vApp Author role or an equivalent set of rights.
Procedure
Example: Recompose a vApp
A RecomposeVAppParams request body prototype is similar to the ComposeVAppParams prototype shown in Compose a vApp. Instantiation parameters for the recomposed vApp appear as a root level InstantiationParams element. Instantiation parameters for added virtual machines appear as InstantiationParams in SourcedItem elements whose Source element references a virtual machine.
<VApp name="Example Corp’s CRM Appliance" type="application/vnd.vmware.vcloud.vApp+xml" status="8" href="https://vcloud.example.com/api/vApp/vapp-33" ...> ... <Link rel="recompose" type="application/vnd.vmware.vcloud.recomposeVAppParams+xml" href="https://vcloud.example.com/api/vApp/vapp-33/action/recomposeVApp" /> ... <Children> <Vm status="8" name="CRM-DB-ORCL" href="https://vcloud.example.com/api/vApp/vm-7" ...> ... </Vm> <Vm status="8" name="CRM-CRM" href="https://vcloud.example.com/api/vApp/vm-44" ...> ... </Vm> <Vm status="8" name="CRM-HTTP" href="https://vcloud.example.com/api/vApp/vm-45" ...> ... </Vm> </Children> ... </VApp>
<Vm status="8" name="CRM-DB-POSTGRES" href="https://vcloud.example.com/api/vApp/vm-90" ...> ... </Vm>
To do that, create a request like this one, which removes the old database server (DeleteItem), adds the new one (SourcedItem, including InstantiationParams that connect it to the vApp network), and modifies the StartupSection to specify an appropriate start order for the recomposed vApp.
POST https://vcloud.example.com/api/vApp/vapp-33/action/recomposeVApp Content-Type: application/vnd.vmware.vcloud.recomposeVAppParams+xml ... <?xml version="1.0" encoding="UTF-8"?> <RecomposeVAppParams name="Example Corp’s CRM Appliance" xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"> <Description>Composed CRM Appliance</Description> <InstantiationParams> <NetworkConfigSection> <ovf:Info>Configuration parameters for logical networks</ovf:Info> <NetworkConfig networkName="CRMApplianceNetwork"> <Configuration> <ParentNetwork href="https://vcloud.example.com/api/network/54"/> <FenceMode>natRouted</FenceMode> </Configuration> </NetworkConfig> </NetworkConfigSection> <ovf:StartupSection xmlns:vcloud="http://www.vmware.com/vcloud/v1.5" vcloud:type="application/vnd.vmware.vcloud.startupSection+xml"> <ovf:Info>VApp startup section</ovf:Info> <ovf:Item ovf:order="0" ovf:id="CRM-DB-POSTGRES"/> <ovf:Item ovf:order="1" ovf:id="CRM-CRM"/> </ovf:StartupSection> </InstantiationParams> <SourcedItem> <Source href="https://vcloud.example.com/api/vApp/vm-90"/> <InstantiationParams> <NetworkConnectionSection xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" type="application/vnd.vmware.vcloud.networkConnectionSection+xml" href="https://vcloud.example.com/api/vApp/vm-4/networkConnectionSection/" ovf:required="false"> <ovf:Info/> <PrimaryNetworkConnectionIndex>0</PrimaryNetworkConnectionIndex> <NetworkConnection network="CRMApplianceNetwork"> <NetworkConnectionIndex>0</NetworkConnectionIndex> <IsConnected>true</IsConnected> <IpAddressAllocationMode>DHCP</IpAddressAllocationMode> </NetworkConnection> </NetworkConnectionSection> </InstantiationParams> </SourcedItem> <AllEULAsAccepted>true</AllEULAsAccepted> <DeleteItem href="https://vcloud.example.com/api/vApp/vm-8"/> </RecomposeVAppParams>
<?xml version="1.0" encoding="UTF-8"?> <RecomposeVAppParams name="Example Corp’s CRM Appliance" xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"> <Description>Composed CRM Appliance</Description> <InstantiationParams> ... </InstantiationParams> <AllEULAsAccepted>true</AllEULAsAccepted> <DeleteItem href="https://vcloud.example.com/api/vApp/vm-8"/> <ReconfigureItem name="vm-90" href="https://vcloud.example.com/api/vApp/vm-90"> <ovf:Section xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="NetworkConnectionSectionType"> <ovf:Info>My Network Connection Section Info</ovf:Info> <PrimaryNetworkConnectionIndex>0</PrimaryNetworkConnectionIndex> <NetworkConnection network="CRMApplianceNetwork"> <NetworkConnectionIndex>0</NetworkConnectionIndex> <IsConnected>true</IsConnected> <IpAddressAllocationMode>DHCP</IpAddressAllocationMode> </NetworkConnection> </ovf:Section> </ReconfigureItem> </RecomposeVAppParams>
https://vcloud.example.com/api/query?type=adminVM&format=references&filter=status==POWERED_OFFSee Using the Query Service.
202 Accepted Content-Type: application/vnd.vmware.vcloud.task+xml ... <Task ... operation="Updating Virtual Application Example Corp’s CRM Appliance (33)" ...> ... </Task>