WJCon
Enthusiast
Enthusiast

Cloud Director Plugin - Can't Get IP Address on DHCP VMs in a vAPP - Even though they Display in UI

I am trying to write a scriptable task that will pull the IP address back for VM's - this works fine for most VM's where in Cloud Director the IP is allocated either through IP Pool or Static - but if the VM gets its IP through DHCP the return is null.
 
Basically issue is networkConnection.ipAddress seems to be null if IP Mode is set to DHCP (In the UI and the actual VM i can see the IP address allocated correctly
 
If IP Mode is Static - Manual or Static - IP Pool the networkConnection.ipAddress displays fine
 
 
System.log("=================================================="); 
var vms = System.getModule("com.vmware.library.vCloud.vApp").getVmsFromVApp(vapp); 
    for each (var vm in vms){
        if (vm.Name == 'KnownDHCPVM'){  
System.log ('Found DHCP VM');
var networkConnectionSection = System.getModule("com.vmware.library.vCloud.operation").getNetworkConnectionSectionVM(vm);    
var networkConnections = networkConnectionSection.networkConnection.enumerate();
var i = 0;
for each (networkConnection in networkConnections){
System.log(networkConnection.ipAddressAllocationMode + ' ' + i + ' ' + networkConnection.network+ i + ' ' + networkConnection.ipAddress)
if (networkConnection.ipAddressAllocationMode == 'DHCP'){;
System.log('DHCP Nic Found  - Nic Slot:'+ i)
var dhcpip = networkConnection.ipAddress
System.log('IP: '+dhcpip) 
}
i++;
}
}
}
0 Kudos
0 Replies