diff options
Diffstat (limited to 'tests/topotests/lib/topogen.py')
-rw-r--r-- | tests/topotests/lib/topogen.py | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/tests/topotests/lib/topogen.py b/tests/topotests/lib/topogen.py index 4d935b9..155d2d0 100644 --- a/tests/topotests/lib/topogen.py +++ b/tests/topotests/lib/topogen.py @@ -81,20 +81,20 @@ def is_string(value): def get_exabgp_cmd(commander=None): - """Return the command to use for ExaBGP version < 4.""" + """Return the command to use for ExaBGP version >= 4.2.11""" if commander is None: commander = Commander("exabgp", logger=logging.getLogger("exabgp")) def exacmd_version_ok(exacmd): - logger.debug("checking %s for exabgp < version 4", exacmd) + logger.debug("checking %s for exabgp version >= 4.2.11", exacmd) _, stdout, _ = commander.cmd_status(exacmd + " -v", warn=False) m = re.search(r"ExaBGP\s*:\s*((\d+)\.(\d+)(?:\.(\d+))?)", stdout) if not m: return False version = m.group(1) - if topotest.version_cmp(version, "4") >= 0: - logging.debug("found exabgp version >= 4 in %s will keep looking", exacmd) + if topotest.version_cmp(version, "4.2.11") < 0: + logging.debug("found exabgp version < 4.2.11 in %s will keep looking", exacmd) return False logger.info("Using ExaBGP version %s in %s", version, exacmd) return True @@ -102,14 +102,14 @@ def get_exabgp_cmd(commander=None): exacmd = commander.get_exec_path("exabgp") if exacmd and exacmd_version_ok(exacmd): return exacmd - py2_path = commander.get_exec_path("python2") - if py2_path: - exacmd = py2_path + " -m exabgp" + py3_path = commander.get_exec_path("python3") + if py3_path: + exacmd = py3_path + " -m exabgp" if exacmd_version_ok(exacmd): return exacmd - py2_path = commander.get_exec_path("python") - if py2_path: - exacmd = py2_path + " -m exabgp" + py3_path = commander.get_exec_path("python") + if py3_path: + exacmd = py3_path + " -m exabgp" if exacmd_version_ok(exacmd): return exacmd return None @@ -719,6 +719,7 @@ class TopoRouter(TopoGear): "/etc/frr", "/etc/snmp", "/var/run/frr", + "/var/lib/frr", "/var/log", ] @@ -744,6 +745,7 @@ class TopoRouter(TopoGear): RD_SNMP = 18 RD_PIM6 = 19 RD_MGMTD = 20 + RD_TRAP = 21 RD = { RD_FRR: "frr", RD_ZEBRA: "zebra", @@ -766,6 +768,7 @@ class TopoRouter(TopoGear): RD_PATH: "pathd", RD_SNMP: "snmpd", RD_MGMTD: "mgmtd", + RD_TRAP: "snmptrapd", } def __init__(self, tgen, cls, name, **params): @@ -842,7 +845,7 @@ class TopoRouter(TopoGear): TopoRouter.RD_RIPNG, TopoRouter.RD_OSPF, TopoRouter.RD_OSPF6, TopoRouter.RD_ISIS, TopoRouter.RD_BGP, TopoRouter.RD_LDP, TopoRouter.RD_PIM, TopoRouter.RD_PIM6, TopoRouter.RD_PBR, - TopoRouter.RD_SNMP, TopoRouter.RD_MGMTD. + TopoRouter.RD_SNMP, TopoRouter.RD_MGMTD, TopoRouter.RD_TRAP. 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 @@ -880,7 +883,7 @@ class TopoRouter(TopoGear): # Enable all daemon command logging, logging files # and set them to the start dir. for daemon, enabled in nrouter.daemons.items(): - if enabled and daemon != "snmpd": + if enabled and daemon != "snmpd" and daemon != "snmptrapd": self.vtysh_cmd( "\n".join( [ @@ -1196,7 +1199,7 @@ class TopoExaBGP(TopoHost): * Run ExaBGP with env file `env_file` and configuration peer*/exabgp.cfg """ exacmd = self.tgen.get_exabgp_cmd() - assert exacmd, "Can't find a usabel ExaBGP (must be < version 4)" + assert exacmd, "Can't find a usable ExaBGP (must be version >= 4.2.11)" self.run("mkdir -p /etc/exabgp") self.run("chmod 755 /etc/exabgp") @@ -1207,8 +1210,22 @@ class TopoExaBGP(TopoHost): self.run("chmod 644 /etc/exabgp/*") self.run("chmod a+x /etc/exabgp/*.py") self.run("chown -R exabgp:exabgp /etc/exabgp") + self.run("[ -p /var/run/exabgp.in ] || mkfifo /var/run/exabgp.in") + self.run("[ -p /var/run/exabgp.out ] || mkfifo /var/run/exabgp.out") + self.run("chown exabgp:exabgp /var/run/exabgp.{in,out}") + self.run("chmod 600 /var/run/exabgp.{in,out}") + + log_dir = os.path.join(self.logdir, self.name) + self.run("chmod 777 {}".format(log_dir)) + + log_file = os.path.join(log_dir, "exabgp.log") - output = self.run(exacmd + " -e /etc/exabgp/exabgp.env /etc/exabgp/exabgp.cfg") + env_cmd = "env exabgp.log.level=INFO " + env_cmd += "exabgp.log.destination={} ".format(log_file) + + output = self.run( + env_cmd + exacmd + " -e /etc/exabgp/exabgp.env /etc/exabgp/exabgp.cfg " + ) if output is None or len(output) == 0: output = "<none>" @@ -1369,7 +1386,7 @@ def diagnose_env_linux(rundir): logger.info("LDPd tests will not run (missing mpls-iptunnel kernel module)") if not get_exabgp_cmd(): - logger.warning("Failed to find exabgp < 4") + logger.warning("Failed to find exabgp >= 4.2.11") logger.removeHandler(fhandler) fhandler.close() |