Hi there forum!
I'm attempting to deploy a vApp from a template and customize the VM's network config during instantiation.
I've followed the example documentation pretty slavishly as per the documentation site for my vcloud director version here: http://pubs.vmware.com/vcd-56/index.jsp#com.vmware.vcloud.api.doc_56/GUID-BF9B790D-512E-4EA1-99E8-68...
But I'm getting an error from vCLoud Director that suggests the example is bogus, thus:
HTTP/1.1 400 Bad Request
Content-Length: 484
Content-Type: application/vnd.vmware.vcloud.error+xml;version=5.5
Date: Tue, 21 Jun 2016 03:54:51 GMT
Date: Tue, 21 Jun 2016 03:54:52 GMT
X-VMWARE-VCLOUD-REQUEST-EXECUTION-TIME: 228
X-VMWARE-VCLOUD-REQUEST-ID: 86662ed4-ed2b-400b-8b09-223f18a08d3c
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Error xmlns:ns0="http://www.vmware.com/vcloud/v1.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" majorErrorCode="400" message="Bad request - Unexpected JAXB Exception - cvc-complex-type.2.3: Element 'Configuration' cannot have character [children], because the type's content type is element-only." minorErrorCode="BAD_REQUEST" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://10.220.0.5/api/v1.5/schema/master.xsd" />
Here is my XML payload - what is actually wrong with it?:
<InstantiateVAppTemplateParams
xmlns="http://www.vmware.com/vcloud/v1.5"
name="poc-vcloud-app09"
deploy="true"
powerOn="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1">
<Description>Test vCloud Deployment</Description>
<Source href="https://vcloud.demo.ac3.com.au/api/vAppTemplate/vappTemplate-10f780a6-c5f3-46d8-981b-f81151a9b500"/>
<SourcedItem>
<Source href="https://vcloud.demo.ac3.com.au/api/vAppTemplate/vm-c9753039-78a7-42f2-a038-ec8babf4d07f"/>
<VmGeneralParams>
<Name>poc-vcloud-app09</Name>
<Description>Test vCloud Deployment</Description>
<NeedsCustomization>true</NeedsCustomization>
</VmGeneralParams>
<InstantiationParams>
<NetworkConfigSection>
<ovf:Info>Configuration parameters for logical networks
</ovf:Info>
<NetworkConfig networkName="VM Network">
<Configuration>
<ParentNetwork href="https://vcloud.demo.ac3.com.au/api/network/56117a52-19d2-4189-94c8-5b37ae7c6e34"/>
<FenceMode>bridged</FenceMode>
</Configuration>
</NetworkConfig>
</NetworkConfigSection>
</InstantiationParams>
</SourcedItem>
<NetworkAssignment innerNetwork="VM Network" containerNetwork="PROD"/>
<StorageProfile href="https://vcloud.demo.ac3.com.au/api/vdcStorageProfile/0b486266-b6ec-4692-b5ba-1596633e2d00"/>
<AllEULAsAccepted>true</AllEULAsAccepted>
</InstantiateVAppTemplateParams>
I think you need the <ovf:Info> element, as shown here (from Create a vApp From a Template)
<NetworkConfigSection>
<ovf:Info>Configuration parameters for logical networks</ovf:Info>
<NetworkConfig networkName="vAppNetwork">
<Configuration>
<ParentNetwork href="https://vcloud.example.com/api/network/54"/>
<FenceMode>bridged</FenceMode>
</Configuration>
</NetworkConfig>
</NetworkConfigSection>
I never really figured out why vCloud Director didn't accept the payload in my original post. The documentation is clearly not trustworthy, I'm sorry to say.
I finally got it to work with this (it's an eRuby template, so the #{variables} indicate interpolated values from the ruby program):
<?xml version="1.0" encoding="UTF-8"?>
<InstantiateVAppTemplateParams
xmlns="http://www.vmware.com/vcloud/v1.5"
name="#{vapp_name}"
deploy="true"
powerOn="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1">
<Description>#{vapp_description}</Description>
<InstantiationParams>
<NetworkConfigSection>
<ovf:Info>Configuration parameters for logical networks
</ovf:Info>
<NetworkConfig networkName="#{vapp_net_name}">
<Configuration>
<ParentNetwork
href="#{network_url}"
name="#{vapp_net_name}"
type="application/vnd.vmware.vcloud.network+xml"/>
<FenceMode>bridged</FenceMode>
</Configuration>
</NetworkConfig>
</NetworkConfigSection>
</InstantiationParams>
<Source href="#{vapp_template_url}"/>
<SourcedItem>
<Source href="#{vapp_template_vm_url}"/>
<VmGeneralParams>
<Name>#{vapp_name}</Name>
<Description>#{vapp_description}</Description>
<NeedsCustomization>true</NeedsCustomization>
</VmGeneralParams>
<InstantiationParams>
<ovf:VirtualHardwareSection
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
xmlns:vmw="http://www.vmware.com/schema/ovf"
xmlns:vcloud="http://www.vmware.com/vcloud/v1.5"
xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
ovf:transport=""
vcloud:href="#{vapp_template_vm_url}/virtualHardwareSection/"
vcloud:type="application/vnd.vmware.vcloud.virtualHardwareSection+xml">
<ovf:Info>Virtual hardware requirements</ovf:Info>
<ovf:Item vcloud:type="application/vnd.vmware.vcloud.rasdItem+xml">
<rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
<rasd:Description>Number of Virtual CPUs</rasd:Description>
<rasd:ElementName>#{vcpu_sockets} virtual CPU(s)</rasd:ElementName>
<rasd:InstanceID>4</rasd:InstanceID>
<rasd:Reservation>0</rasd:Reservation>
<rasd:ResourceType>3</rasd:ResourceType>
<rasd:VirtualQuantity>#{vcpu_sockets}</rasd:VirtualQuantity>
<rasd:Weight>0</rasd:Weight>
<vmw:CoresPerSocket ovf:required="false">#{vcpu_cores_per_socket}</vmw:CoresPerSocket>
</ovf:Item>
<ovf:Item vcloud:type="application/vnd.vmware.vcloud.rasdItem+xml">
<rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
<rasd:Description>Memory Size</rasd:Description>
<rasd:ElementName>#{ram_size} MB of memory</rasd:ElementName>
<rasd:InstanceID>5</rasd:InstanceID>
<rasd:Reservation>0</rasd:Reservation>
<rasd:ResourceType>4</rasd:ResourceType>
<rasd:VirtualQuantity>#{ram_size}</rasd:VirtualQuantity>
<rasd:Weight>0</rasd:Weight>
</ovf:Item>
<ovf:Item>
<rasd:AddressOnParent>0</rasd:AddressOnParent>
<rasd:Description>Hard disk</rasd:Description>
<rasd:ElementName>Hard disk 1</rasd:ElementName>
<rasd:HostResource vcloud:capacity="#{disk_size}" />
<rasd:InstanceID>2000</rasd:InstanceID>
<rasd:ResourceType>17</rasd:ResourceType>
</ovf:Item>
</ovf:VirtualHardwareSection>
</InstantiationParams>
<NetworkAssignment innerNetwork="none" containerNetwork="#{vapp_net_name}" />
<StorageProfile href="#{storage_profile_url}" />
</SourcedItem>
<AllEULAsAccepted>true</AllEULAsAccepted>
</InstantiateVAppTemplateParams>
I hope this is helpful to someone else.
Thanks for posting this. It works for me as well. The example in the documentation also works for me, though it doesn't do exactly the same thing as the sample you posted here. We'll take a closer look at how our example could be improved, sine we really want to documentation to be trustworthy (and correct).