Skip to content

Commit

Permalink
patch topotest invalid frr user and snmp
Browse files Browse the repository at this point in the history
  • Loading branch information
pguibert6WIND committed Mar 22, 2024
1 parent 9f9c765 commit d70d4ea
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion tests/topotests/bgp_snmp_mplsl3vpn/ce1/snmpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ rouser frr
master agentx

agentXSocket /etc/frr/agentx
agentXPerms 777 755 root frr
agentXPerms 777 755 root root
2 changes: 1 addition & 1 deletion tests/topotests/bgp_snmp_mplsl3vpn/ce2/snmpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ rouser frr
master agentx

agentXSocket /etc/frr/agentx
agentXPerms 777 755 root frr
agentXPerms 777 755 root root
2 changes: 1 addition & 1 deletion tests/topotests/bgp_snmp_mplsl3vpn/ce3/snmpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ rouser frr
master agentx

agentXSocket /etc/frr/agentx
agentXPerms 777 755 root frr
agentXPerms 777 755 root root
2 changes: 1 addition & 1 deletion tests/topotests/bgp_snmp_mplsl3vpn/ce4/snmpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ rouser frr
master agentx

agentXSocket /etc/frr/agentx
agentXPerms 777 755 root frr
agentXPerms 777 755 root root
2 changes: 1 addition & 1 deletion tests/topotests/bgp_snmp_mplsl3vpn/r1/snmpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ master agentx
noRangeCheck yes

agentXSocket /etc/frr/agentx
agentXPerms 777 755 root frr
agentXPerms 777 755 root root
3 changes: 2 additions & 1 deletion tests/topotests/bgp_snmp_mplsl3vpn/r2/snmpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ rouser frr
master agentx

agentXSocket /etc/frr/agentx
agentXPerms 777 755 root frr
agentXPerms 777 755 root root

2 changes: 1 addition & 1 deletion tests/topotests/bgp_snmp_mplsl3vpn/r3/snmpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ rouser frr
master agentx

agentXSocket /etc/frr/agentx
agentXPerms 777 755 root frr
agentXPerms 777 755 root root
2 changes: 1 addition & 1 deletion tests/topotests/bgp_snmp_mplsl3vpn/r4/snmpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ rouser frr
master agentx

agentXSocket /etc/frr/agentx
agentXPerms 777 755 root frr
agentXPerms 777 755 root root
6 changes: 3 additions & 3 deletions tests/topotests/lib/snmptest.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ def _parse_multiline(self, snmp_output):
return out_dict, out_list

def get(self, oid):
cmd = "snmpget {0} {1}".format(self._snmp_config(), oid)
cmd = "snmpget {0} {1} 2> /dev/null".format(self._snmp_config(), oid)

result = self.router.cmd(cmd)
if "not found" in result:
return None
return self._get_snmp_value(result)

def get_next(self, oid):
cmd = "snmpgetnext {0} {1}".format(self._snmp_config(), oid)
cmd = "snmpgetnext {0} {1} 2> /dev/null".format(self._snmp_config(), oid)

result = self.router.cmd(cmd)
print("get_next: {}".format(result))
Expand All @@ -102,7 +102,7 @@ def get_next(self, oid):
return self._get_snmp_value(result)

def walk(self, oid):
cmd = "snmpwalk {0} {1}".format(self._snmp_config(), oid)
cmd = "snmpwalk {0} {1} 2> /dev/null".format(self._snmp_config(), oid)

result = self.router.cmd(cmd)
return self._parse_multiline(result)
Expand Down
16 changes: 8 additions & 8 deletions tests/topotests/lib/topotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,7 @@ def config_host(self, **params):
self.routertype = params.get("routertype")

# Set ownership of config files
self.cmd("chown {0}:{0}vty /etc/{0}".format(self.routertype))
self.cmd("chown root:root /etc/{0}".format(self.routertype))

def terminate(self):
# Stop running FRR daemons
Expand Down Expand Up @@ -1644,7 +1644,7 @@ def loadConf(self, daemon, source=None, param=None):
self.cmd_raises("rm -f " + conf_file)
self.cmd_raises("touch " + conf_file)
self.cmd_raises(
"chown {0}:{0} {1}".format(self.routertype, conf_file)
"chown root:root {0}".format(conf_file)
)
self.cmd_raises("chmod 664 {}".format(conf_file))
elif source:
Expand All @@ -1659,15 +1659,15 @@ def loadConf(self, daemon, source=None, param=None):
)
self.cmd_raises("cp {} {}".format(source, conf_file_mgmt))
self.cmd_raises(
"chown {0}:{0} {1}".format(self.routertype, conf_file_mgmt)
"chown root:root {0}".format(conf_file_mgmt)
)
self.cmd_raises("chmod 664 {}".format(conf_file_mgmt))

logger.debug(
"copying '%s' as '%s' on '%s'", source, conf_file, self.name
)
self.cmd_raises("cp {} {}".format(source, conf_file))
self.cmd_raises("chown {0}:{0} {1}".format(self.routertype, conf_file))
self.cmd_raises("chown root:root {0}".format(conf_file))
self.cmd_raises("chmod 664 {}".format(conf_file))

if (daemon == "snmpd") and (self.routertype == "frr"):
Expand Down Expand Up @@ -1713,8 +1713,8 @@ def startRouter(self, tgen=None):
)

self.cmd(
"chown %s:%svty /etc/%s/vtysh.conf"
% (self.routertype, self.routertype, self.routertype)
"chown root:root /etc/%s/vtysh.conf"
% (self.routertype)
)
# TODO remove the following lines after all tests are migrated to Topogen.
# Try to find relevant old logfiles in /tmp and delete them
Expand Down Expand Up @@ -1829,7 +1829,7 @@ def startRouterDaemons(self, daemons=None, tgen=None):

# Starts actual daemons without init (ie restart)
# cd to per node directory
self.cmd("install -m 775 -o frr -g frr -d {}/{}".format(self.logdir, self.name))
self.cmd("install -m 775 -o root -g root -d {}/{}".format(self.logdir, self.name))
self.set_cwd("{}/{}".format(self.logdir, self.name))
self.cmd("umask 000")

Expand Down Expand Up @@ -2248,7 +2248,7 @@ def emacs_gdb_ready():
)

# Update the permissions on the log files
self.cmd("chown frr:frr -R {}/{}".format(self.logdir, self.name))
self.cmd("chown root:root -R {}/{}".format(self.logdir, self.name))
self.cmd("chmod ug+rwX,o+r -R {}/{}".format(self.logdir, self.name))

if "frr" in logd_options:
Expand Down

0 comments on commit d70d4ea

Please sign in to comment.