<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 9.00.8112.16421"><LINK rel=stylesheet
href="BLOCKQUOTE{margin-Top: 0px; margin-Bottom: 0px; margin-Left: 2em}"></HEAD>
<BODY style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt">
<DIV><FONT size=2><FONT color=#c0c0c0
size=2><SPAN></SPAN></FONT></FONT> </DIV>
<DIV><FONT size=2><FONT color=#c0c0c0
size=2><SPAN>HI,all:</SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT color=#c0c0c0
size=2><SPAN> </SPAN></FONT></FONT></DIV>
<DIV style="TEXT-INDENT: 2em"><FONT size=2><FONT color=#c0c0c0 size=2><SPAN>I'm
new to libvirt, and have some questions about How to get the IP address of a
Domain?</SPAN></FONT></FONT></DIV>
<DIV style="TEXT-INDENT: 2em"><FONT size=2><FONT color=#c0c0c0
size=2><SPAN></SPAN></FONT></FONT> </DIV>
<DIV style="TEXT-INDENT: 2em"><FONT size=2><FONT color=#c0c0c0 size=2><SPAN>I
searched the old mails int the mail-list ,found one way to do this,it is
first get the mac address of the Domain,then used some
</SPAN></FONT></FONT><FONT size=2><FONT color=#c0c0c0 size=2><SPAN>sniffer or
arp tools to fetch the IP address , but:</SPAN></FONT></FONT></DIV>
<DIV style="TEXT-INDENT: 2em"><FONT size=2><FONT color=#c0c0c0
size=2><SPAN></SPAN></FONT></FONT> </DIV>
<DIV style="TEXT-INDENT: 2em"><FONT size=2><FONT color=#c0c0c0 size=2><SPAN>Q1:
Is there any APIs of libvirt to get the domain's IP address directly? If does
not exist now , have any plan to add this api or some extra tools to do this
,just like the vm-tools on </SPAN></FONT></FONT></DIV>
<DIV style="TEXT-INDENT: 4em"><FONT size=2><FONT color=#c0c0c0
size=2><SPAN></SPAN></FONT></FONT> </DIV>
<DIV style="TEXT-INDENT: 4em"><FONT size=2><FONT color=#c0c0c0
size=2><SPAN>VMware ESX?</SPAN></FONT></FONT></DIV>
<DIV style="TEXT-INDENT: 4em"><FONT size=2><FONT color=#c0c0c0
size=2><SPAN></SPAN></FONT></FONT> </DIV>
<DIV style="TEXT-INDENT: 2em"><FONT size=2><FONT color=#c0c0c0 size=2><SPAN>Q2:
How to get the domain's mac? I download the virt-manager src, searching it's
source to find how to do this : </SPAN></FONT></FONT></DIV>
<DIV style="TEXT-INDENT: 2em"><FONT size=2><FONT color=#c0c0c0
size=2><SPAN> </SPAN></FONT></FONT></DIV>
<DIV style="TEXT-INDENT: 2em"><FONT size=2><FONT color=#c0c0c0
size=2><SPAN> in details.py , this line seems to
get the mac address:</SPAN></FONT></FONT></DIV>
<DIV style="TEXT-INDENT: 2em"><FONT size=2><FONT color=#c0c0c0
size=2><SPAN></SPAN></FONT></FONT> </DIV>
<DIV style="TEXT-INDENT: 4em"><FONT size=2><FONT color=#c0c0c0
size=2><SPAN> in function
<STRONG>update_hwlist(hwtype, info, name, icon_name)</STRONG>:
Line 2475</SPAN></FONT></FONT></DIV>
<DIV style="TEXT-INDENT: 4em"><FONT size=2><FONT color=#c0c0c0
size=2><SPAN></SPAN></FONT></FONT> </DIV>
<DIV style="TEXT-INDENT: 6em"><FONT size=2><FONT color=#c0c0c0 size=2><SPAN>
<DIV><STRONG><FONT
size=3>for net in self.vm.get_network_devices():</FONT></STRONG></DIV>
<DIV><STRONG><FONT
size=3> mac = net.macaddr</FONT></STRONG></DIV>
<DIV><STRONG><FONT size=3></FONT></STRONG></DIV>
<DIV><STRONG><FONT
size=3> update_hwlist(HW_LIST_TYPE_NIC, net,</FONT></STRONG></DIV>
<DIV><STRONG><FONT
size=3> "NIC %s" % mac[-9:], "network-idle")</FONT></STRONG></DIV></SPAN></FONT></FONT></DIV>
<DIV style="TEXT-INDENT: 6em"><FONT size=2><FONT color=#c0c0c0
size=2><SPAN></SPAN></FONT></FONT> </DIV>
<DIV style="TEXT-INDENT: 4em"><FONT size=2><FONT color=#c0c0c0 size=2><SPAN>then
,I looked into domains.py, in function
<STRONG>get_network_devices():</STRONG></SPAN></FONT></FONT></DIV>
<DIV style="TEXT-INDENT: 2em"><FONT size=2><FONT color=#c0c0c0
size=2><SPAN></SPAN></FONT></FONT> </DIV>
<DIV style="TEXT-INDENT: 6em"><FONT color=#c0c0c0
size=3><SPAN><STRONG>def get_network_devices(self, refresh_if_necc=True):</STRONG></SPAN></FONT></DIV>
<DIV style="TEXT-INDENT: 10em"><FONT color=#c0c0c0
size=3><SPAN><STRONG>return self._build_device_list("interface", refresh_if_necc)</STRONG></SPAN></FONT></DIV>
<DIV style="TEXT-INDENT: 4em"><FONT size=2><FONT color=#c0c0c0
size=2><SPAN></SPAN></FONT></FONT> </DIV>
<DIV style="TEXT-INDENT: 4em"><FONT size=2><FONT color=#c0c0c0
size=2><SPAN>next, go to function<STRONG>
_build_device_list()</STRONG></DIV>
<DIV style="TEXT-INDENT: 6em">
<DIV>
<DIV><STRONG> <FONT
size=3>def _build_device_list(self, device_type,</FONT></STRONG></DIV>
<DIV><STRONG><FONT
size=3> refresh_if_necc=True, inactive=False):</FONT></STRONG></DIV>
<DIV><STRONG><FONT
size=3> guest = self._get_guest(refresh_if_necc=refresh_if_necc,</FONT></STRONG></DIV>
<DIV><STRONG><FONT
size=3> inactive=inactive)</FONT></STRONG></DIV>
<DIV><STRONG><FONT
size=3> devs = guest.get_devices(device_type)</FONT></STRONG></DIV>
<DIV><STRONG><FONT size=3></FONT></STRONG></DIV>
<DIV><STRONG><FONT
size=3> count = 0</FONT></STRONG></DIV>
<DIV><STRONG><FONT
size=3> for dev in devs:</FONT></STRONG></DIV>
<DIV><STRONG><FONT
size=3> dev.vmmindex = count</FONT></STRONG></DIV>
<DIV><STRONG><FONT
size=3> count += 1</FONT></STRONG></DIV>
<DIV style="TEXT-INDENT: 2em"><STRONG><FONT
size=3> return devs</FONT></STRONG></DIV>
<DIV style="TEXT-INDENT: 2em"> </DIV>
<DIV style="TEXT-INDENT: 4em">finally ,in funciton <STRONG>
_get_guest(self, inactive=False, refresh_if_necc=True)</STRONG>
<DIV style="TEXT-INDENT: 6em"><STRONG><FONT
size=3>def _get_guest(self, inactive=False, refresh_if_necc=True):</FONT></STRONG></DIV>
<DIV><STRONG><FONT
size=3> raise NotImplementedError()</FONT></STRONG></DIV></DIV>
<DIV> </DIV>
<DIV>this puzzled me , only raise a exception NotImplentedError(),but not deal
with it .</DIV>
<DIV> </DIV>
<DIV>How to get the mac address?</DIV>
<DIV> </DIV>
<DIV>Sorry ,I 'm new to Python either... </DIV>
<DIV> </DIV></DIV>
<DIV style="TEXT-INDENT: 2em">Really appreciate for your help!</DIV>
<DIV> </DIV>
<DIV
style="TEXT-INDENT: 6em">
wade</DIV>
<DIV> </DIV></DIV></SPAN></FONT></FONT></BODY></HTML>