VMware Cloud Community
Subnet88
Enthusiast
Enthusiast

Change ProviderNetwork and vApp Network Setting

I am attemting to change the network settings of all Networks attached to a vApp via a workflow. I have the settings retrieved, and I believe changed. However the Objects are not being updated to reflect the changes. I cannot find the proper .Update methods.  Below is my current code.  The input is of type Array/String with the following format " NetworkName,NewNetworkName,FencedMode,Netmask,Gateway,Suffix,DNS1,DNS2" with one Network per line.

Any assistance on updating the objects would be greatly appreciated.

vApp.updateInternalState()
var vdc = vApp.parent
var Org = vdc.parent
var vcdHost = Org.parent
for (var m in Array){
ArrayLine = Array[m];
CurrentArray = ArrayLine.split(",");  // Split the array into smaller arrays line by line
var NetworkConfig = vApp.getVappNetworkConfigurations()
for ( var i in NetworkConfig) {
System.log("Looking for Network with name"+CurrentArray[0])
if(NetworkConfig[i].networkName == CurrentArray[0]){
System.log("================================================================")
System.log("Found Network with name"+CurrentArray[0])
//Change the network Name
if (NetworkConfig[i].networkName != CurrentArray[1]){
System.log("Changing Network name from "+NetworkConfig[i].networkName+" to "+CurrentArray[1])
NetworkConfig[i].networkName = CurrentArray[1]
}
var Configuration = NetworkConfig[i].Configuration;
var FenceMode = Configuration.fenceMode;
System.log("Network is running in "+FenceMode+" mode ")
// push data about bridged and nat route networks
if (FenceMode == "natRouted" || FenceMode == "bridged") {
//Retrieve Organization Network
var ParentNetwork = Configuration.parentNetwork;
var OrganizationNetwork = vcdHost.getEntityByReference("vcloud:network",ParentNetwork)
//Retrieve External Network
var extNetworkRef = OrganizationNetwork.toAdminObject().configuration.parentNetwork;
var ExtNetwork = OrganizationNetwork.getHost().getEntityByReference(VclFinderType.PROVIDER_NETWORK, extNetworkRef);
ExtNetworkConfiguration = ExtNetwork.configuration
var ipScope = ExtNetworkConfiguration.ipScope
ipScope.dns1 = CurrentArray[8]
ipScope.dns2 = CurrentArray[8]
ipScope.dnsSuffix = CurrentArray[6]
ipScope.gateway = CurrentArray[5]
ipScope.netmask = CurrentArray[4]
ExtNetwork.toAdminExtensionObject().update();
}
//Input data for the Isolated Network
else if (FenceMode == "isolated"){
var ipScope = Configuration.ipScope
ipScope.dns1 = CurrentArray[8]
ipScope.dns2 = CurrentArray[8]
ipScope.dnsSuffix = CurrentArray[6]
ipScope.gateway = CurrentArray[5]
ipScope.netmask = CurrentArray[4]
}
}
}
}
vApp.updateSection(vApp.getNetworkConfigSection());

0 Kudos
8 Replies
cdecanini_
VMware Employee
VMware Employee

Try to set a task output with update section, wait for task and once complete do a vApp.updateInternalState();

Christophe.

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 vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos
Subnet88
Enthusiast
Enthusiast

Update which Section?  "NetworkConfigSection" ?

0 Kudos
cdecanini_
VMware Employee
VMware Employee

Also I do not get what you are updating since you are passing to updateSection an unmodified section you get from the vApp.

Christophe.

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 vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos
cdecanini_
VMware Employee
VMware Employee

The updateSection method returns a task. You are supposed to get the task returned from the method to wait it completes before you can update the object (as most workflows do in the vCloud library).

The second thing is that to modify a section, you need to get it in the variable, modifiy its properties and then pass it back to the updateSection method.

Christophe.

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 vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos
Subnet88
Enthusiast
Enthusiast

The attempt is tho update properties in the ipscope section of a ProviderNetwork and a vApp Isolated Network

I am finding and updating these properties by finding the network via
var NetworkConfig =App.getVappNetworkConfigurations()

Retrieving their Configuration Properties via

var Configuration = NetworkConfig[i].Configuration;

and Finally retrieving the ip Scope(The Container for the properties I am modifying) by running

Configuration.ipScope

There is no updateSection method in any of these 3 Objects.

0 Kudos
cdecanini_
VMware Employee
VMware Employee

I mentioned updateSection() because there is one at the end of the script that is not updating anything since it is passing the current section.

The mechanism I described for updateSection() is similar for the update() method (apart no parameter) : it returns a task and you need to wait this task to complete before running vApp.updateInternalState().

Use the "Add a firewall rule" library workflow as an example.

Christophe.

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 vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos
Subnet88
Enthusiast
Enthusiast

OK. I managed to get the External Network updated via the following code

ExtNetworkConfiguration = ExtNetwork.configuration
var ipScope = new VclIpScope();
ipScope.dns1 = CurrentArray[6]
ipScope.dns2 = CurrentArray[7]
ipScope.dnsSuffix = CurrentArray[5]
ipScope.gateway = CurrentArray[4]
ipScope.netmask = CurrentArray[3]
var AdminExtNetwork = ExtNetwork.toAdminExtensionObject()
AdminExtNetwork.Configuration.ipScope = ipScope;
AdminExtNetwork.update()

Im attempting to find a way to update the Isolated vApp Network now.

0 Kudos
cdecanini_
VMware Employee
VMware Employee

To make it complete you are still missing:

task = AdminExtNetwork.update();

Then add a Wait for task workflow there.

Then a scriptable box with

orgNetwork.updateInternalState();

Christophe.

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 vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos