Unsolved

This post is more than 5 years old

22 Posts

140136

April 16th, 2012 17:00

how to get all ip addresses of a vm

When I look at the data model, I can get the primary ip address of a vm by going to VMware -> Virtual Machines -> VM -> Guest IP -> latest.  However, some VMs have multiple ip addresses, and I wanted to create a dashboard that shows all the IPs of all the VMs in the environment.  How can I achieve that, either through the model or groovy scrip?

Thanks

Frank

59 Posts

May 3rd, 2012 20:00

Here's a groovy script that generates a list of the IP addresses for each host:

hosts = #!Host#.getTopologyObjects()

result = 'Hostname, IP Address(es)\n'

hosts.each { host->

     ips = host.ipAddresses

     if (ips != null) {

       result +=  host.name + ','

       ips.each { result += it.address +  ' '}

       result += '\n'

    }

}

return result

Result:

Hostname, IP Address(es)

...

ausfil03.qsftdemo.local,169.254.71.168 10.80.14.111 10.80.14.49

ausdme01,10.80.14.61

ausbak01bcar.qsftdemo.local,10.80.14.204

ausvra01,10.80.14.175

ausvdi01rmeh.qsftdemo.local,10.80.14.212

ausesx02.qsftdemo.local,

ausvra04,10.80.14.111 10.80.14.80

sydvmm02.qsftdemo.local,10.80.14.228 10.80.14.88

...

Regards,

Brian Wheeldon

Top