VMware Cloud Community
YueZhao
Contributor
Contributor

connect vApp network to an organization vDC network using JAVA SDK

Hello all,

I am a newbie here and working on automating the following procedures using vcloud java SDK5.1:
1. create vApps from the template -> modify the code ComposevApp.java.
2. deploy/undepoly the vApp
3. add VMs into the vAPPs. -> modify the code RecomposevApp.java

4. delete VMs and vApps

All of these work well but I cannot set the network correctly. What I want is to create a vAPP network and connect it to an organization vDC network and set routing as NAT. In this way I could get the external IP for each single VMs and access them. I have searched the related information for several days but nothing really helps. What my code could do is just create a direct fenced network in the vApp. The org vDC I want to connect is Internal_Routed_Network.

        networkConfiguration.setParentNetwork(vdc.getAvailableNetworkRefByName("Internal_Routed_Network"));

        networkConfiguration.setFenceMode(FenceModeValuesType.NATROUTED.value());

        VAppNetworkConfigurationType vAppNetworkConfigurationType = new VAppNetworkConfigurationType();

        vAppNetworkConfigurationType.setConfiguration(networkConfiguration);

        vAppNetworkConfigurationType.setNetworkName( networkName );

        NetworkConfigSectionType networkConfigSectionType = new NetworkConfigSectionType();

        MsgType networkInfo = new MsgType();

        networkConfigSectionType.setInfo(networkInfo);

        List<VAppNetworkConfigurationType> vAppNetworkConfigs = networkConfigSectionType .getNetworkConfig();

        vAppNetworkConfigs.add(vAppNetworkConfigurationType);

        InstantiationParamsType vappOrvAppTemplateInstantiationParamsType = new InstantiationParamsType();

        List<JAXBElement<? extends SectionType>> vappSections = vappOrvAppTemplateInstantiationParamsType.getSection();


        vappSections.add(new ObjectFactory()  .createNetworkConfigSection(networkConfigSectionType));

        //

        // create the request body (InstantiateVAppTemplateParams)

        //

        ComposeVAppParamsType instVappTemplParams = new ComposeVAppParamsType();

        instVappTemplParams.setName( vAppName );

        instVappTemplParams.setDeploy(false);

        //instVappTemplParams.setSource(vAppTemplateReference);

        instVappTemplParams.setInstantiationParams(vappOrvAppTemplateInstantiationParamsType);

        Vapp vapp = vdc.composeVapp(instVappTemplParams);

        return vapp;


Thanks for any input.


Yue

Reply
0 Kudos
1 Reply
koustubhw
Contributor
Contributor

I am facing the same issue. unfortunately nobody answered.

Reply
0 Kudos