From f405076a4b218e17bafd8c69505884c529987b73 Mon Sep 17 00:00:00 2001 From: J vanBemmel Date: Mon, 16 Dec 2024 13:14:57 -0600 Subject: [PATCH] BUGFIX: Avoid marking single-provider links as multi-provider Fixes #1658 --- netsim/providers/__init__.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/netsim/providers/__init__.py b/netsim/providers/__init__.py index 0f205ae9f..165a54530 100644 --- a/netsim/providers/__init__.py +++ b/netsim/providers/__init__.py @@ -236,17 +236,21 @@ def pre_transform(self,topology : Box) -> None: return for l in topology.links: + providers = {} for intf in l.interfaces: node = topology.nodes[intf.node] - if not 'provider' in node: - continue - - p_name = topology.provider # Get primary and secondary provider - s_name = node.provider # ... to make the rest of the code more readable - - l[p_name].provider[s_name] = True # Collect secondary link provider(s) - if 'uplink' in l[p_name]: # ... and copy primary uplink to secondary uplink - l[s_name].uplink = l[p_name].uplink + provider = node.get('provider',topology.provider) + providers[ provider ] = True + + if len(providers)<=1: + continue # Not a multi-provider link - continue + + p_name = topology.provider # Get primary and secondary provider + s_name = node.provider # ... to make the rest of the code more readable + + l[p_name].provider[s_name] = True # Collect secondary link provider(s) + if 'uplink' in l[p_name]: # ... and copy primary uplink to secondary uplink + l[s_name].uplink = l[p_name].uplink """ Generic provider pre-output transform: remove loopback links