+# SPDX-License-Identifier: ISC
#
# topogen.py
# Library of helper functions for NetDEF Topology Tests
# 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
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
]
# 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
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",
RD_ISIS: "isisd",
RD_BGP: "bgpd",
RD_PIM: "pimd",
+ RD_PIM6: "pim6d",
RD_LDP: "ldpd",
RD_EIGRP: "eigrpd",
RD_NHRP: "nhrpd",
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
"ripngd",
"isisd",
"pimd",
+ "pim6d",
"ldpd",
"pbrd",
]:
)
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":