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.parentvar Org = vdc.parentvar vcdHost = Org.parentfor (var m in Array){ArrayLine = Array[m];CurrentArray = ArrayLine.split(","); // Split the array into smaller arrays line by linevar 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 Nameif (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 networksif (FenceMode == "natRouted" || FenceMode == "bridged") {//Retrieve Organization Networkvar ParentNetwork = Configuration.parentNetwork;var OrganizationNetwork = vcdHost.getEntityByReference("vcloud:network",ParentNetwork)//Retrieve External Networkvar extNetworkRef = OrganizationNetwork.toAdminObject().configuration.parentNetwork;var ExtNetwork = OrganizationNetwork.getHost().getEntityByReference(VclFinderType.PROVIDER_NETWORK, extNetworkRef);ExtNetworkConfiguration = ExtNetwork.configurationvar ipScope = ExtNetworkConfiguration.ipScopeipScope.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 Networkelse if (FenceMode == "isolated"){var ipScope = Configuration.ipScopeipScope.dns1 = CurrentArray[8]ipScope.dns2 = CurrentArray[8]ipScope.dnsSuffix = CurrentArray[6]ipScope.gateway = CurrentArray[5]ipScope.netmask = CurrentArray[4]}}}}vApp.updateSection(vApp.getNetworkConfigSection());
Try to set a task output with update section, wait for task and once complete do a vApp.updateInternalState();
Christophe.
Update which Section? "NetworkConfigSection" ?
Also I do not get what you are updating since you are passing to updateSection an unmodified section you get from the vApp.
Christophe.
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.
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.
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.
OK. I managed to get the External Network updated via the following code
ExtNetworkConfiguration = ExtNetwork.configurationvar 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.
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.