mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 09:20:25 +00:00
tests: API to launch snmpd in a topotest scenario
Prepare the infrastructure to allow configuring and launching an SNMP daemon as part of testing scenario. Signed-off-by: Babis Chalios <babis@voltanet.io> Signed-off-by: Pat Ruddy Chalios <pat@voltanet.io>
This commit is contained in:
parent
b96138fbf0
commit
92be50e63e
@ -555,6 +555,7 @@ class TopoRouter(TopoGear):
|
|||||||
RD_BABEL = 15
|
RD_BABEL = 15
|
||||||
RD_PBRD = 16
|
RD_PBRD = 16
|
||||||
RD_PATH = 17
|
RD_PATH = 17
|
||||||
|
RD_SNMP = 18
|
||||||
RD = {
|
RD = {
|
||||||
RD_ZEBRA: "zebra",
|
RD_ZEBRA: "zebra",
|
||||||
RD_RIP: "ripd",
|
RD_RIP: "ripd",
|
||||||
@ -572,7 +573,8 @@ class TopoRouter(TopoGear):
|
|||||||
RD_SHARP: "sharpd",
|
RD_SHARP: "sharpd",
|
||||||
RD_BABEL: "babeld",
|
RD_BABEL: "babeld",
|
||||||
RD_PBRD: "pbrd",
|
RD_PBRD: "pbrd",
|
||||||
RD_PATH: 'pathd',
|
RD_PATH: "pathd",
|
||||||
|
RD_SNMP: "snmpd",
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, tgen, cls, name, **params):
|
def __init__(self, tgen, cls, name, **params):
|
||||||
@ -657,7 +659,7 @@ class TopoRouter(TopoGear):
|
|||||||
Possible daemon values are: TopoRouter.RD_ZEBRA, TopoRouter.RD_RIP,
|
Possible daemon values are: TopoRouter.RD_ZEBRA, TopoRouter.RD_RIP,
|
||||||
TopoRouter.RD_RIPNG, TopoRouter.RD_OSPF, TopoRouter.RD_OSPF6,
|
TopoRouter.RD_RIPNG, TopoRouter.RD_OSPF, TopoRouter.RD_OSPF6,
|
||||||
TopoRouter.RD_ISIS, TopoRouter.RD_BGP, TopoRouter.RD_LDP,
|
TopoRouter.RD_ISIS, TopoRouter.RD_BGP, TopoRouter.RD_LDP,
|
||||||
TopoRouter.RD_PIM, TopoRouter.RD_PBR.
|
TopoRouter.RD_PIM, TopoRouter.RD_PBR, TopoRouter.RD_SNMP.
|
||||||
"""
|
"""
|
||||||
daemonstr = self.RD.get(daemon)
|
daemonstr = self.RD.get(daemon)
|
||||||
self.logger.info('loading "{}" configuration: {}'.format(daemonstr, source))
|
self.logger.info('loading "{}" configuration: {}'.format(daemonstr, source))
|
||||||
|
@ -1105,7 +1105,8 @@ class Router(Node):
|
|||||||
"sharpd": 0,
|
"sharpd": 0,
|
||||||
"babeld": 0,
|
"babeld": 0,
|
||||||
"pbrd": 0,
|
"pbrd": 0,
|
||||||
'pathd': 0
|
"pathd": 0,
|
||||||
|
"snmpd": 0,
|
||||||
}
|
}
|
||||||
self.daemons_options = {"zebra": ""}
|
self.daemons_options = {"zebra": ""}
|
||||||
self.reportCores = True
|
self.reportCores = True
|
||||||
@ -1289,6 +1290,8 @@ class Router(Node):
|
|||||||
% (self.routertype, self.routertype, self.routertype, daemon)
|
% (self.routertype, self.routertype, self.routertype, daemon)
|
||||||
)
|
)
|
||||||
self.waitOutput()
|
self.waitOutput()
|
||||||
|
if (daemon == "snmpd") and (self.routertype == "frr"):
|
||||||
|
self.cmd('echo "agentXSocket /etc/frr/agentx" > /etc/snmp/frr.conf')
|
||||||
if (daemon == "zebra") and (self.daemons["staticd"] == 0):
|
if (daemon == "zebra") and (self.daemons["staticd"] == 0):
|
||||||
# Add staticd with zebra - if it exists
|
# Add staticd with zebra - if it exists
|
||||||
staticd_path = os.path.join(self.daemondir, "staticd")
|
staticd_path = os.path.join(self.daemondir, "staticd")
|
||||||
@ -1445,6 +1448,20 @@ class Router(Node):
|
|||||||
while "staticd" in daemons_list:
|
while "staticd" in daemons_list:
|
||||||
daemons_list.remove("staticd")
|
daemons_list.remove("staticd")
|
||||||
|
|
||||||
|
if "snmpd" in daemons_list:
|
||||||
|
snmpd_path = "/usr/sbin/snmpd"
|
||||||
|
snmpd_option = self.daemons_options["snmpd"]
|
||||||
|
self.cmd(
|
||||||
|
"{0} {1} -C -c /etc/frr/snmpd.conf -p /var/run/{2}/snmpd.pid -x /etc/frr/agentx > snmpd.out 2> snmpd.err".format(
|
||||||
|
snmpd_path, snmpd_option, self.routertype
|
||||||
|
)
|
||||||
|
)
|
||||||
|
logger.info("{}: {} snmpd started".format(self, self.routertype))
|
||||||
|
|
||||||
|
# Remove `snmpd` so we don't attempt to start it again.
|
||||||
|
while "snmpd" in daemons_list:
|
||||||
|
daemons_list.remove("snmpd")
|
||||||
|
|
||||||
# Fix Link-Local Addresses
|
# Fix Link-Local Addresses
|
||||||
# Somehow (on Mininet only), Zebra removes the IPv6 Link-Local addresses on start. Fix this
|
# Somehow (on Mininet only), Zebra removes the IPv6 Link-Local addresses on start. Fix this
|
||||||
self.cmd(
|
self.cmd(
|
||||||
|
Loading…
Reference in New Issue
Block a user