[libvirt] How to get the IP address of a Domain?
徐滕
xuteng at huaihuacity.com
Wed Mar 30 10:10:18 UTC 2011
HI,all:
I'm new to libvirt, and have some questions about How to get the IP address of a Domain?
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 sniffer or arp tools to fetch the IP address , but:
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
VMware ESX?
Q2: How to get the domain's mac? I download the virt-manager src, searching it's source to find how to do this :
in details.py , this line seems to get the mac address:
in function update_hwlist(hwtype, info, name, icon_name): Line 2475
for net in self.vm.get_network_devices():
mac = net.macaddr
update_hwlist(HW_LIST_TYPE_NIC, net,
"NIC %s" % mac[-9:], "network-idle")
then ,I looked into domains.py, in function get_network_devices():
def get_network_devices(self, refresh_if_necc=True):
return self._build_device_list("interface", refresh_if_necc)
next, go to function _build_device_list()
def _build_device_list(self, device_type,
refresh_if_necc=True, inactive=False):
guest = self._get_guest(refresh_if_necc=refresh_if_necc,
inactive=inactive)
devs = guest.get_devices(device_type)
count = 0
for dev in devs:
dev.vmmindex = count
count += 1
return devs
finally ,in funciton _get_guest(self, inactive=False, refresh_if_necc=True)
def _get_guest(self, inactive=False, refresh_if_necc=True):
raise NotImplementedError()
this puzzled me , only raise a exception NotImplentedError(),but not deal with it .
How to get the mac address?
Sorry ,I 'm new to Python either...
Really appreciate for your help!
wade
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110330/1e00ca2a/attachment-0001.htm>
More information about the libvir-list
mailing list