VMware Cloud Community
JayhawkEric
Expert
Expert
Jump to solution

Add Organization Network connection to all VM's within vApp

I'm tying to create a workaround for vCD.  When deploying a vApp Template from a published catalog in a different organiztion the organization network does not auto connect to the VM's if the vApp Template had its network settings captured.  This currently happens for us within Lab Manager and does not in vCD.  Also, we must capture the networking as we are using a Fenced/NAT model and this is too complex the have our users setup each time they deploy a configuration.

I'm not sure if this is the proper way to go with this yet but until VMware gets back to us we are going to test this route.

I have a workflow to get all of the VM's within a vApp and am having problems pulling their network settings.  If I can get this I can pull the organizational network for the organization the vApp is currently in and then assign it to each VM. 

I'm not sure how we can use this but I am thinking we'll either do deployments from vCO instead of vCD or use AMQP to listen for new deployments within vCD and then kick off this workflow to fix the vApps.

If you are wondering why we need this we are a large LM shop and the 500 running vApps per organization limit forces us to have more than one organization.

Any help would be appreciated.

Eric

VCP5-DV twitter - @ericblee6 blog - http://vEric.me
0 Kudos
1 Solution

Accepted Solutions
Burke-
VMware Employee
VMware Employee
Jump to solution

To have a VM connect to a network, create a new workflow with a scriptable task in it...

Workflow/Scriptable task Inputs:

nicNumber (Number)

ipMode (String - should be MANUAL, POOL, or DHCP)

newIpAddress (String - only required if ipMode == MANUAL)

network (vCloud:OrgNetwork)

vm (vCloud:VM)

Scriptable Task Output:

task (vCloud:Task)

// Scripting box: (I have a bunch of System.log entries shown below to help with logging/troubleshooting - feel free to comment out each line that starts with System.log)

vm.updateInternalState(); // Update current information...
var networkConnectionSection = vm.getNetworkConnectionSection();
System.log("Info: "+networkConnectionSection.info.msgid+" ("+networkConnectionSection.info.value+")");
System.log("Required: "+networkConnectionSection.required);
System.log("PrimaryNetworkConnectionIndex: "+networkConnectionSection.primaryNetworkConnectionIndex);
var connections = networkConnectionSection.networkConnection;
for each (var connection in connections){
    if (connection.networkConnectionIndex == nicNumber){
        System.log("NIC Match found...");
        System.log("Current IP: "+connection.ipAddress);
        System.log("Current IP Mode: "+connection.ipAddressAllocationMode);
        System.log("Connected: "+connection.isConnected);
        System.log("mac: "+connection.macAddress);
        System.log("Current network: "+connection.network);
        System.log("networkConnectionIndex: "+connection.networkConnectionIndex);
        // Set our changes here, the ipAddress property is only applicable if ipMode is MANUAL
        connection.ipAddressAllocationMode = ipMode;
        if (ipMode == "MANUAL"){
            connection.ipAddress = newIpAddress;
        }
        connection.network = network.name;
        connection.isConnected = true;
    }   
}
// Now apply the changes
var task = vm.updateSection(networkConnectionSection);

// End of Scriptable Task code

Make sure you bind all your variables and it may be a good idea to link the "task" attribute to an action "VclWaitTaskEnd" before proceeding with other operations Smiley Happy

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter

View solution in original post

0 Kudos
5 Replies
JayhawkEric
Expert
Expert
Jump to solution

I found someone doing this via SDK for .NET.  Does anyone know how to translate this to vCO. 

I'm trying to create a new Action from parts of the addVAppNetwork and deleteVAppNetwork actions.  I'm looking at the instantiateVAppTemplate as well.  I understand how to get the info needed but not how to properly apply it to the vApp without blowing up the current vApp Network.

VCP5-DV twitter - @ericblee6 blog - http://vEric.me
0 Kudos
thechaos
Enthusiast
Enthusiast
Jump to solution

Ich bin ab Dienstag den 1.11.2011 wieder zu erreichen. E-Mails werden nicht weitergeleitet.

0 Kudos
jake_robinson_b
Hot Shot
Hot Shot
Jump to solution

I know that you can modify the networks VMs are attached to with the REST API. Worst case scenario, you use the REST plugin to write a custom workflow. I'm sure there is an easier way to do this though. Have you written any custom workflows previously?

Really modifying the network is just doing a PUT to the NetworkConfigSection in the API. No need to re-create the nic.

Jake Robinson VCP, vExpert - geekafterfive.com - Twitter: @jakerobinson
0 Kudos
JayhawkEric
Expert
Expert
Jump to solution

Jake,

I was trying to write a custom workflow but I'm very new to vCO.  I've been working through demo's and such but no luck so far.  Most of my "programming" in the past has all been PowerShell and VB Script.  I've never touched the REST area either.

I found a post on the vCD Community page where a user wanted to know how to do this with the .NET API.  They were seccessful and it seemed like the only thing that needed to change was the "parent" setting for the vApp Network. 

When looking at the "Add vApp Network" and "Remove vApp Network" workflows though it looks like everything is done with a "new" network and applying it over the current one.  If this is the case I think I'd need to retrieve all of the current network settings, create a new network with the proper "parent" network connection, and then apply it.

VCP5-DV twitter - @ericblee6 blog - http://vEric.me
0 Kudos
Burke-
VMware Employee
VMware Employee
Jump to solution

To have a VM connect to a network, create a new workflow with a scriptable task in it...

Workflow/Scriptable task Inputs:

nicNumber (Number)

ipMode (String - should be MANUAL, POOL, or DHCP)

newIpAddress (String - only required if ipMode == MANUAL)

network (vCloud:OrgNetwork)

vm (vCloud:VM)

Scriptable Task Output:

task (vCloud:Task)

// Scripting box: (I have a bunch of System.log entries shown below to help with logging/troubleshooting - feel free to comment out each line that starts with System.log)

vm.updateInternalState(); // Update current information...
var networkConnectionSection = vm.getNetworkConnectionSection();
System.log("Info: "+networkConnectionSection.info.msgid+" ("+networkConnectionSection.info.value+")");
System.log("Required: "+networkConnectionSection.required);
System.log("PrimaryNetworkConnectionIndex: "+networkConnectionSection.primaryNetworkConnectionIndex);
var connections = networkConnectionSection.networkConnection;
for each (var connection in connections){
    if (connection.networkConnectionIndex == nicNumber){
        System.log("NIC Match found...");
        System.log("Current IP: "+connection.ipAddress);
        System.log("Current IP Mode: "+connection.ipAddressAllocationMode);
        System.log("Connected: "+connection.isConnected);
        System.log("mac: "+connection.macAddress);
        System.log("Current network: "+connection.network);
        System.log("networkConnectionIndex: "+connection.networkConnectionIndex);
        // Set our changes here, the ipAddress property is only applicable if ipMode is MANUAL
        connection.ipAddressAllocationMode = ipMode;
        if (ipMode == "MANUAL"){
            connection.ipAddress = newIpAddress;
        }
        connection.network = network.name;
        connection.isConnected = true;
    }   
}
// Now apply the changes
var task = vm.updateSection(networkConnectionSection);

// End of Scriptable Task code

Make sure you bind all your variables and it may be a good idea to link the "task" attribute to an action "VclWaitTaskEnd" before proceeding with other operations Smiley Happy

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos