diff options
| author | Jafar Al-Gharaibeh <jafar@atcorp.com> | 2022-02-26 19:59:48 -0600 |
|---|---|---|
| committer | Jafar Al-Gharaibeh <jafar@atcorp.com> | 2022-02-27 20:53:18 -0600 |
| commit | a4b4bb5077c3c11cc13f43ef15dd3a3e7251a54c (patch) | |
| tree | f517fb701d59b9b412b75386aed39ddf55a4f357 /tests/topotests/lib/topotest.py | |
| parent | ae45a630222b53b02d8fc7cd84bb24d8744cd09c (diff) | |
topotests: add support for frr.conf as a unified config
This PR adds support for configuring topotest routers using a single file.
instead of:
```
router.load_config(
TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
)
router.load_config(
TopoRouter.RD_OSPF, os.path.join(CWD, "{}/ospfd.conf".format(rname))
)
router.load_config(
TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname))
)
```
you can now do:
```
router.load_frr_config(
os.path.join(CWD, "{}/frr.conf".format(rname)),
[TopoRouter.RD_ZEBRA, TopoRouter.RD_OSPF, TopoRouter.RD_BGP]
)
```
or just:
```
router.load_frr_config(os.path.join(CWD, "{}/frr.conf".format(rname)))
```
In this latter case, the daemons list will be inferred from frr.conf file.
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
Diffstat (limited to 'tests/topotests/lib/topotest.py')
| -rw-r--r-- | tests/topotests/lib/topotest.py | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/tests/topotests/lib/topotest.py b/tests/topotests/lib/topotest.py index d3438f67e5..4e5fe4c90b 100644 --- a/tests/topotests/lib/topotest.py +++ b/tests/topotests/lib/topotest.py @@ -1319,6 +1319,7 @@ class Router(Node): self.daemondir = None self.hasmpls = False self.routertype = "frr" + self.unified_config = None self.daemons = { "zebra": 0, "ripd": 0, @@ -1521,21 +1522,28 @@ class Router(Node): ) # print "Daemons before:", self.daemons - if daemon in self.daemons.keys(): - self.daemons[daemon] = 1 + if daemon in self.daemons.keys() or daemon == "frr": + if daemon == "frr": + self.unified_config = 1 + else: + self.daemons[daemon] = 1 if param is not None: self.daemons_options[daemon] = param conf_file = "/etc/{}/{}.conf".format(self.routertype, daemon) if source is None or not os.path.exists(source): - self.cmd_raises("rm -f " + conf_file) - self.cmd_raises("touch " + conf_file) + if daemon == "frr" or not self.unified_config: + self.cmd_raises("rm -f " + conf_file) + self.cmd_raises("touch " + conf_file) else: self.cmd_raises("cp {} {}".format(source, conf_file)) - self.cmd_raises("chown {0}:{0} {1}".format(self.routertype, conf_file)) - self.cmd_raises("chmod 664 {}".format(conf_file)) + + if not self.unified_config or daemon == "frr": + self.cmd_raises("chown {0}:{0} {1}".format(self.routertype, conf_file)) + self.cmd_raises("chmod 664 {}".format(conf_file)) + if (daemon == "snmpd") and (self.routertype == "frr"): # /etc/snmp is private mount now - self.cmd('echo "agentXSocket /etc/frr/agentx" > /etc/snmp/frr.conf') + self.cmd('echo "agentXSocket /etc/frr/agentx" >> /etc/snmp/frr.conf') self.cmd('echo "mibs +ALL" > /etc/snmp/snmp.conf') if (daemon == "zebra") and (self.daemons["staticd"] == 0): @@ -1557,11 +1565,18 @@ class Router(Node): return self.run_in_window(cmd, title) def startRouter(self, tgen=None): - # Disable integrated-vtysh-config - self.cmd( - 'echo "no service integrated-vtysh-config" >> /etc/%s/vtysh.conf' - % self.routertype - ) + if self.unified_config: + self.cmd( + 'echo "service integrated-vtysh-config" >> /etc/%s/vtysh.conf' + % self.routertype + ) + else: + # Disable integrated-vtysh-config + self.cmd( + 'echo "no service integrated-vtysh-config" >> /etc/%s/vtysh.conf' + % self.routertype + ) + self.cmd( "chown %s:%svty /etc/%s/vtysh.conf" % (self.routertype, self.routertype, self.routertype) @@ -1633,6 +1648,9 @@ class Router(Node): if "all" in vtysh_routers or self.name in vtysh_routers: self.run_in_window("vtysh", title="vt-%s" % self.name) + if self.unified_config: + self.cmd("vtysh -f /etc/frr/frr.conf") + return status def getStdErr(self, daemon): |
