Do not add the same network multiple times

visu_broken
LEdoian 2 years ago
parent 018a7ed4b7
commit b78934167f

@ -30,11 +30,13 @@ class Topology:
self.network_addrs[directive] = net_addr
# Fix the topology: find other networks (stubnets, external, ...) and links:
known = set()
for r, rd in self.routers:
for n, nd in rd:
if n.startswith(('network', 'stubnet', 'external')):
net_id = re.match(r'((network|stubnet|external) [^ ]+)', n).group(1)
if n.startswith(('stubnet', 'external')):
if n.startswith(('stubnet', 'external')) and net_id not in known:
known.add(net_id)
self.networks.append((net_id, []))
# Add dummy mapping
self.network_addrs[net_id] = net_id

Loading…
Cancel
Save