Hi,
I am trying to retreive the IP from a NIC from a vcloud:VM type. After deploying the VM I want to be able to send a confirmation email detailing certain information, with the IP being one.I have searched through the actions and tried multiple different ones and I can't seem to get the information I am looking for. I am currently using the below script to try but receive this error "TypeError: Cannot read property "ipAddress" from null (Dynamic Script Module Name : getVMIp#4)
Script:
I wrote this script but it seems to be the one for vCloud 1.0
Try this one:
vm.updateInternalState();
var networkConnectionSection = vm.getNetworkConnectionSection();
//System.log("IP is: " + networkConnectionSection.networkConnection.enumerate()[0].ipAddress);
return networkConnectionSection.networkConnection.enumerate()[0].ipAddress;
In vCloud 1.0 an array was returned, in vCloud 1.5 an object which is a list of objects requiring using the enumerate() method.
In both scripts I am assuming the IP is in the first network connection.
If this still does not work you can add:
System.log(networkConnectionSection.toXml());
Then you can then copy paste in an XML editor to check this VM network configuration and where the IP is located.
Christophe.
I wrote this script but it seems to be the one for vCloud 1.0
Try this one:
vm.updateInternalState();
var networkConnectionSection = vm.getNetworkConnectionSection();
//System.log("IP is: " + networkConnectionSection.networkConnection.enumerate()[0].ipAddress);
return networkConnectionSection.networkConnection.enumerate()[0].ipAddress;
In vCloud 1.0 an array was returned, in vCloud 1.5 an object which is a list of objects requiring using the enumerate() method.
In both scripts I am assuming the IP is in the first network connection.
If this still does not work you can add:
System.log(networkConnectionSection.toXml());
Then you can then copy paste in an XML editor to check this VM network configuration and where the IP is located.
Christophe.
Thank you for the help. This worked and I am now able to see the IP in the variable. I have run into another small problem regarding the same issue however. I want to store the IP into array/string. My setup is:
Your script action:
Out variable = actionResultIP (This receives the correct IP)
My Scriptable task:
var i = IPCounter;
ipAddressArray[i] = actionResultIP;
Any idea why I can't pass the actionResultIP variable into the array? I have also tried to just pass the string variable(actionResultIP) to another string variable (not an array) and this did not work either.
Thanks again for you help!
I am not sure how you created your array. I would write it this way:
var ipAddressArray = new Array();
ipAddressArray.push(actionResultIP);
Christophe.
THank you, that solved my problem!