]> git.puffer.fish Git - matthieu/frr.git/commitdiff
topogen: implement start/stop methods for TopoGear
authorRafael Zalamena <rzalamena@gmail.com>
Mon, 10 Jul 2017 20:01:23 +0000 (17:01 -0300)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 28 Nov 2018 01:22:11 +0000 (20:22 -0500)
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

index 1fb3679d7e7449685c82c74c0d18412783e70796..cc139bc83c737695c2b54e81627a558338193f95 100644 (file)
@@ -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<name="{}",links=[{}]>'.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