Hey guys,
I'm stuck with the situation where I'm not able to connect vApp network to VM's nic at the step of vApp instantiation from a template.
I've read this docs VMware vCloud Director 5.6 Documentation Center and tried using the construction:
<?xml version="1.0" encoding="UTF-8"?>
<InstantiateVAppTemplateParams
xmlns="http://www.vmware.com/vcloud/v1.5"
name="111"
deploy="true"
powerOn="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1">
<Description>vApp with the new network</Description>
<InstantiationParams>
<NetworkConfigSection>
<ovf:Info>Configuration parameters for logical networks</ovf:Info>
<NetworkConfig networkName="net1>
<Configuration>
<ParentNetwork href="https://example.com/api/network/e4627307-8ab9-46c3-8ae9-b6f31158f665" />
<FenceMode>bridged</FenceMode>
</Configuration>
</NetworkConfig>
</NetworkConfigSection>
</InstantiationParams>
<Source href="https://example.com/api/vAppTemplate/vappTemplate-db2d4ba6-7f36-44be-a2de-50ddff8a3985" />
<SourcedItem>
<Source href="https://example.com/api/vAppTemplate/vm-28bfdffa-a75e-4921-9de1-6a3c4fdb8af6"/>
<VmGeneralParams>
<Name>111VM</Name>
<Description>VM with the new network</Description>
<NeedsCustomization>true</NeedsCustomization>
</VmGeneralParams>
<InstantiationParams>
<NetworkConnectionSection
type="application/vnd.vmware.vcloud.networkConnectionSection+xml"
xmlns="http://www.vmware.com/vcloud/v1.5"
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1">
<ovf:Info>Firewall allows access to this address.</ovf:Info>
<PrimaryNetworkConnectionIndex>0</PrimaryNetworkConnectionIndex>
<NetworkConnection network="net1">
<NetworkConnectionIndex>0</NetworkConnectionIndex>
<IsConnected>true</IsConnected>
<MACAddress>00:50:56:01:01:49</MACAddress>
<IpAddressAllocationMode>POOL</IpAddressAllocationMode>
</NetworkConnection>
</NetworkConnectionSection>
</InstantiationParams>
</SourcedItem>
<AllEULAsAccepted>true</AllEULAsAccepted>
</InstantiateVAppTemplateParams>
But vCloud Director 5.6 responds with the 400 error:
Unsupported instantiation section: {http://www.vmware.com/vcloud/v1.5}NetworkConnectionSection
However VMware docs says that InstantiationParamsType does have such a section "NetworkConnectionSection".
It's also possible in existing vCD UI wizard to instantiate vApp from a template and to connect its network to a children VM's nic.
Furthermore, when I try using the same xml syntax for recomposeVApp/reconfigureVM actions the vCD accepts it as valid and connects the network to the VM.
So is it possible with API to connect a vApp network to a VM's nic at the instantiation step or do I have to do that after the instantiation of the vApp is finished?
Thanks!
This is what I did for similar use case.
Added the required network to an existing vApp.
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="Org1-net">
<Configuration>
<ParentNetwork
href="https://192.168.9.23/api/admin/network/698fff30-b753-4373-a315-17cd9152b10a" />
<FenceMode>Bridged</FenceMode>
</Configuration>
</NetworkConfig>
</NetworkConfigSection>
</InstantiationParams>
<AllEULAsAccepted>true</AllEULAsAccepted>
</RecomposeVAppParams>
Once the network is added to the vApp add the template VM in the vApp connect it to the desired network
Content type: application/vnd.vmware.vcloud.recomposeVAppParams+xml
<?xml version="1.0" encoding="UTF-8"?>
<RecomposeVAppParams xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1">
<SourcedItem sourceDelete="false">
<Source href="https://192.168.9.23/api/vAppTemplate/vm-6bf05d97-e720-46f4-8141-78514b07f62e" name="new-vm"/>
<InstantiationParams>
<NetworkConnectionSection>
<ovf:Info/>
<PrimaryNetworkConnectionIndex>0</PrimaryNetworkConnectionIndex>
<NetworkConnection network="Org1-net">
<NetworkConnectionIndex>0</NetworkConnectionIndex>
<IsConnected>true</IsConnected>
<IpAddressAllocationMode>POOL</IpAddressAllocationMode>
</NetworkConnection>
</NetworkConnectionSection>
<GuestCustomizationSection>
<ovf:Info/>
<Enabled>true</Enabled>
<ChangeSid>false</ChangeSid>
<AdminPasswordEnabled>false</AdminPasswordEnabled>
<ComputerName>win12</ComputerName>
</GuestCustomizationSection>
</InstantiationParams>
</SourcedItem>
<AllEULAsAccepted>true</AllEULAsAccepted>
<CreateItem name="NIC Test VM"/>
</RecomposeVAppParams>
Hi kkeshri,
Thanks for your reply!
I can confirm that it will work for an existing vApp. However our task is to add and assign a network to a new vApp being provisioned from a vApp Template. In your case you are using "RecomposeVAppParams", and we are trying to do that with one single API call using "InstantiateVAppTemplateParams". Seems like its impossible though...
Hi... I looked up vCloud REST API - InstantiationParamsType in the VMware docs and it does include a NetworkConnectionSection. Where were you seeing that this element is not part of InstantiationParams?
Where have you seen that I said that NetworkConnectionSection is not a part of InstantiationParams? I'm afraid you read inattentively, cause actually I said the opposite. But it doesn't work, when I add this section to the xml, vCD throws me the validation error saying that this section isn't supported. That's actually the issue.