VMware {code} Community
anniyan
Contributor
Contributor

How to get the IP address of a VM?

I am trying to get the IP address of a VM I created but the vCloud API returns nothing

for DHCP address even if VMWare tools are installed and are current. When I enable

static IP address, I do get the IP address but it is stale - looks like IP address was

cached and returned even though the VM got a new static IP. Is this a bug in vCloud

API? I checked this in both vCloud Director and vCloud Express - same result.

DHCP IP address - nothing returned
Static IP address - bogus IP returned sometimes

Any idea how to get the VM (DHCP) IP address reliably?

GET https://<IP>/api/v1.0/vApp/vm-id

For static IP:
    <NetworkConnection Network=....>
      <IpAddress>192.168.1.23</IpAddress>
    </NetworkConnection>


For dynamic IP:
     <NetworkConnection Network=....>
    </NetworkConnection>

Thanks

1 Reply
geoffaviarc
Contributor
Contributor

I had this same problem.  vCenter can see the DHCP address but vCloud director cannot.  this API/product is far from complete.

You should be able to get away without using DHCP.   give your network a range of addresses and then have the address of the vm in the vapp template assigned via "POOL". (IpAddressAllocationMode for the vApps NetworkConnection)

use guest customisation to have the address setup on first boot.

when the VM is thrown away the IP goes back to the pool...

it performs like dhcp but the machine gets a address until its thrown away.

I've tested it on redhat and windows.  appears to work well.