virtManager: interface: Remove unused code after UI removal

Removal all the virtManager bits that are no longer used
This commit is contained in:
Cole Robinson 2019-05-04 11:39:25 -04:00
parent 622a363e5b
commit 85a7b2cd61
4 changed files with 7 additions and 142 deletions

View File

@ -518,23 +518,6 @@ class vmmConnection(vmmGObject):
return self._get_flags_helper(vm, key, check_func)
def get_interface_flags(self, iface):
key = "interface"
def check_func():
act = 0
inact = 0
if self.check_support(
self._backend.SUPPORT_INTERFACE_XML_INACTIVE, iface):
inact = libvirt.VIR_INTERFACE_XML_INACTIVE
else:
logging.debug("Interface XML inactive flag not supported.")
return (inact, act)
return self._get_flags_helper(iface, key, check_func)
def get_default_pool(self):
for p in self.list_pools():
if p.get_name() == "default":
@ -667,8 +650,6 @@ class vmmConnection(vmmGObject):
return self._backend.networkDefineXML(xml)
def define_pool(self, xml):
return self._backend.storagePoolDefineXML(xml, 0)
def define_interface(self, xml):
return self._backend.interfaceDefineXML(xml, 0)
def rename_object(self, obj, origxml, newxml, oldconnkey):
if obj.is_domain():

View File

@ -26,129 +26,25 @@ class vmmInterface(vmmLibvirtObject):
def _XMLDesc(self, flags):
return self._backend.XMLDesc(flags)
def _define(self, xml):
return self.conn.define_interface(xml)
def _check_supports_isactive(self):
return self.conn.check_support(
self.conn.SUPPORT_INTERFACE_ISACTIVE, self._backend)
def _get_backend_status(self):
return self._backend_get_active()
# The libvirt object can be active or inactive, but our code
# doesn't care.
return True
def tick(self, stats_update=True):
ignore = stats_update
self._refresh_status()
def _init_libvirt_state(self):
(self._inactive_xml_flags,
self._active_xml_flags) = self.conn.get_interface_flags(self._backend)
self.tick()
#####################
# Object operations #
#####################
@vmmLibvirtObject.lifecycle_action
def start(self):
self._backend.create(0)
@vmmLibvirtObject.lifecycle_action
def stop(self):
self._backend.destroy(0)
@vmmLibvirtObject.lifecycle_action
def delete(self, force=True):
self._backend.undefine()
################
# XML routines #
################
def get_mac(self):
return self.get_xmlobj().macaddr
def is_bridge(self):
typ = self.get_type()
return typ == "bridge"
return self.get_xmlobj().type == "bridge"
def get_type(self):
return self.get_xmlobj().type
def get_pretty_type(self):
itype = self.get_type()
if itype == Interface.INTERFACE_TYPE_VLAN:
return "VLAN"
elif itype:
return str(itype).capitalize()
else:
return _("Interface")
def get_startmode(self):
return self.get_xmlobj(inactive=True).start_mode or "none"
def set_startmode(self, newmode):
xmlobj = self._make_xmlobj_to_define()
xmlobj.start_mode = newmode
self._redefine_xmlobj(xmlobj)
def get_slaves(self):
return [[obj.name, obj.type or _("Unknown")] for obj in
self.get_xmlobj().interfaces]
def get_slave_names(self):
# Returns a list of names of all enslaved interfaces
return [x[0] for x in self.get_slaves()]
def _get_ip(self, iptype):
# Get list of IP addresses from active XML and protocol configuration
# from inactive XML to figure out whether the IP address is static or
# from DHCP server.
activeObj = self.get_xmlobj()
inactiveObj = self.get_xmlobj(inactive=True)
activeProto = None
inactiveProto = None
for protocol in activeObj.protocols:
if protocol.family == iptype:
activeProto = protocol
break
for protocol in inactiveObj.protocols:
if protocol.family == iptype:
inactiveProto = protocol
break
if not activeProto and not inactiveProto:
return None, []
ret = []
if activeProto:
for ip in activeProto.ips:
ipstr = ip.address
if not ipstr:
continue
if ip.prefix:
ipstr += "/%s" % ip.prefix
ret.append(ipstr)
return inactiveProto or activeProto, ret
def get_ipv4(self):
proto, ips = self._get_ip("ipv4")
if proto is None:
return []
ipstr = None
if ips:
ipstr = ips[0]
return [proto.dhcp, ipstr]
def get_ipv6(self):
proto, ips = self._get_ip("ipv6")
if proto is None:
return []
return [proto.dhcp, proto.autoconf, ips]
def get_protocol_xml(self, inactive=False):
return self.get_xmlobj(inactive=inactive).protocols[:]
def get_interface_names(self):
return [obj.name for obj in self.get_xmlobj().interfaces]

View File

@ -171,7 +171,7 @@ class vmmNetworkList(vmmGObjectUI):
for iface in self.conn.list_interfaces():
name = iface.get_name()
netdevs[name] = NetDev(name, iface.is_bridge(),
iface.get_slave_names())
iface.get_interface_names())
for nodedev in self.conn.filter_nodedevs("net"):
if nodedev.xmlobj.interface not in netdevs:
netdev = NetDev(nodedev.xmlobj.interface, False, [])

View File

@ -313,18 +313,6 @@ SUPPORT_POOL_METADATA_PREALLOC = _make(
version="1.0.1")
####################
# Interface checks #
####################
SUPPORT_INTERFACE_XML_INACTIVE = _make(function="virInterface.XMLDesc",
flag="VIR_INTERFACE_XML_INACTIVE",
run_args=())
SUPPORT_INTERFACE_ISACTIVE = _make(
function="virInterface.isActive", run_args=())
##################
# Network checks #
##################