This (How to find management IP(s) of ESXi host from VcHostSystem (vRO 7.3 and vSphere 6.0) ) is being re-posted here.
I am trying to find the ESXi host to which a virtual machine is registered. From the vm I am able to find the host (VcHostSystem) in vRO. Searching the API it would appear that I need HostVirtualNicManagerNicType (http://pubs.vmware.com/vsphere-6-0/topic/com.vmware.wssdk.apiref.doc/vim.host.VirtualNicManager.NicType.html). The code below allows me to iterate over the virtual NICs and includes IP address information but I haven't figured out how to definitively determine which interface(s), and therefore which IP(s), are designated for ESXi management.
var EsxiHostConfigNetworkdVnic = vm.runtime.host.config.network.vnic System.log( "EsxiHostConfigNetworkdVnic.length = " + EsxiHostConfigNetworkdVnic.length ) for( var VnicIndex = 0 , VnicLength = EsxiHostConfigNetworkdVnic.length ; VnicIndex < VnicLength ; VnicIndex++ ){ System.log( "EsxiHostConfigNetworkdVnic[" + VnicIndex + "] = " + EsxiHostConfigNetworkdVnic[ VnicIndex ] ) }
Thanks in advance.