]> git.proxmox.com Git - mirror_frr.git/blobdiff - tests/topotests/lib/topogen.py
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / tests / topotests / lib / topogen.py
index 33e1388639680a160cbe41c4316ff8d99b0faacc..16d89f079a720d9182c3055336b2796f91e80b41 100644 (file)
@@ -1,3 +1,4 @@
+# SPDX-License-Identifier: ISC
 #
 # topogen.py
 # Library of helper functions for NetDEF Topology Tests
@@ -5,20 +6,6 @@
 # Copyright (c) 2017 by
 # Network Device Education Foundation, Inc. ("NetDEF")
 #
-# Permission to use, copy, modify, and/or distribute this software
-# for any purpose with or without fee is hereby granted, provided
-# that the above copyright notice and this permission notice appear
-# in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
-# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
-# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
-# OF THIS SOFTWARE.
-#
 
 """
 Topogen (Topology Generator) is an abstraction around Topotest and Mininet to
@@ -443,7 +430,7 @@ class Topogen(object):
     def start_router(self, router=None):
         """
         Call the router startRouter method.
-        If no router is specified it is called for all registred routers.
+        If no router is specified it is called for all registered routers.
         """
         if router is None:
             # pylint: disable=r1704
@@ -706,6 +693,7 @@ class TopoRouter(TopoGear):
     ]
 
     # Router Daemon enumeration definition.
+    RD_FRR = 0  # not a daemon, but use to setup unified configs
     RD_ZEBRA = 1
     RD_RIP = 2
     RD_RIPNG = 3
@@ -724,7 +712,9 @@ class TopoRouter(TopoGear):
     RD_PBRD = 16
     RD_PATH = 17
     RD_SNMP = 18
+    RD_PIM6 = 19
     RD = {
+        RD_FRR: "frr",
         RD_ZEBRA: "zebra",
         RD_RIP: "ripd",
         RD_RIPNG: "ripngd",
@@ -733,6 +723,7 @@ class TopoRouter(TopoGear):
         RD_ISIS: "isisd",
         RD_BGP: "bgpd",
         RD_PIM: "pimd",
+        RD_PIM6: "pim6d",
         RD_LDP: "ldpd",
         RD_EIGRP: "eigrpd",
         RD_NHRP: "nhrpd",
@@ -789,12 +780,37 @@ class TopoRouter(TopoGear):
         self.logger.info('check capability {} for "{}"'.format(param, daemonstr))
         return self.net.checkCapability(daemonstr, param)
 
+    def load_frr_config(self, source, daemons=None):
+        """
+        Loads the unified configuration file source
+        Start the daemons in the list
+        If daemons is None, try to infer daemons from the config file
+        """
+        self.load_config(self.RD_FRR, source)
+        if not daemons:
+            # Always add zebra
+            self.load_config(self.RD_ZEBRA)
+            for daemon in self.RD:
+                # This will not work for all daemons
+                daemonstr = self.RD.get(daemon).rstrip("d")
+                if daemonstr == "pim":
+                    grep_cmd = "grep 'ip {}' {}".format(daemonstr, source)
+                else:
+                    grep_cmd = "grep 'router {}' {}".format(daemonstr, source)
+                result = self.run(grep_cmd).strip()
+                if result:
+                    self.load_config(daemon)
+        else:
+            for daemon in daemons:
+                self.load_config(daemon)
+
     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,
         TopoRouter.RD_RIPNG, TopoRouter.RD_OSPF, TopoRouter.RD_OSPF6,
         TopoRouter.RD_ISIS, TopoRouter.RD_BGP, TopoRouter.RD_LDP,
-        TopoRouter.RD_PIM, TopoRouter.RD_PBR, TopoRouter.RD_SNMP.
+        TopoRouter.RD_PIM, TopoRouter.RD_PIM6, TopoRouter.RD_PBR,
+        TopoRouter.RD_SNMP.
 
         Possible `source` values are `None` for an empty config file, a path name which is
         used directly, or a file name with no path components which is first looked for
@@ -1250,6 +1266,7 @@ def diagnose_env_linux(rundir):
             "ripngd",
             "isisd",
             "pimd",
+            "pim6d",
             "ldpd",
             "pbrd",
         ]:
@@ -1263,7 +1280,7 @@ def diagnose_env_linux(rundir):
                     )
                     continue
 
-                logger.warning("could not find {} in {}".format(fname, frrdir))
+                logger.error("could not find {} in {}".format(fname, frrdir))
                 ret = False
             else:
                 if fname != "zebra":