VMware {code} Community
JerryCW
Contributor
Contributor

How to retrieve ESX IP address from Vcenter


Hi all


Is there a way can retrieve ESX IP address directly from SDK? We can get it by resolve hostname (dnsconfig.hostname), but it may fail sometime.


I also find +host.config.network.pnic.spec.ip +but its description says  The IP configuration on the physical network adapter (applies only to a hosted network adapter). The data object will be NULL on an ESX Server system.   


So, would this ip be possible to get from vcenter directly?


thanks


Jerry   
 

0 Kudos
2 Replies
stumpr
Virtuoso
Virtuoso

Yes, you can get that information from the networkSystem:

thisHost.configManager.networkSystem.networkInfo.vnic[]

That array will have an entry for each vmkernel interface (vmk0, vmk1, etc). 

You'll have to enumerate it and check the spec property to get the ip information.

If you need to know which functions each vmk interface has, you'll have to look at the virtualNicManager object.

Reuben Stump | http://www.virtuin.com | @ReubenStump
0 Kudos
JerryCW
Contributor
Contributor

hi

what is the difference between configManager.networkSystem.networkInfo.vnic and config.network.vnic

I tested both on my system, but get empty list

0 Kudos