From: Martin Winter Date: Thu, 19 Jul 2018 00:41:24 +0000 (-0700) Subject: lib: Add support for staticd X-Git-Tag: frr-7.1-dev~151^2~60 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=a2a1134c77bd18fef600da136a4e357f805fc3e6;p=mirror%2Ffrr.git lib: Add support for staticd Signed-off-by: Martin Winter --- diff --git a/tests/topotests/lib/topogen.py b/tests/topotests/lib/topogen.py index 9e4132e8fb..52b3353f32 100644 --- a/tests/topotests/lib/topogen.py +++ b/tests/topotests/lib/topogen.py @@ -530,6 +530,7 @@ class TopoRouter(TopoGear): RD_PIM = 9 RD_EIGRP = 10 RD_NHRP = 11 + RD_STATIC = 12 RD = { RD_ZEBRA: 'zebra', RD_RIP: 'ripd', @@ -542,6 +543,7 @@ class TopoRouter(TopoGear): RD_LDP: 'ldpd', RD_EIGRP: 'eigrpd', RD_NHRP: 'nhrpd', + RD_STATIC: 'staticd', } def __init__(self, tgen, cls, name, **params): diff --git a/tests/topotests/lib/topotest.py b/tests/topotests/lib/topotest.py index 3114d47c9d..2d1c2b3c62 100644 --- a/tests/topotests/lib/topotest.py +++ b/tests/topotests/lib/topotest.py @@ -486,7 +486,7 @@ class Router(Node): self.routertype = 'frr' self.daemons = {'zebra': 0, 'ripd': 0, 'ripngd': 0, 'ospfd': 0, 'ospf6d': 0, 'isisd': 0, 'bgpd': 0, 'pimd': 0, - 'ldpd': 0, 'eigrpd': 0, 'nhrpd': 0} + 'ldpd': 0, 'eigrpd': 0, 'nhrpd': 0, 'staticd': 0} self.daemons_options = {'zebra': ''} self.reportCores = True self.version = None @@ -632,6 +632,18 @@ class Router(Node): self.waitOutput() self.cmd('chown %s:%s /etc/%s/%s.conf' % (self.routertype, self.routertype, self.routertype, daemon)) self.waitOutput() + if daemon == 'zebra': + # Add staticd with zebra - if it exists + staticd_path = os.path.join(self.daemondir, 'staticd') + if os.path.isfile(staticd_path): + self.daemons['staticd'] = 1 + self.daemons_options['staticd'] = None + self.cmd('touch /etc/%s/%s.conf' % (self.routertype, 'staticd')) + self.waitOutput() + self.cmd('chmod 640 /etc/%s/%s.conf' % (self.routertype, 'staticd')) + self.waitOutput() + self.cmd('chown %s:%s /etc/%s/%s.conf' % (self.routertype, self.routertype, self.routertype, 'staticd')) + self.waitOutput() else: logger.info('No daemon {} known'.format(daemon)) # print "Daemons after:", self.daemons @@ -705,15 +717,24 @@ class Router(Node): self.waitOutput() logger.debug('{}: {} zebra started'.format(self, self.routertype)) sleep(1, '{}: waiting for zebra to start'.format(self.name)) - # Fix Link-Local Addresses + # Start staticd next if required + if self.daemons['staticd'] == 1: + staticd_path = os.path.join(self.daemondir, 'staticd') + staticd_option = self.daemons_options['staticd'] + self.cmd('{0} {1} > staticd.out 2> staticd.err &'.format( + staticd_path, staticd_option, self.logdir, self.name + )) + self.waitOutput() + logger.debug('{}: {} staticd started'.format(self, self.routertype)) + sleep(1, '{}: waiting for staticd to start'.format(self.name)) + # Fix Link-Local Addresses # Somehow (on Mininet only), Zebra removes the IPv6 Link-Local addresses on start. Fix this self.cmd('for i in `ls /sys/class/net/` ; do mac=`cat /sys/class/net/$i/address`; IFS=\':\'; set $mac; unset IFS; ip address add dev $i scope link fe80::$(printf %02x $((0x$1 ^ 2)))$2:${3}ff:fe$4:$5$6/64; done') # Now start all the other daemons for daemon in self.daemons: # Skip disabled daemons and zebra - if self.daemons[daemon] == 0 or daemon == 'zebra': + if self.daemons[daemon] == 0 or daemon == 'zebra' or daemon == 'staticd': continue - daemon_path = os.path.join(self.daemondir, daemon) self.cmd('{0} > {3}.out 2> {3}.err &'.format( daemon_path, self.logdir, self.name, daemon