VMware {code} Community
sqeezer
Contributor
Contributor
Jump to solution

VM network connection while recomposing from template

Hi,

I was trying to recompose vApp with VM template and passing existing network as InstantiationParamsType as it is in RecomposevApp.java but couldn't get any success.

This is the code, which is exactly the same as in RecomposevApp.java except POOL is used:

            NetworkConnectionSectionType networkConnectionSectionType = new NetworkConnectionSectionType();
            MsgType networkInfo = new MsgType();
            networkConnectionSectionType.setInfo(networkInfo);

            NetworkConnectionType networkConnectionType = new NetworkConnectionType();
            networkConnectionType.setNetwork(vappNetworkName);
            networkConnectionType.setIsConnected(true);
            networkConnectionType
                    .setIpAddressAllocationMode(IpAddressAllocationModeType.POOL);
            networkConnectionSectionType.getNetworkConnection().add(
                    networkConnectionType);

            InstantiationParamsType vmInstantiationParamsType = new InstantiationParamsType();
            List<JAXBElement<? extends SectionType>> vmSections = vmInstantiationParamsType
                    .getSection();
            vmSections
                    .add(new ObjectFactory()
                            .createNetworkConnectionSection(networkConnectionSectionType));
            vmItem.setInstantiationParams(vmInstantiationParamsType);

But when I call vapp.recomposeVapp I'm getting " minorErrorCode="BAD_REQUEST" message="The parameter is not supported in the current context: InstantiationParamsType" majorErrorCode="400" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://vrp-vcloudd-http.cisco.com/api/v1.0/schema/master.xsd"></Error>

If I create VM from template using vCloud Director Web I see dropdown box with networks (Configure Virtual Machines tab) where I can choose the needed one. But how to do the same using vCloud API?

Thank you in advance,

0 Kudos
1 Solution

Accepted Solutions
rkamal
VMware Employee
VMware Employee
Jump to solution

Hi,

1. InstantiationParams contained by an Item element that specifies a Vm as its Source can contain the following section types:
        VirtualHardwareSection
        OperatingSystemSection
        NetworkConnectionSection
        GuestCustomizationSection
2. InstantiationParams contained by any other element apply to a vApp and can contain the following section types:

        LeaseSettingsSection
        StartupSection
        NetworkConfigSection
        CustomizationSection

vCloud API Programming Guide 1.0

        http://communities.vmware.com/docs/DOC-12463 Pg.No-172,173

In your case, your source is vappTemplate and you are trying to pass in a NetworkConnectionSection. This contradicts 1.

So, if you point your source to the vappTemplate's VM and then try passing the NetworkConnectionSection.

Something like this,

        <Source href="https://host/api/v1.0/vAppTemplate/vm-iddd"/>

Regards,

Rajesh Kamal.

View solution in original post

0 Kudos
3 Replies
rkamal
VMware Employee
VMware Employee
Jump to solution

Can you share the XML/Payload which you are trying to send for the recompose operation.

Regards,

Rajesh Kamal.

0 Kudos
sqeezer
Contributor
Contributor
Jump to solution

Hi Rajesh,

This is xml generated by vCloud Java API:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RecomposeVAppParams xmlns="http://www.vmware.com/vcloud/v1" xmlns:ns2="http://schemas.dmtf.org/ovf/envelope/1" xmlns:ns3="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:ns4="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:ns5="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:ns6="http://www.vmware.com/vcloud/versions" xmlns:ns7="http://www.vmware.com/vcloud/extension/v1" name="vApp_MyVapp">
    <Item>
        <Source href="https://host/api/v1.0/vAppTemplate/vappTemplate-671427474"/>
        <InstantiationParams>
            <NetworkConnectionSection>
                <ns2:Info/>
                <NetworkConnection network="My Network">
                    <NetworkConnectionIndex>0</NetworkConnectionIndex>
                    <IsConnected>true</IsConnected>
                    <IpAddressAllocationMode>POOL</IpAddressAllocationMode>
                </NetworkConnection>
            </NetworkConnectionSection>
        </InstantiationParams>
    </Item>
</RecomposeVAppParams>

'vApp_MyVapp' is vApp to which I trying to add VM from template.

'My Network' is network which has a set of IPs. If I create VM from web I can choose this network in dropdown box (initially 'none' is shown there).

Thanks,

0 Kudos
rkamal
VMware Employee
VMware Employee
Jump to solution

Hi,

1. InstantiationParams contained by an Item element that specifies a Vm as its Source can contain the following section types:
        VirtualHardwareSection
        OperatingSystemSection
        NetworkConnectionSection
        GuestCustomizationSection
2. InstantiationParams contained by any other element apply to a vApp and can contain the following section types:

        LeaseSettingsSection
        StartupSection
        NetworkConfigSection
        CustomizationSection

vCloud API Programming Guide 1.0

        http://communities.vmware.com/docs/DOC-12463 Pg.No-172,173

In your case, your source is vappTemplate and you are trying to pass in a NetworkConnectionSection. This contradicts 1.

So, if you point your source to the vappTemplate's VM and then try passing the NetworkConnectionSection.

Something like this,

        <Source href="https://host/api/v1.0/vAppTemplate/vm-iddd"/>

Regards,

Rajesh Kamal.

0 Kudos