From 87935c7e3adc2802a436f742999748c0222c446d Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Sat, 15 Jul 2023 14:17:15 +0200 Subject: [PATCH] Set a better(?) fallback for unusable BIRD. --- poor_mans_visualisation.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/poor_mans_visualisation.py b/poor_mans_visualisation.py index 3ef4365..00a5229 100755 --- a/poor_mans_visualisation.py +++ b/poor_mans_visualisation.py @@ -12,10 +12,22 @@ if len(sys.argv) > 1: ref_topo = OspfFileTopologyProvider(ref_topo_file).get_topology() -try: - cur_topo = BirdSocketTopologyProvider(instance='ospf1', area=0).get_topology() -except OSError as e: - raise NotImplementedError('Cannot create a mock topology atm') from e +def get_empty_topology(): + from birdvisu.topo_v3 import TopologyV3 + topo = TopologyV3() + topo.freeze() + return topo + +if len(sys.argv) > 2 and sys.argv[2] == '--no-bird': + cur_topo = get_empty_topology() +else: + try: + cur_topo = BirdSocketTopologyProvider(instance='ospf1', area=0).get_topology() + except OSError as e: + # I know this is not how you print exceptions. + print('Cannot get topology from BIRD: {e}') + print('Will provide an empty topology.') + cur_topo = get_empty_topology() # Create combined topology