mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 06:03:10 +00:00
bgp_l3vpn_to_bgp_vrf: catch linux setup failures
Signed-off-by: Lou Berger <lberger@labn.net>
This commit is contained in:
parent
d1f82d97db
commit
f2f902aca8
@ -93,6 +93,8 @@ CWD = os.path.dirname(os.path.realpath(__file__))
|
|||||||
# test name based on directory
|
# test name based on directory
|
||||||
TEST = os.path.basename(CWD)
|
TEST = os.path.basename(CWD)
|
||||||
|
|
||||||
|
InitSuccess = False
|
||||||
|
|
||||||
class ThisTestTopo(Topo):
|
class ThisTestTopo(Topo):
|
||||||
"Test topology builder"
|
"Test topology builder"
|
||||||
def build(self, *_args, **_opts):
|
def build(self, *_args, **_opts):
|
||||||
@ -136,13 +138,45 @@ class ThisTestTopo(Topo):
|
|||||||
switch[1].add_link(tgen.gears['r2'], nodeif='r2-eth2')
|
switch[1].add_link(tgen.gears['r2'], nodeif='r2-eth2')
|
||||||
switch[1].add_link(tgen.gears['r3'], nodeif='r3-eth1')
|
switch[1].add_link(tgen.gears['r3'], nodeif='r3-eth1')
|
||||||
|
|
||||||
def doCmd(tgen, rtr, cmd, checkstr = None):
|
class CustCmd():
|
||||||
output = tgen.net[rtr].cmd(cmd).strip()
|
def __init__(self):
|
||||||
if len(output):
|
self.resetCounts()
|
||||||
if checkstr != None:
|
|
||||||
return re.search(checkstr, output)
|
def doCmd(self, tgen, rtr, cmd, checkstr = None):
|
||||||
logger.info('command output: ' + output)
|
output = tgen.net[rtr].cmd(cmd).strip()
|
||||||
return None
|
if len(output):
|
||||||
|
self.output += 1
|
||||||
|
if checkstr != None:
|
||||||
|
ret = re.search(checkstr, output)
|
||||||
|
if ret == None:
|
||||||
|
self.nomatch += 1
|
||||||
|
else:
|
||||||
|
self.match += 1
|
||||||
|
return ret
|
||||||
|
logger.info('command: {} {}'.format(rtr, cmd))
|
||||||
|
logger.info('output: ' + output)
|
||||||
|
self.none += 1
|
||||||
|
return None
|
||||||
|
|
||||||
|
def resetCounts(self):
|
||||||
|
self.match = 0
|
||||||
|
self.nomatch = 0
|
||||||
|
self.output = 0
|
||||||
|
self.none = 0
|
||||||
|
|
||||||
|
def getMatch(self):
|
||||||
|
return self.match
|
||||||
|
|
||||||
|
def getNoMatch(self):
|
||||||
|
return self.nomatch
|
||||||
|
|
||||||
|
def getOutput(self):
|
||||||
|
return self.output
|
||||||
|
|
||||||
|
def getNone(self):
|
||||||
|
return self.none
|
||||||
|
|
||||||
|
cc = CustCmd()
|
||||||
|
|
||||||
def ltemplatePreRouterStartHook():
|
def ltemplatePreRouterStartHook():
|
||||||
krel = platform.release()
|
krel = platform.release()
|
||||||
@ -152,14 +186,16 @@ def ltemplatePreRouterStartHook():
|
|||||||
if tgen.hasmpls != True:
|
if tgen.hasmpls != True:
|
||||||
logger.info('MPLS not available, skipping setup')
|
logger.info('MPLS not available, skipping setup')
|
||||||
return
|
return
|
||||||
|
#collect/log info on iproute2
|
||||||
|
cc.doCmd(tgen, 'r2', 'apt-cache policy iproute2')
|
||||||
|
cc.doCmd(tgen, 'r2', 'yum info iproute2')
|
||||||
|
cc.doCmd(tgen, 'r2', 'yum info iproute')
|
||||||
|
|
||||||
|
cc.resetCounts()
|
||||||
#configure r2 mpls interfaces
|
#configure r2 mpls interfaces
|
||||||
intfs = ['lo', 'r2-eth0', 'r2-eth1', 'r2-eth2']
|
intfs = ['lo', 'r2-eth0', 'r2-eth1', 'r2-eth2']
|
||||||
for intf in intfs:
|
for intf in intfs:
|
||||||
doCmd(tgen, 'r2', 'echo 1 > /proc/sys/net/mpls/conf/{}/input'.format(intf))
|
cc.doCmd(tgen, 'r2', 'echo 1 > /proc/sys/net/mpls/conf/{}/input'.format(intf))
|
||||||
#collect/log info on iproute2
|
|
||||||
doCmd(tgen, 'r2', 'apt-cache policy iproute2')
|
|
||||||
doCmd(tgen, 'r2', 'yum info iproute2')
|
|
||||||
doCmd(tgen, 'r2', 'yum info iproute')
|
|
||||||
|
|
||||||
#configure cust1 VRFs & MPLS
|
#configure cust1 VRFs & MPLS
|
||||||
rtrs = ['r1', 'r3', 'r4']
|
rtrs = ['r1', 'r3', 'r4']
|
||||||
@ -170,11 +206,11 @@ def ltemplatePreRouterStartHook():
|
|||||||
for rtr in rtrs:
|
for rtr in rtrs:
|
||||||
router = tgen.gears[rtr]
|
router = tgen.gears[rtr]
|
||||||
for cmd in cmds:
|
for cmd in cmds:
|
||||||
doCmd(tgen, rtr, cmd)
|
cc.doCmd(tgen, rtr, cmd)
|
||||||
doCmd(tgen, rtr, 'ip link set dev {}-eth4 master cust1'.format(rtr))
|
cc.doCmd(tgen, rtr, 'ip link set dev {}-eth4 master cust1'.format(rtr))
|
||||||
intfs = ['cust1', 'lo', rtr+'-eth0', rtr+'-eth4']
|
intfs = ['cust1', 'lo', rtr+'-eth0', rtr+'-eth4']
|
||||||
for intf in intfs:
|
for intf in intfs:
|
||||||
doCmd(tgen, rtr, 'echo 1 > /proc/sys/net/mpls/conf/{}/input'.format(intf))
|
cc.doCmd(tgen, rtr, 'echo 1 > /proc/sys/net/mpls/conf/{}/input'.format(intf))
|
||||||
logger.info('setup {0} vrf cust1, {0}-eth4. enabled mpls input.'.format(rtr))
|
logger.info('setup {0} vrf cust1, {0}-eth4. enabled mpls input.'.format(rtr))
|
||||||
#configure cust2 VRFs & MPLS
|
#configure cust2 VRFs & MPLS
|
||||||
rtrs = ['r4']
|
rtrs = ['r4']
|
||||||
@ -184,12 +220,19 @@ def ltemplatePreRouterStartHook():
|
|||||||
'ip link set dev cust2 up']
|
'ip link set dev cust2 up']
|
||||||
for rtr in rtrs:
|
for rtr in rtrs:
|
||||||
for cmd in cmds:
|
for cmd in cmds:
|
||||||
doCmd(tgen, rtr, cmd)
|
cc.doCmd(tgen, rtr, cmd)
|
||||||
doCmd(tgen, rtr, 'ip link set dev {}-eth5 master cust2'.format(rtr))
|
cc.doCmd(tgen, rtr, 'ip link set dev {}-eth5 master cust2'.format(rtr))
|
||||||
intfs = ['cust2', rtr+'-eth5']
|
intfs = ['cust2', rtr+'-eth5']
|
||||||
for intf in intfs:
|
for intf in intfs:
|
||||||
doCmd(tgen, rtr, 'echo 1 > /proc/sys/net/mpls/conf/{}/input'.format(intf))
|
cc.doCmd(tgen, rtr, 'echo 1 > /proc/sys/net/mpls/conf/{}/input'.format(intf))
|
||||||
logger.info('setup {0} vrf cust2, {0}-eth5. enabled mpls input.'.format(rtr))
|
logger.info('setup {0} vrf cust2, {0}-eth5. enabled mpls input.'.format(rtr))
|
||||||
|
global InitSuccess
|
||||||
|
if cc.getOutput():
|
||||||
|
InitSuccess = False
|
||||||
|
logger.info('VRF config failed ({}), tests will be skipped'.format(cc.getOutput()))
|
||||||
|
else:
|
||||||
|
InitSuccess = True
|
||||||
|
logger.info('VRF config successful!')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
def ltemplatePostRouterStartHook():
|
def ltemplatePostRouterStartHook():
|
||||||
@ -205,6 +248,10 @@ def versionCheck(vstr, rname='r1', compstr='<',cli=False, kernel='4.9'):
|
|||||||
ret = 'MPLS not initialized'
|
ret = 'MPLS not initialized'
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
if InitSuccess != True:
|
||||||
|
ret = 'Test not successfully initialized'
|
||||||
|
return ret
|
||||||
|
|
||||||
ret = True
|
ret = True
|
||||||
try:
|
try:
|
||||||
if router.has_version(compstr, vstr):
|
if router.has_version(compstr, vstr):
|
||||||
|
Loading…
Reference in New Issue
Block a user