From 4cfdff1a861184e8b643372cb0da0fcd8452c501 Mon Sep 17 00:00:00 2001 From: Rafael Zalamena Date: Mon, 10 Jul 2017 17:01:23 -0300 Subject: [PATCH] topogen: implement start/stop methods for TopoGear Having a generic start/stop methods for TopoGear allows TopoGen to call start/stop for all equipments. This allows us to reduce the teardown code by removing the necessity of having to always remember to call each equipment clean up function. --- tests/topotests/lib/topogen.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/topotests/lib/topogen.py b/tests/topotests/lib/topogen.py index 1fb3679d7e..cc139bc83c 100644 --- a/tests/topotests/lib/topogen.py +++ b/tests/topotests/lib/topogen.py @@ -250,8 +250,16 @@ class Topogen(object): router.start() def stop_topology(self): - "Stops the network topology" + """ + Stops the network topology. This function will call the stop() function + of all gears before calling the mininet stop function, so they can have + their oportunity to do a graceful shutdown. + """ logger.info('stopping topology: {}'.format(self.modname)) + + for gear in self.gears.values(): + gear.stop() + self.net.stop() def mininet_cli(self): @@ -310,6 +318,14 @@ class TopoGear(object): return 'TopoGear'.format(self.name, links) + def start(self): + "Basic start function that just reports equipment start" + logger.info('starting "{}"'.format(self.name)) + + def stop(self): + "Basic start function that just reports equipment stop" + logger.info('stopping "{}"'.format(self.name)) + def run(self, command): """ Runs the provided command string in the router and returns a string -- 2.39.5