From d410773af81143d5848322a9b8f63b5c414f8a1f Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Sat, 25 Jan 2020 20:28:43 -0500 Subject: [PATCH] virtManager: Remove virInterface polling There are no more users of interface objects in the code. Remove all the polling support, and all the remaining references to interface objects throughout the code base Signed-off-by: Cole Robinson --- tests/interface-xml/test-bond-arp.xml | 20 ----- tests/interface-xml/test-bond-mii.xml | 20 ----- tests/interface-xml/test-bond.xml | 19 ----- tests/interface-xml/test-bridge-ip.xml | 38 ---------- tests/interface-xml/test-bridge.xml | 25 ------- .../test-ethernet-copy-proto.xml | 5 -- tests/interface-xml/test-ethernet-params.xml | 4 - tests/interface-xml/test-ethernet.xml | 1 - tests/interface-xml/test-vlan.xml | 5 -- tests/interface.py | 32 -------- tests/testdriver.xml | 73 ------------------- virtManager/addhardware.py | 2 +- virtManager/connection.py | 37 ++-------- virtManager/createvm.py | 2 +- virtManager/object/interface.py | 50 ------------- virtManager/object/libvirtobject.py | 2 - virtinst/__init__.py | 1 - virtinst/interface.py | 64 ---------------- virtinst/pollhelpers.py | 7 -- virtinst/support.py | 2 - 20 files changed, 8 insertions(+), 401 deletions(-) delete mode 100644 tests/interface-xml/test-bond-arp.xml delete mode 100644 tests/interface-xml/test-bond-mii.xml delete mode 100644 tests/interface-xml/test-bond.xml delete mode 100644 tests/interface-xml/test-bridge-ip.xml delete mode 100644 tests/interface-xml/test-bridge.xml delete mode 100644 tests/interface-xml/test-ethernet-copy-proto.xml delete mode 100644 tests/interface-xml/test-ethernet-params.xml delete mode 100644 tests/interface-xml/test-ethernet.xml delete mode 100644 tests/interface-xml/test-vlan.xml delete mode 100644 tests/interface.py delete mode 100644 virtManager/object/interface.py delete mode 100644 virtinst/interface.py diff --git a/tests/interface-xml/test-bond-arp.xml b/tests/interface-xml/test-bond-arp.xml deleted file mode 100644 index ec5176dba..000000000 --- a/tests/interface-xml/test-bond-arp.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/tests/interface-xml/test-bond-mii.xml b/tests/interface-xml/test-bond-mii.xml deleted file mode 100644 index b27f72a71..000000000 --- a/tests/interface-xml/test-bond-mii.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/tests/interface-xml/test-bond.xml b/tests/interface-xml/test-bond.xml deleted file mode 100644 index c314c9a2f..000000000 --- a/tests/interface-xml/test-bond.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/tests/interface-xml/test-bridge-ip.xml b/tests/interface-xml/test-bridge-ip.xml deleted file mode 100644 index 503e08720..000000000 --- a/tests/interface-xml/test-bridge-ip.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/interface-xml/test-bridge.xml b/tests/interface-xml/test-bridge.xml deleted file mode 100644 index a95a1b02e..000000000 --- a/tests/interface-xml/test-bridge.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/interface-xml/test-ethernet-copy-proto.xml b/tests/interface-xml/test-ethernet-copy-proto.xml deleted file mode 100644 index 5f570e765..000000000 --- a/tests/interface-xml/test-ethernet-copy-proto.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/tests/interface-xml/test-ethernet-params.xml b/tests/interface-xml/test-ethernet-params.xml deleted file mode 100644 index ea6abac10..000000000 --- a/tests/interface-xml/test-ethernet-params.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/tests/interface-xml/test-ethernet.xml b/tests/interface-xml/test-ethernet.xml deleted file mode 100644 index 04718372a..000000000 --- a/tests/interface-xml/test-ethernet.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/tests/interface-xml/test-vlan.xml b/tests/interface-xml/test-vlan.xml deleted file mode 100644 index 25e97400d..000000000 --- a/tests/interface-xml/test-vlan.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/tests/interface.py b/tests/interface.py deleted file mode 100644 index 797140c57..000000000 --- a/tests/interface.py +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright (C) 2013 Red Hat, Inc. -# -# This work is licensed under the GNU GPLv2 or later. -# See the COPYING file in the top-level directory. - -import unittest - -from virtinst import Interface -from tests import utils - -datadir = "tests/interface-xml" - - -class TestInterfaces(unittest.TestCase): - def testInterfaceBridgeIP(self): - conn = utils.URIs.open_testdriver_cached() - - def _check_iface(name, typ, child_names): - libvirtobj = conn.interfaceLookupByName(name) - xmlobj = Interface(conn, parsexml=libvirtobj.XMLDesc(0)) - - self.assertEqual(xmlobj.name, name) - self.assertEqual(xmlobj.type, typ) - self.assertEqual( - {i.name for i in xmlobj.interfaces}, - set(child_names)) - - _check_iface("eth0", "ethernet", []) - _check_iface("bond0", "bond", ["eth-bond0-1", "eth-bond0-2"]) - _check_iface("brplain", "bridge", ["eth-brplain0", "eth-brplain1"]) - _check_iface("brempty", "bridge", []) - _check_iface("vlaneth1.3", "vlan", ["vlaneth1"]) diff --git a/tests/testdriver.xml b/tests/testdriver.xml index e59ca7052..4ca85db17 100644 --- a/tests/testdriver.xml +++ b/tests/testdriver.xml @@ -3610,77 +3610,4 @@ ba - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py index 80065306b..cfa0cffe8 100644 --- a/virtManager/addhardware.py +++ b/virtManager/addhardware.py @@ -131,7 +131,7 @@ class vmmAddHardware(vmmGObjectUI): self.topwin.set_transient_for(parent) self.topwin.present() self.conn.schedule_priority_tick(pollnet=True, - pollpool=True, polliface=True, + pollpool=True, pollnodedev=True) def close(self, ignore1=None, ignore2=None): diff --git a/virtManager/connection.py b/virtManager/connection.py index 8c1a59391..b8e276fa9 100644 --- a/virtManager/connection.py +++ b/virtManager/connection.py @@ -19,7 +19,6 @@ from .lib import connectauth from .baseclass import vmmGObject from .lib.libvirtenummap import LibvirtEnumMap from .object.domain import vmmDomain -from .object.interface import vmmInterface from .object.network import vmmNetwork from .object.nodedev import vmmNodeDevice from .object.storagepool import vmmStoragePool @@ -148,8 +147,6 @@ class vmmConnection(vmmGObject): "net-removed": (vmmGObject.RUN_FIRST, None, [str]), "pool-added": (vmmGObject.RUN_FIRST, None, [str]), "pool-removed": (vmmGObject.RUN_FIRST, None, [str]), - "interface-added": (vmmGObject.RUN_FIRST, None, [str]), - "interface-removed": (vmmGObject.RUN_FIRST, None, [str]), "nodedev-added": (vmmGObject.RUN_FIRST, None, [str]), "nodedev-removed": (vmmGObject.RUN_FIRST, None, [str]), "resources-sampled": (vmmGObject.RUN_FIRST, None, []), @@ -533,11 +530,6 @@ class vmmConnection(vmmGObject): def list_pools(self): return self._objects.get_objects_for_class(vmmStoragePool) - def get_interface(self, connkey): - return self._objects.lookup_object(vmmInterface, connkey) - def list_interfaces(self): - return self._objects.get_objects_for_class(vmmInterface) - def get_nodedev(self, connkey): return self._objects.lookup_object(vmmNodeDevice, connkey) def list_nodedevs(self): @@ -958,8 +950,6 @@ class vmmConnection(vmmGObject): log.debug("Connection doesn't seem to support storage APIs.") if not self.support.conn_network(): log.debug("Connection doesn't seem to support network APIs.") - if not self.support.conn_interface(): - log.debug("Connection doesn't seem to support interface APIs.") if not self.support.conn_nodedev(): log.debug("Connection doesn't seem to support nodedev APIs.") @@ -983,8 +973,8 @@ class vmmConnection(vmmGObject): self.schedule_priority_tick(stats_update=True, pollvm=True, pollnet=True, - pollpool=True, polliface=True, - pollnodedev=True, force=True, initial_poll=True) + pollpool=True, pollnodedev=True, + force=True, initial_poll=True) self._init_object_event.wait() self._init_object_event = None @@ -1027,8 +1017,6 @@ class vmmConnection(vmmGObject): self.emit("net-removed", obj.get_connkey()) elif obj.is_pool(): self.emit("pool-removed", obj.get_connkey()) - elif obj.is_interface(): - self.emit("interface-removed", obj.get_connkey()) elif obj.is_nodedev(): self.emit("nodedev-removed", obj.get_connkey()) @@ -1090,8 +1078,6 @@ class vmmConnection(vmmGObject): self.emit("net-added", obj.get_connkey()) elif obj.is_pool(): self.emit("pool-added", obj.get_connkey()) - elif obj.is_interface(): - self.emit("interface-added", obj.get_connkey()) elif obj.is_nodedev(): self.emit("nodedev-added", obj.get_connkey()) finally: @@ -1112,12 +1098,6 @@ class vmmConnection(vmmGObject): return vmmStoragePool(self, obj, key) return pollhelpers.fetch_pools(self._backend, keymap, cb) - def _update_interfaces(self): - keymap = dict((o.get_connkey(), o) for o in self.list_interfaces()) - def cb(obj, key): - return vmmInterface(self, obj, key) - return pollhelpers.fetch_interfaces(self._backend, keymap, cb) - def _update_nodedevs(self): keymap = dict((o.get_connkey(), o) for o in self.list_nodedevs()) def cb(obj, key): @@ -1131,7 +1111,7 @@ class vmmConnection(vmmGObject): return pollhelpers.fetch_vms(self._backend, keymap, cb) def _poll(self, initial_poll, - pollvm, pollnet, pollpool, polliface, pollnodedev): + pollvm, pollnet, pollpool, pollnodedev): """ Helper called from tick() to do necessary polling and return the relevant object lists @@ -1156,7 +1136,6 @@ class vmmConnection(vmmGObject): new_vms = _process_objects(self._update_vms, pollvm) new_nets = _process_objects(self._update_nets, pollnet) new_pools = _process_objects(self._update_pools, pollpool) - new_ifaces = _process_objects(self._update_interfaces, polliface) new_nodedevs = _process_objects(self._update_nodedevs, pollnodedev) # Kick off one thread per object type to handle the initial @@ -1172,8 +1151,7 @@ class vmmConnection(vmmGObject): # is never called and the event is never set, so let's do it here self._init_object_event.set() - for newlist in [new_vms, new_nets, new_pools, - new_ifaces, new_nodedevs]: + for newlist in [new_vms, new_nets, new_pools, new_nodedevs]: if not newlist: continue @@ -1190,8 +1168,7 @@ class vmmConnection(vmmGObject): def _tick(self, stats_update=False, pollvm=False, pollnet=False, - pollpool=False, polliface=False, - pollnodedev=False, + pollpool=False, pollnodedev=False, force=False, initial_poll=False): """ main update function: polls for new objects, updates stats, ... @@ -1225,7 +1202,7 @@ class vmmConnection(vmmGObject): self.statsmanager.cache_all_stats(self) gone_objects, preexisting_objects = self._poll( - initial_poll, pollvm, pollnet, pollpool, polliface, pollnodedev) + initial_poll, pollvm, pollnet, pollpool, pollnodedev) self.idle_add(self._gone_object_signals, gone_objects) # Only tick() pre-existing objects, since new objects will be @@ -1240,8 +1217,6 @@ class vmmConnection(vmmGObject): continue elif obj.is_pool() and not pollpool: continue - elif obj.is_interface() and not polliface: - continue elif obj.is_nodedev() and not pollnodedev: continue diff --git a/virtManager/createvm.py b/virtManager/createvm.py index 1651022b7..25055329f 100644 --- a/virtManager/createvm.py +++ b/virtManager/createvm.py @@ -514,7 +514,7 @@ class vmmCreateVM(vmmGObjectUI): Update all state that has some dependency on the current connection """ self.conn.schedule_priority_tick(pollnet=True, - pollpool=True, polliface=True, + pollpool=True, pollnodedev=True) self.widget("install-box").show() diff --git a/virtManager/object/interface.py b/virtManager/object/interface.py deleted file mode 100644 index 87c2a6f9e..000000000 --- a/virtManager/object/interface.py +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (C) 2009, 2013 Red Hat, Inc. -# Copyright (C) 2009 Cole Robinson -# -# This work is licensed under the GNU GPLv2 or later. -# See the COPYING file in the top-level directory. - -from virtinst import Interface - -from .libvirtobject import vmmLibvirtObject - - -class vmmInterface(vmmLibvirtObject): - def __init__(self, conn, backend, key): - vmmLibvirtObject.__init__(self, conn, backend, key, Interface) - - - ########################## - # Required class methods # - ########################## - - # Routines from vmmLibvirtObject - def _conn_tick_poll_param(self): - return "polliface" - def class_name(self): - return "interface" - - def _XMLDesc(self, flags): - return self._backend.XMLDesc(flags) - def _get_backend_status(self): - # 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.tick() - - - ################ - # XML routines # - ################ - - def is_bridge(self): - return self.get_xmlobj().type == "bridge" - - def get_interface_names(self): - return [obj.name for obj in self.get_xmlobj().interfaces] diff --git a/virtManager/object/libvirtobject.py b/virtManager/object/libvirtobject.py index 40dccaf54..a27088af8 100644 --- a/virtManager/object/libvirtobject.py +++ b/virtManager/object/libvirtobject.py @@ -105,8 +105,6 @@ class vmmLibvirtObject(vmmGObject): return self.class_name() == "pool" def is_nodedev(self): return self.class_name() == "nodedev" - def is_interface(self): - return self.class_name() == "interface" def change_name_backend(self, newbackend): # Used for changing the backing object after a rename diff --git a/virtinst/__init__.py b/virtinst/__init__.py index 7d0972205..f6c9899bb 100644 --- a/virtinst/__init__.py +++ b/virtinst/__init__.py @@ -50,7 +50,6 @@ from virtinst.domain import * # pylint: disable=wildcard-import from virtinst.capabilities import Capabilities from virtinst.domcapabilities import DomainCapabilities -from virtinst.interface import Interface from virtinst.network import Network from virtinst.nodedev import NodeDevice from virtinst.storage import StoragePool, StorageVolume diff --git a/virtinst/interface.py b/virtinst/interface.py deleted file mode 100644 index 81de9544b..000000000 --- a/virtinst/interface.py +++ /dev/null @@ -1,64 +0,0 @@ -# -# Copyright 2009, 2013 Red Hat, Inc. -# -# This work is licensed under the GNU GPLv2 or later. -# See the COPYING file in the top-level directory. -""" -Classes for building and installing libvirt interface xml -""" - -from .xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty - - -class _BondConfig(XMLBuilder): - XML_NAME = "bond" - - -class _BridgeConfig(XMLBuilder): - XML_NAME = "bridge" - - -class _VLANConfig(XMLBuilder): - XML_NAME = "vlan" - - -class Interface(XMLBuilder): - """ - Base class for parsing any libvirt virInterface object XML - """ - - XML_NAME = "interface" - _XML_PROP_ORDER = ["type", "name", "_bond", "_bridge", "_vlan"] - - ###################### - # Interface handling # - ###################### - - # The recursive nature of nested interfaces complicates things here, - # which is why this is strange. See bottom of the file for more - # weirdness - - _bond = XMLChildProperty(_BondConfig, is_single=True) - _bridge = XMLChildProperty(_BridgeConfig, is_single=True) - _vlan = XMLChildProperty(_VLANConfig, is_single=True) - - @property - def interfaces(self): - if self.type != "ethernet": - return getattr(self, "_" + self.type).interfaces - return [] - - - ################## - # General params # - ################## - - type = XMLProperty("./@type") - name = XMLProperty("./@name") - - -# Interface can recursively have child interfaces which we can't define -# inline in the class config, hence this hackery -_BondConfig.interfaces = XMLChildProperty(Interface) -_BridgeConfig.interfaces = XMLChildProperty(Interface) -_VLANConfig.interfaces = XMLChildProperty(Interface) diff --git a/virtinst/pollhelpers.py b/virtinst/pollhelpers.py index a5c8391e7..72d1e4f18 100644 --- a/virtinst/pollhelpers.py +++ b/virtinst/pollhelpers.py @@ -58,13 +58,6 @@ def fetch_volumes(backend, pool, origmap, build_cb): return _new_poll_helper(origmap, name, list_cb, build_cb, support_cb) -def fetch_interfaces(backend, origmap, build_cb): - name = "interface" - list_cb = backend.listAllInterfaces - support_cb = backend.support.conn_interface - return _new_poll_helper(origmap, name, list_cb, build_cb, support_cb) - - def fetch_nodedevs(backend, origmap, build_cb): name = "nodedev" list_cb = backend.listAllDevices diff --git a/virtinst/support.py b/virtinst/support.py index 1008cec87..ae05ceb19 100644 --- a/virtinst/support.py +++ b/virtinst/support.py @@ -235,8 +235,6 @@ class SupportCache: function="virConnect.listDevices", run_args=(None, 0)) conn_network = _make( function="virConnect.listNetworks", run_args=()) - conn_interface = _make( - function="virConnect.listInterfaces", run_args=()) conn_stream = _make(function="virConnect.newStream", run_args=(0,)) conn_working_xen_events = _make(hv_version={"xen": "4.0.0", "all": 0})