This has the advantage that we can access the attributes by name and it's immutable by design. Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxx> Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx> --- virtManager/netlist.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/virtManager/netlist.py b/virtManager/netlist.py index cb043b7e83c4..8b1f12268fb0 100644 --- a/virtManager/netlist.py +++ b/virtManager/netlist.py @@ -3,6 +3,7 @@ # This work is licensed under the GNU GPLv2 or later. # See the COPYING file in the top-level directory. +import collections import logging from gi.repository import Gtk @@ -12,6 +13,9 @@ from . import uiutil from .baseclass import vmmGObjectUI +NetDev = collections.namedtuple('Netdev', ['name', 'is_bridge', 'slave_names']) + + class vmmNetworkList(vmmGObjectUI): __gsignals__ = { "changed": (vmmGObjectUI.RUN_FIRST, None, []), @@ -165,17 +169,19 @@ class vmmNetworkList(vmmGObjectUI): netdevs = {} for iface in self.conn.list_interfaces(): - netdevs[iface.get_name()] = [ - iface.get_name(), iface.is_bridge(), iface.get_slave_names()] + name = iface.get_name() + netdevs[name] = NetDev(name, iface.is_bridge(), + iface.get_slave_names()) for nodedev in self.conn.filter_nodedevs("net"): if nodedev.xmlobj.interface not in netdevs: - netdevs[nodedev.xmlobj.interface] = [nodedev.xmlobj.interface, - False, []] + netdev = NetDev(nodedev.xmlobj.interface, False, []) + netdevs[nodedev.xmlobj.interface] = netdev # For every bridge used by a virtual network, and any slaves of # those devices, don't list them. for vnet_bridge in vnet_bridges: - slave_names = netdevs.pop(vnet_bridge, [None, None, []])[2] + slave_names = netdevs.pop(vnet_bridge, + NetDev(None, None, [])).slave_names for slave in slave_names: netdevs.pop(slave, None) -- 2.17.0 _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list