From 964f78f06a15cfd618be09f00019e7d1454509a2 Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Sat, 23 May 2020 01:14:47 -0700 Subject: [PATCH] added othernet to CoreInterface to avoid hasattr checks --- daemon/core/nodes/base.py | 4 ++-- daemon/core/nodes/interface.py | 1 + daemon/core/nodes/network.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/daemon/core/nodes/base.py b/daemon/core/nodes/base.py index 1dbdcf53..e1267530 100644 --- a/daemon/core/nodes/base.py +++ b/daemon/core/nodes/base.py @@ -1086,11 +1086,11 @@ class CoreNetworkBase(NodeBase): for netif in self.netifs(sort=True): if not hasattr(netif, "node"): continue - linked_node = netif.node uni = False + linked_node = netif.node if linked_node is None: # two layer-2 switches/hubs linked together via linknet() - if not hasattr(netif, "othernet"): + if not netif.othernet: continue linked_node = netif.othernet if linked_node.id == self.id: diff --git a/daemon/core/nodes/interface.py b/daemon/core/nodes/interface.py index 8235878c..97b494b7 100644 --- a/daemon/core/nodes/interface.py +++ b/daemon/core/nodes/interface.py @@ -51,6 +51,7 @@ class CoreInterface: raise ValueError self.mtu = mtu self.net = None + self.othernet = None self._params = {} self.addrlist = [] self.hwaddr = None diff --git a/daemon/core/nodes/network.py b/daemon/core/nodes/network.py index 17fb4fc2..5f6c635c 100644 --- a/daemon/core/nodes/network.py +++ b/daemon/core/nodes/network.py @@ -580,7 +580,7 @@ class CoreNetwork(CoreNetworkBase): :return: interface the provided network is linked to """ for netif in self.netifs(): - if hasattr(netif, "othernet") and netif.othernet == net: + if netif.othernet == net: return netif return None