]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: zebra support for vrfwnetns parameter
authorPhilippe Guibert <philippe.guibert@6wind.com>
Wed, 31 Jan 2018 10:48:11 +0000 (11:48 +0100)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 28 Nov 2018 01:22:13 +0000 (20:22 -0500)
topotest library is being added a new parameter when preparing the
configurationof each daemon. This parameter will be used to call the
daemon with some extra parameters. The -n parameter for zebra is taken
into account.
Also, when a extra parameter is given for calling zebra, a check is done to
see if it is possible to run zebra daemon with that option. This is the
case for vrfwnetns option. If not available, an error message is sent
back.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
tests/topotests/lib/topogen.py
tests/topotests/lib/topotest.py

index 3c500a85dc76fb6bfb264c7c90366a09d3b4e148..d3d50e816c99decefaada455586952937c7681d1 100644 (file)
@@ -602,7 +602,16 @@ class TopoRouter(TopoGear):
         # Remove old core files
         map(os.remove, glob.glob('{}/{}*.dmp'.format(self.logdir, self.name)))
 
-    def load_config(self, daemon, source=None):
+    def check_capability(self, daemon, param):
+        """
+        Checks a capability daemon against an argument option
+        Return True if capability available. False otherwise
+        """
+        daemonstr = self.RD.get(daemon)
+        self.logger.info('check capability {} for "{}"'.format(param, daemonstr))
+        return self.tgen.net[self.name].checkCapability(daemonstr, param)
+
+    def load_config(self, daemon, source=None, param=None):
         """
         Loads daemon configuration from the specified source
         Possible daemon values are: TopoRouter.RD_ZEBRA, TopoRouter.RD_RIP,
@@ -612,7 +621,7 @@ class TopoRouter(TopoGear):
         """
         daemonstr = self.RD.get(daemon)
         self.logger.info('loading "{}" configuration: {}'.format(daemonstr, source))
-        self.tgen.net[self.name].loadConf(daemonstr, source)
+        self.tgen.net[self.name].loadConf(daemonstr, source, param)
 
     def check_router_running(self):
         """
index 501b8ab053c27ec51e386d860019f379b2e2a4ab..6fd1e2c179faca492aedfbdd222197a433e9195f 100644 (file)
@@ -469,6 +469,7 @@ class Router(Node):
         self.daemons = {'zebra': 0, 'ripd': 0, 'ripngd': 0, 'ospfd': 0,
                         'ospf6d': 0, 'isisd': 0, 'bgpd': 0, 'pimd': 0,
                         'ldpd': 0, 'eigrpd': 0, 'nhrpd': 0}
+        self.daemons_options = {'zebra': ''}
 
     def _config_frr(self, **params):
         "Configure FRR binaries"
@@ -569,10 +570,23 @@ class Router(Node):
     def removeIPs(self):
         for interface in self.intfNames():
             self.cmd('ip address flush', interface)
-    def loadConf(self, daemon, source=None):
+
+    def checkCapability(self, daemon, param):
+        if param is not None:
+            daemon_path = os.path.join(self.daemondir, daemon)
+            daemon_search_option = param.replace('-','')
+            output = self.cmd('{0} -h | grep {1}'.format(
+                daemon_path, daemon_search_option))
+            if daemon_search_option not in output:
+                return False
+        return True
+
+    def loadConf(self, daemon, source=None, param=None):
         # print "Daemons before:", self.daemons
         if daemon in self.daemons.keys():
             self.daemons[daemon] = 1
+            if param is not None:
+                self.daemons_options[daemon] = param
             if source is None:
                 self.cmd('touch /etc/%s/%s.conf' % (self.routertype, daemon))
                 self.waitOutput()
@@ -632,7 +646,6 @@ class Router(Node):
                 logger.info("EIGRP Test, but no eigrpd compiled or installed")
                 return "EIGRP Test, but no eigrpd compiled or installed"
 
-        # Init done - now restarting daemons
         self.restartRouter()
         return ""
     def restartRouter(self):
@@ -640,8 +653,9 @@ class Router(Node):
         # Start Zebra first
         if self.daemons['zebra'] == 1:
             zebra_path = os.path.join(self.daemondir, 'zebra')
-            self.cmd('{0} > {1}/{2}-zebra.out 2> {1}/{2}-zebra.err &'.format(
-                zebra_path, self.logdir, self.name
+            zebra_option = self.daemons_options['zebra']
+            self.cmd('{0} {1} > {2}/{3}-zebra.out 2> {2}/{3}-zebra.err &'.format(
+                 zebra_path, zebra_option, self.logdir, self.name
             ))
             self.waitOutput()
             logger.debug('{}: {} zebra started'.format(self, self.routertype))