added othernet to CoreInterface to avoid hasattr checks
This commit is contained in:
parent
c580e15f8e
commit
964f78f06a
3 changed files with 4 additions and 3 deletions
|
@ -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:
|
||||
|
|
|
@ -51,6 +51,7 @@ class CoreInterface:
|
|||
raise ValueError
|
||||
self.mtu = mtu
|
||||
self.net = None
|
||||
self.othernet = None
|
||||
self._params = {}
|
||||
self.addrlist = []
|
||||
self.hwaddr = None
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue