[libvirt-users] Guest interface info under ESX driver

Hi, Is there a way to fetch the current IP address of a running guest domain (with VMware Tools installed) running on an ESX host? Ideally this would be doable via the libvirt Python bindings. Thank you. -- sengork

On 30/01/2011, at 11:19 PM, Sengor wrote:
Hi,
Is there a way to fetch the current IP address of a running guest domain (with VMware Tools installed) running on an ESX host?
Ideally this would be doable via the libvirt Python bindings.
Hi Sengor, Does this help? https://rwmj.wordpress.com/2010/10/26/tip-find-the-ip-address-of-a-virtual-m... I'm unsure about it's interaction with vSphere/ESX though. Regards and best wishes, Justin Clift

Hi Justin, Thanks. I did come across that post, but was hoping there'd be a more contained method of finding the domain's IP address without needing to do ARP/MAC lookups or query the DHCP server itself. The following does not display the IP either for an ESX guest 'testvm': virsh # dumpxml testvm ... <interface type='bridge'> <mac address='00:0c:29:09:ab:2c'/> <source bridge='VM Network'/> </interface> ... Looking around the libvirt Python bindings reveals class virInterface from lib/site-packages/libvirt.py with the following function: def XMLDesc(self, flags): """VIR_INTERFACE_XML_INACTIVE - return the static configuration, suitable for use redefining the interface via virInterfaceDefineXML() Provide an XML description of the interface. If VIR_INTERFACE_XML_INACTIVE is set, the description may be reused later to redefine the interface with virInterfaceDefineXML(). If it is not set, the ip address and netmask will be the current live setting of the interface, not the settings from the config files. """ ret = libvirtmod.virInterfaceGetXMLDesc(self._o, flags) if ret is None: raise libvirtError ('virInterfaceGetXMLDesc() failed', net=self) return ret This looks promising (if it indeed does work for ESX driver), however I've not figured out how to use this particular class/function yet. So far unable to find any examples on the web... Lastly I cannot tell whether this is supported at all for the ESX driver given the current driver support matrix: http://www.libvirt.org/hvsupport.html Any help is appreciated. On Mon, Jan 31, 2011 at 4:22 PM, Justin Clift <jclift@redhat.com> wrote:
On 30/01/2011, at 11:19 PM, Sengor wrote:
Hi,
Is there a way to fetch the current IP address of a running guest domain (with VMware Tools installed) running on an ESX host?
Ideally this would be doable via the libvirt Python bindings.
Hi Sengor,
Does this help?
https://rwmj.wordpress.com/2010/10/26/tip-find-the-ip-address-of-a-virtual-m...
I'm unsure about it's interaction with vSphere/ESX though.
Regards and best wishes,
Justin Clift
-- sengork

2011/1/31 Sengor <sengork@gmail.com>:
Hi Justin,
Thanks. I did come across that post, but was hoping there'd be a more contained method of finding the domain's IP address without needing to do ARP/MAC lookups or query the DHCP server itself.
Currently libvirt doesn't provide a function to get the IP address of a domain's network interface. Might be a useful addition as libvirt can know/determine the IP address in several cases.
The following does not display the IP either for an ESX guest 'testvm': virsh # dumpxml testvm ... <interface type='bridge'> <mac address='00:0c:29:09:ab:2c'/> <source bridge='VM Network'/> </interface> ...
The domain XML doesn't contain the IP address (yet). With VMware tools installed in the guest it might be possible to obtain the IP address via the vSphere API, I didn't test this yet. But libvirt doesn't have a function to expose this information yet.
Looking around the libvirt Python bindings reveals class virInterface from lib/site-packages/libvirt.py with the following function: def XMLDesc(self, flags): """VIR_INTERFACE_XML_INACTIVE - return the static configuration, suitable for use redefining the interface via virInterfaceDefineXML()
Provide an XML description of the interface. If VIR_INTERFACE_XML_INACTIVE is set, the description may be reused later to redefine the interface with virInterfaceDefineXML(). If it is not set, the ip address and netmask will be the current live setting of the interface, not the settings from the config files. """ ret = libvirtmod.virInterfaceGetXMLDesc(self._o, flags) if ret is None: raise libvirtError ('virInterfaceGetXMLDesc() failed', net=self) return ret
This looks promising (if it indeed does work for ESX driver), however I've not figured out how to use this particular class/function yet. So far unable to find any examples on the web...
virInterface is for the host network interfaces, this is not what you're looking for.
Lastly I cannot tell whether this is supported at all for the ESX driver given the current driver support matrix: http://www.libvirt.org/hvsupport.html
This matrix is quite outdated, and needs to be updated :( Matthias
On Mon, Jan 31, 2011 at 4:22 PM, Justin Clift <jclift@redhat.com> wrote:
On 30/01/2011, at 11:19 PM, Sengor wrote:
Hi,
Is there a way to fetch the current IP address of a running guest domain (with VMware Tools installed) running on an ESX host?
Ideally this would be doable via the libvirt Python bindings.
Hi Sengor,
Does this help?
https://rwmj.wordpress.com/2010/10/26/tip-find-the-ip-address-of-a-virtual-m...
I'm unsure about it's interaction with vSphere/ESX though.
Regards and best wishes,
Justin Clift
-- sengork
_______________________________________________ libvirt-users mailing list libvirt-users@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-users

Thanks for the speedy replies guys, much appreciated. On Tue, Feb 1, 2011 at 12:45 AM, Matthias Bolte <matthias.bolte@googlemail.com> wrote:
Currently libvirt doesn't provide a function to get the IP address of a domain's network interface.
Might be a useful addition as libvirt can know/determine the IP address in several cases.
It'd be an useful addon to libvirt, as at the moment there are not many mature Python interface libraries for ESX.
The domain XML doesn't contain the IP address (yet).
With VMware tools installed in the guest it might be possible to obtain the IP address via the vSphere API, I didn't test this yet.
Yes VMware Tools need to be deployed within the guest OS for the IP to be visible even to ESX itself. I think I'll resort to using ESX's own API interface to query this piece of info (possibly via pywbem). An example of such use is available @ http://www.linuxdynasty.org/howto-list-virtual-machines-using-python-and-cim... Regardless will keep using libvirt for the remainder of functionality I'm after.
But libvirt doesn't have a function to expose this information yet.
virInterface is for the host network interfaces, this is not what you're looking for.
This matrix is quite outdated, and needs to be updated :(
Matthias
-- sengork
participants (3)
-
Justin Clift
-
Matthias Bolte
-
Sengor