From 6c75c7e1cd631670437c9286a6dc092c6e273a67 Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Fri, 30 Sep 2022 07:20:20 +0200 Subject: [PATCH 1/2] Poor man's visualisation: cope with no BIRD client. --- poor_mans_visualisation.py | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/poor_mans_visualisation.py b/poor_mans_visualisation.py index cae983e..c5747fc 100644 --- a/poor_mans_visualisation.py +++ b/poor_mans_visualisation.py @@ -13,7 +13,42 @@ if len(sys.argv) > 1: with open(ref_topo_file) as ref_file: ref_topo = providers.OspfFileTopologyProvider(ref_file).get_topology() -cur_topo = providers.RunningBirdTopologyProvider().get_topology() +try: + cur_topo = providers.RunningBirdTopologyProvider().get_topology() +except OSError: + # HACK! + import traceback as tb + tb.print_exc(file=sys.stderr) + print(f'Could not get current topology from BIRD,\n' + 'will load reference one with random omissions\n----', file=sys.stderr) + with open(ref_topo_file) as ref_file: + cur_topo = providers.OspfFileTopologyProvider(ref_file).get_topology() + import random + random.seed('birdvisu_demo') + # Routers: + for _ in range(random.randint(1, 3)): + key, router_to_delete = random.choice(list(cur_topo.routers.items())) + for l in router_to_delete.links: + lk = (l.router.ident, l.network.ident) + del cur_topo.links[lk] + l.network.links.remove(l) + del cur_topo.routers[key] + # Networks: + for _ in range(random.randint(1, 3)): + key, network_to_delete = random.choice(list(cur_topo.networks.items())) + for l in network_to_delete.links: + lk = (l.router.ident, l.network.ident) + del cur_topo.links[lk] + l.router.links.remove(l) + del cur_topo.networks[key] + # Links: + for _ in range(random.randint(1, 3)): + key, link_to_delete = random.choice(list(cur_topo.links.items())) + link_to_delete.router.links.remove(link_to_delete) + link_to_delete.network.links.remove(link_to_delete) + del cur_topo.links[key] + + # Combine topologies From 999f6988cbc9b807b18f7f7d3f851b7652d6d93b Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Fri, 30 Sep 2022 07:21:10 +0200 Subject: [PATCH 2/2] Poor man's visualisation: +x --- poor_mans_visualisation.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 poor_mans_visualisation.py diff --git a/poor_mans_visualisation.py b/poor_mans_visualisation.py old mode 100644 new mode 100755