host: Show running interface IP address

This commit is contained in:
Cole Robinson 2010-12-02 15:19:17 -05:00
parent 9e312c7a67
commit 8b8974970a
2 changed files with 15 additions and 10 deletions

View File

@ -550,10 +550,6 @@ class vmmConnection(gobject.GObject):
if virtinst.support.check_interface_support(iface, if virtinst.support.check_interface_support(iface,
virtinst.support.SUPPORT_INTERFACE_XML_INACTIVE): virtinst.support.SUPPORT_INTERFACE_XML_INACTIVE):
inact = libvirt.VIR_INTERFACE_XML_INACTIVE inact = libvirt.VIR_INTERFACE_XML_INACTIVE
# XXX: We intentionally use 'inactive' XML even for active
# interfaces, since active XML doesn't show much info
act = inact
else: else:
logging.debug("Interface XML inactive flag not supported.") logging.debug("Interface XML inactive flag not supported.")

View File

@ -51,8 +51,17 @@ class vmmInterface(vmmLibvirtObject):
def _define(self, xml): def _define(self, xml):
return self.get_connection().define_interface(xml) return self.get_connection().define_interface(xml)
def xpath(self, path): def xpath(self, *args, **kwargs):
return virtinst.util.get_xml_path(self.get_xml(), path) # Must use this function for ALL XML parsing
ret = virtinst.util.get_xml_path(self.get_xml(), *args, **kwargs)
if ret:
return ret
if not self.is_active():
return ret
# The running config did not have the info requested
return virtinst.util.get_xml_path(self.get_xml(inactive=True),
*args, **kwargs)
def set_active(self, state): def set_active(self, state):
self.active = state self.active = state
@ -83,7 +92,7 @@ class vmmInterface(vmmLibvirtObject):
return typ == "bridge" return typ == "bridge"
def get_type(self): def get_type(self):
return virtinst.util.get_xml_path(self.get_xml(), "/interface/@type") return self.xpath("/interface/@type")
def get_pretty_type(self): def get_pretty_type(self):
itype = self.get_type() itype = self.get_type()
@ -132,7 +141,7 @@ class vmmInterface(vmmLibvirtObject):
return ret return ret
ret = virtinst.util.get_xml_path(self.get_xml(), func=node_func) ret = self.xpath(func=node_func)
if not ret: if not ret:
return [] return []
@ -184,7 +193,7 @@ class vmmInterface(vmmLibvirtObject):
return ret return ret
ret = virtinst.util.get_xml_path(self.get_xml(), func=addr_func) ret = self.xpath(func=addr_func)
return [dhcp, autoconf, ret] return [dhcp, autoconf, ret]
@ -199,7 +208,7 @@ class vmmInterface(vmmLibvirtObject):
return ret return ret
ret = virtinst.util.get_xml_path(self.get_xml(), func=protocol) ret = self.xpath(func=protocol)
if ret: if ret:
ret = " %s\n" % ret ret = " %s\n" % ret
return ret return ret