def RequireVpnRoutes(self, target, title, wantroutes, debug=0): import json logstr = "RequireVpnRoutes " + str(wantroutes) #non json form for humans luCommand(target, 'vtysh -c "show bgp ipv4 vpn"', '.', 'None', 'Get VPN RIB (non-json)') ret = luCommand(target, 'vtysh -c "show bgp ipv4 vpn json"', '.*', 'None', 'Get VPN RIB (json)') if re.search(r'^\s*$', ret): # degenerate case: empty json means no routes if len(wantroutes) > 0: luResult(target, False, title, logstr) return luResult(target, True, title, logstr) rib = json.loads(ret) rds = rib['routes']['routeDistinguishers'] for want in wantroutes: found = 0 if debug: print "want rd " + want['rd'] for rd in rds.iterkeys(): if rd != want['rd']: continue if debug: print "found rd " + rd table = rds[rd] if self.routes_include_wanted(table, want, debug): found = 1 break if not found: luResult(target, False, title, logstr) return luResult(target, True, title, logstr)
def RequireUnicastRoutes(self, target, afi, vrf, title, wantroutes, debug=0): logstr = "RequireVpnRoutes %s" % str(wantroutes) vrfstr = "" if vrf != "": vrfstr = "vrf %s" % (vrf) if (afi != "ipv4") and (afi != "ipv6"): self.log("ERROR invalid afi") cmdstr = "show bgp %s %s unicast" % (vrfstr, afi) # non json form for humans cmd = 'vtysh -c "%s"' % cmdstr luCommand(target, cmd, ".", "None", "Get %s %s RIB (non-json)" % (vrfstr, afi)) cmd = 'vtysh -c "%s json"' % cmdstr ret = luCommand(target, cmd, ".*", "None", "Get %s %s RIB (json)" % (vrfstr, afi)) if re.search(r"^\s*$", ret): # degenerate case: empty json means no routes if len(wantroutes) > 0: luResult(target, False, title, logstr) return luResult(target, True, title, logstr) rib = json.loads(ret) try: table = rib["routes"] # KeyError: 'routes' probably means missing/bad VRF except KeyError as err: if vrf != "": errstr = "-script ERROR: check if wrong vrf (%s)" % (vrf) else: errstr = "-script ERROR: check if vrf missing" luResult(target, False, title + errstr, logstr) return #if debug: # self.log("table=%s" % table) for want in wantroutes: if debug: self.log("want=%s" % want) if not self.routes_include_wanted(table, want, debug): luResult(target, False, title, logstr) return luResult(target, True, title, logstr)
def RequireUnicastRoutes(self, target, afi, vrf, title, wantroutes, debug=0): vrfstr = '' if vrf != '': vrfstr = 'vrf %s' % (vrf) if (afi != 'ipv4') and (afi != 'ipv6'): print "ERROR invalid afi" str = 'show bgp %s %s unicast json' % (vrfstr, afi) cmd = 'vtysh -c "%s"' % str ret = luCommand(target, cmd, '.*', 'None', 'Get %s %s RIB' % (vrfstr, afi)) if re.search(r'^\s*$', ret): # degenerate case: empty json means no routes if len(wantroutes) > 0: luResult(target, False, title) return luResult(target, True, title) rib = json.loads(ret) table = rib['routes'] for want in wantroutes: if not self.routes_include_wanted(table, want, debug): luResult(target, False, title) return luResult(target, True, title)
def RequireVpnRoutes(self, target, title, wantroutes, debug=0): import json logstr = "RequireVpnRoutes " + str(wantroutes) # non json form for humans luCommand( target, 'vtysh -c "show bgp ipv4 vpn"', ".", "None", "Get VPN RIB (non-json)", ) ret = luCommand( target, 'vtysh -c "show bgp ipv4 vpn json"', ".*", "None", "Get VPN RIB (json)", ) if re.search(r"^\s*$", ret): # degenerate case: empty json means no routes if len(wantroutes) > 0: luResult(target, False, title, logstr) return luResult(target, True, title, logstr) rib = json.loads(ret) rds = rib["routes"]["routeDistinguishers"] for want in wantroutes: found = 0 if debug: self.log("want rd %s" % want["rd"]) for rd in rds.iterkeys(): if rd != want["rd"]: continue if debug: self.log("found rd %s" % rd) table = rds[rd] if self.routes_include_wanted(table, want, debug): found = 1 break if not found: luResult(target, False, title, logstr) return luResult(target, True, title, logstr)
def RequireUnicastRoutes(self,target,afi,vrf,title,wantroutes,debug=0): logstr = "RequireVpnRoutes " + str(wantroutes) vrfstr = '' if vrf != '': vrfstr = 'vrf %s' % (vrf) if (afi != 'ipv4') and (afi != 'ipv6'): print "ERROR invalid afi"; cmdstr = 'show bgp %s %s unicast' % (vrfstr, afi) #non json form for humans cmd = 'vtysh -c "%s"' % cmdstr luCommand(target,cmd,'.','None','Get %s %s RIB (non-json)' % (vrfstr, afi)) cmd = 'vtysh -c "%s json"' % cmdstr ret = luCommand(target,cmd,'.*','None','Get %s %s RIB (json)' % (vrfstr, afi)) if re.search(r'^\s*$', ret): # degenerate case: empty json means no routes if len(wantroutes) > 0: luResult(target, False, title, logstr) return luResult(target, True, title, logstr) rib = json.loads(ret) try: table = rib['routes'] # KeyError: 'routes' probably means missing/bad VRF except KeyError as err: if vrf != '': errstr = '-script ERROR: check if wrong vrf (%s)' % (vrf) else: errstr = '-script ERROR: check if vrf missing' luResult(target, False, title + errstr, logstr) return for want in wantroutes: if not self.routes_include_wanted(table,want,debug): luResult(target, False, title, logstr) return luResult(target, True, title, logstr)
from lutil import luCommand luCommand('r1', 'vtysh -c "add vrf r1-cust1 prefix 99.0.0.1/32"', '.', 'none', 'IP Address') luCommand('r3', 'vtysh -c "add vrf r3-cust1 prefix 99.0.0.2/32"', '.', 'none', 'IP Address') luCommand('r4', 'vtysh -c "add vrf r4-cust1 prefix 99.0.0.3/32"', '.', 'none', 'IP Address') luCommand('r1', 'vtysh -c "show vnc registrations local"', '99.0.0.1', 'pass', 'Local Registration') luCommand('r3', 'vtysh -c "show vnc registrations local"', '99.0.0.2', 'pass', 'Local Registration') luCommand('r4', 'vtysh -c "show vnc registrations local"', '99.0.0.3', 'pass', 'Local Registration') luCommand('r1', 'vtysh -c "show vnc registrations remote"', '4 out of 4', 'wait', 'Remote Registration', 10) luCommand('r3', 'vtysh -c "show vnc registrations remote"', '6 out of 6', 'wait', 'Remote Registration', 10) luCommand('r4', 'vtysh -c "show vnc registrations remote"', '4 out of 4', 'wait', 'Remote Registration', 10) luCommand('r1', 'vtysh -c "show vnc registrations"', '.', 'none') luCommand('r3', 'vtysh -c "show vnc registrations"', '.', 'none') luCommand('r4', 'vtysh -c "show vnc registrations"', '.', 'none')
from lutil import luCommand ret = luCommand('ce1', 'vtysh -c "show ip route" | grep -c \\ 10\\.\\*/32','(.*)','pass', 'Looking for sharp routes') found = luLast() if ret != False and found != None: num = int(found.group()) luCommand('ce3', 'vtysh -c "show bgp sum"', '.', 'pass', 'See %s sharp routes' % num) if num > 0: wait = num/500 luCommand('ce1', 'vtysh -c "sharp remove routes 10.0.0.0 {}"'.format(num),'.','none','Removing {} routes'.format(num)) luCommand('ce2', 'vtysh -c "sharp remove routes 10.0.0.0 {}"'.format(num),'.','none','Removing {} routes'.format(num)) rtrs = ['ce1', 'ce2', 'ce3'] for rtr in rtrs: luCommand(rtr, 'vtysh -c "show bgp ipv4 uni" | grep -c 10\\.\\*/32','^0$', 'wait', 'BGP routes removed', wait) for rtr in rtrs: luCommand(rtr, 'ip route show | grep -c \\^10\\.','^0$', 'wait', 'Linux routes removed', wait) rtrs = ['r1', 'r3', 'r4'] for rtr in rtrs: luCommand(rtr, 'ip route show vrf {}-cust1 | grep -c \\^10\\.'.format(rtr),'^0$','wait','VRF route removed',wait) #done
from lutil import luCommand rtrs = ["ce1", "ce2", "ce3", "r1", "r2", "r3", "r4"] for rtr in rtrs: ret = luCommand( rtr, 'vtysh -c "show bgp neigh"', "Notification received .([A-Za-z0-9/ ]*)", "none", "collect neighbor stats", ) found = luLast() if ret != False and found != None: val = found.group(1) ret = luCommand( rtr, 'vtysh -c "show bgp neigh"', "Notification received", "fail", "Notify RXed! {}".format(val), ) # done
from lutil import luCommand ret = luCommand('ce1', 'vtysh -c "show ip route" | grep -c \\ 10\\.\\*/32', '(.*)', 'pass', 'Looking for sharp routes') found = luLast() if ret != False and found != None: num = int(found.group()) luCommand('ce3', 'vtysh -c "show bgp sum"', '.', 'pass', 'See %s sharp routes' % num) if num > 0: rtrs = ['ce1', 'ce2', 'ce3'] for rtr in rtrs: luCommand(rtr, 'vtysh -c "show bgp ipv4 uni" | grep Display', '.', 'none', 'BGP routes pre remove') luCommand(rtr, 'ip route show | cat -n | tail', '.', 'none', 'Linux routes pre remove') wait = 2 * num / 500 luCommand('ce1', 'vtysh -c "sharp remove routes 10.0.0.0 {}"'.format(num), '.', 'none', 'Removing {} routes'.format(num)) luCommand('ce2', 'vtysh -c "sharp remove routes 10.0.0.0 {}"'.format(num), '.', 'none', 'Removing {} routes'.format(num)) for rtr in rtrs: luCommand(rtr, 'vtysh -c "show bgp ipv4 uni" | grep Display', ' 10 route', 'wait', 'BGP routes removed', wait) luCommand(rtr, 'vtysh -c "show bgp ipv4 uni"', '.', 'none', 'BGP routes post remove') for rtr in rtrs: luCommand(rtr, 'ip route show | grep -c \\^10\\.', '^0$', 'wait', 'Linux routes removed', wait) luCommand(rtr, 'ip route show', '.', 'none',
from lutil import luCommand rtrs = ['ce1', 'ce2', 'ce3', 'r1', 'r2', 'r3', 'r4'] for rtr in rtrs: ret = luCommand(rtr, 'vtysh -c "show bgp neigh"', 'Notification received .([A-Za-z0-9/ ]*)', 'none', 'collect neighbor stats') found = luLast() if ret != False and found != None: val = found.group(1) ret = luCommand(rtr, 'vtysh -c "show bgp neigh"', 'Notification received', 'fail', 'Notify RXed! {}'.format(val)) #done
from lutil import luCommand luCommand('r2', 'vtysh -c "show bgp summary"', ' 00:0.* 00:0.* 00:0', 'wait', 'Core adjacencies up', 90) luCommand('r1', 'vtysh -c "show bgp summary"', ' 00:0', 'pass', 'Core adjacencies up') luCommand('r3', 'vtysh -c "show bgp summary"', ' 00:0', 'pass', 'Core adjacencies up') luCommand('r4', 'vtysh -c "show bgp summary"', ' 00:0', 'pass', 'Core adjacencies up') luCommand('ce1', 'vtysh -c "show bgp summary"', ' 00:0', 'wait', 'Adjacencies up', 90) luCommand('ce2', 'vtysh -c "show bgp summary"', ' 00:0', 'wait', 'Adjacencies up') luCommand('ce3', 'vtysh -c "show bgp summary"', ' 00:0', 'wait', 'Adjacencies up') luCommand('r1', 'vtysh -c "show bgp vrf all summary"', ' 00:0.* 00:0', 'pass', 'All adjacencies up') luCommand('r3', 'vtysh -c "show bgp vrf all summary"', ' 00:0.* 00:0', 'pass', 'All adjacencies up') luCommand('r4', 'vtysh -c "show bgp vrf all summary"', ' 00:0.* 00:0', 'pass', 'All adjacencies up')
from lutil import luCommand luCommand('r1', 'vtysh -c "clear vrf r1-cust1 prefix 99.0.0.1/32"', '.', 'none', 'Cleared VRF route') luCommand('r3', 'vtysh -c "clear vrf r3-cust1 prefix 99.0.0.2/32"', '.', 'none', 'Cleared VRF route') luCommand('r4', 'vtysh -c "clear vrf r3-cust1 prefix 99.0.0.3/32"', '.', 'none', 'Cleared VRF route') luCommand('r1', 'vtysh -c "show vnc registrations local"', '99.0.0.1', 'fail', 'Local Registration cleared') luCommand('r3', 'vtysh -c "show vnc registrations local"', '99.0.0.2', 'fail', 'Local Registration cleared') luCommand('r4', 'vtysh -c "show vnc registrations local"', '99.0.0.3', 'fail', 'Local Registration cleared') luCommand('r1', 'vtysh -c "show bgp ipv4 uni"', '2 routes and 2', 'wait', 'Unicast SAFI updated', 10) luCommand('r2', 'vtysh -c "show bgp ipv4 uni"', 'No BGP prefixes displayed', 'pass', 'Unicast SAFI') luCommand('r3', 'vtysh -c "show bgp ipv4 uni"', '2 routes and 2', 'wait', 'Unicast SAFI updated', 10) luCommand('r4', 'vtysh -c "show bgp ipv4 uni"', '2 routes and 2', 'wait', 'Unicast SAFI updated', 10) luCommand('ce1', 'vtysh -c "show bgp ipv4 uni"', '2 routes and 2', 'wait', 'Local and remote routes', 10) luCommand('ce2', 'vtysh -c "show bgp ipv4 uni"', '2 routes and 2', 'wait', 'Local and remote routes', 10) luCommand('ce3', 'vtysh -c "show bgp ipv4 uni"', '2 routes and 2', 'wait', 'Local and remote routes', 10) luCommand('r1', 'vtysh -c "show vnc registrations remote"', 'Prefix ', 'fail', 'Remote Registration cleared') luCommand('r3', 'vtysh -c "show vnc registrations remote"', 'Prefix ', 'fail', 'Remote Registration cleared')
{'p':'99.0.0.3/32', 'n':'192.168.1.2'}, ] bgpribRequireUnicastRoutes('r4','ipv4','r4-cust1','Customer 1 routes in r4 vrf',want_r4_cust1_routes) want_r4_cust2_routes = [ {'p':'5.4.2.0/24', 'n':'99.0.0.4'}, {'p':'5.4.3.0/24', 'n':'99.0.0.4'}, {'p':'99.0.0.4/32', 'n':'192.168.2.2'}, ] bgpribRequireUnicastRoutes('r4','ipv4','r4-cust2','Customer 2 routes in r4 vrf',want_r4_cust2_routes) ######################################################################## # PE routers: core unicast routes are empty ######################################################################## luCommand('r1','vtysh -c "show bgp ipv4 uni"','No BGP prefixes displayed','pass','Core Unicast SAFI clean') luCommand('r2','vtysh -c "show bgp ipv4 uni"','No BGP prefixes displayed','pass','Core Unicast SAFI clean') luCommand('r3','vtysh -c "show bgp ipv4 uni"','No BGP prefixes displayed','pass','Core Unicast SAFI clean') luCommand('r4','vtysh -c "show bgp ipv4 uni"','No BGP prefixes displayed','pass','Core Unicast SAFI clean') ######################################################################## # PE routers: local ce-originated routes are leaked to vpn ######################################################################## # nhzero is for the new code that sets nh of locally-leaked routes to 0 #nhzero = 1 nhzero = 0 if nhzero: luCommand('r1','vtysh -c "show bgp ipv4 vpn"', 'Distinguisher: *10:1.*5.1.0.0/24 *0.0.0.0 .*5.1.1.0/24 *0.0.0.0 .*99.0.0.1/32 *0.0.0.0 ',
from lutil import luCommand holddownFactorSet = luCommand('r1','vtysh -c "show running"','rfp holddown-factor','none','Holddown factor set') luCommand('r1','vtysh -c "show vnc registrations"','.','none') luCommand('r3','vtysh -c "show vnc registrations"','.','none') luCommand('r4','vtysh -c "show vnc registrations"','.','none') if not holddownFactorSet: luCommand('r1','vtysh -c "show vnc summary"','.','pass','Holddown factor not set -- skipping test') else: #holddown time test luCommand('r1','vtysh -c "debug rfapi-dev register vn 10.0.0.1 un 1.1.1.1 prefix 1.111.0.0/16 lifetime 10"','', 'none', 'Prefix registered') luCommand('r1','vtysh -c "show vnc registrations local"','1.111.0.0/16','wait','Local registration') luCommand('r3','vtysh -c "debug rfapi-dev register vn 10.0.0.2 un 2.2.2.2 prefix 1.222.0.0/16 lifetime 10"','', 'none', 'Prefix registered') luCommand('r3','vtysh -c "show vnc registrations local"','1.222.0.0/16','wait','Local registration') luCommand('r4','vtysh -c "show vnc registrations"','Remotely: *Active: 4 ','wait', 'See registrations, L=10') luCommand('r4','vtysh -c "debug rfapi-dev register vn 10.0.0.3 un 3.3.3.3 prefix 1.222.0.0/16 lifetime 5 cost 50"','', 'none', 'MP Prefix registered') luCommand('r4','vtysh -c "show vnc registrations local"','1.222.0.0/16','wait','Local registration (MP prefix)') luCommand('r1','vtysh -c "show vnc registrations"','.','none') luCommand('r3','vtysh -c "show vnc registrations"','.','none') luCommand('r4','vtysh -c "debug rfapi-dev query vn 10.0.0.3 un 3.3.3.3 target 1.111.111.111"','pfx=', 'pass', 'Query R1s info') luCommand('r4','vtysh -c "debug rfapi-dev query vn 10.0.0.3 un 3.3.3.3 target 1.222.222.222"','1.222.0.0/16.*1.222.0.0/16', 'pass', 'Query R3s+R4s info') luCommand('r4','vtysh -c "debug rfapi-dev unregister vn 10.0.0.3 un 3.3.3.3 prefix 1.222.0.0/16"','', 'none', 'MP Prefix removed') luCommand('r4','vtysh -c "show vnc registrations"','In Holddown: *Active: 1 ','wait', 'MP prefix in holddown') luCommand('r1','vtysh -c "show vnc registrations"','In Holddown: *Active: 1 ','wait', 'MP prefix in holddown') luCommand('r3','vtysh -c "show vnc registrations"','In Holddown: *Active: 1 ','wait', 'MP prefix in holddown') luCommand('r1','vtysh -c "debug rfapi-dev query vn 10.0.0.1 un 1.1.1.1 target 1.222.222.222"','1.222.0.0/16', 'pass', 'Query R3s info')
c = int(r / 256) if c > 0: d = r - c * 256 - 1 else: d = r wait = 2 * num / 1000 mem_z = {} mem_b = {} rtrs = ["ce1", "ce2", "ce3", "r1", "r2", "r3", "r4"] for rtr in rtrs: mem_z[rtr] = {"value": 0, "units": "unknown"} mem_b[rtr] = {"value": 0, "units": "unknown"} ret = luCommand( rtr, 'vtysh -c "show memory"', "zebra: System allocator statistics: Total heap allocated: *(\d*) ([A-Za-z]*) .*bgpd: System allocator statistics: Total heap allocated: *(\d*) ([A-Za-z]*)", "none", "collect bgpd memory stats", ) found = luLast() if ret != False and found != None: mem_z[rtr] = {"value": int(found.group(1)), "units": found.group(2)} mem_b[rtr] = {"value": int(found.group(3)), "units": found.group(4)} luCommand("ce1", 'vtysh -c "show mem"', "qmem sharpd", "none", "check if sharpd running") doSharp = False found = luLast() if ret != False and found != None: if len(found.group()): doSharp = True
from lutil import luCommand, luLast from lib import topotest ret = luCommand('r2', 'ip -M route show', '\d*(?= via inet 10.0.2.4 dev r2-eth1)','wait','See mpls route to r4') found = luLast() if ret != False and found != None: label4r4 = found.group(0) luCommand('r2', 'ip -M route show', '.', 'pass', 'See %s as label to r4' % label4r4) ret = luCommand('r2', 'ip -M route show', '\d*(?= via inet 10.0.1.1 dev r2-eth0)', 'wait', 'See mpls route to r1') found = luLast() if ret != False and found != None: label4r1 = found.group(0) luCommand('r2', 'ip -M route show', '.', 'pass', 'See %s as label to r1' % label4r1) luCommand('r1', 'ip route show vrf r1-cust1', '99.0.0.4', 'pass', 'VRF->MPLS PHP route installed') luCommand('r4', 'ip route show vrf r4-cust2', '99.0.0.1','pass', 'VRF->MPLS PHP route installed') luCommand('r1', 'ip -M route show', '101', 'pass', 'MPLS->VRF route installed') luCommand('r4', 'ip -M route show', '1041', 'pass', 'MPLS->VRF1 route installed') luCommand('r4', 'ip -M route show', '1042', 'pass', 'MPLS->VRF2 route installed')
from lutil import luCommand luCommand('r1','vtysh -c "debug rfapi-dev unregister vn 10.0.0.1 un 1.1.1.1 prefix 11.11.11.0/24"','', 'none', 'Prefix removed') luCommand('r1','vtysh -c "show vnc registrations"','Locally: *Active: 0 ','wait','Local registration removed') luCommand('r1','vtysh -c "debug rfapi-dev close vn 10.0.0.1 un 1.1.1.1"','status 0', 'pass', 'Closed RFAPI') luCommand('r3','vtysh -c "debug rfapi-dev unregister vn 10.0.0.2 un 2.2.2.2 prefix 22.22.22.0/24"','', 'none', 'Prefix removed') luCommand('r3','vtysh -c "show vnc registrations"','Locally: *Active: 0 ','wait','Local registration removed') luCommand('r3','vtysh -c "debug rfapi-dev close vn 10.0.0.2 un 2.2.2.2"','status 0', 'pass', 'Closed RFAPI') luCommand('r4','vtysh -c "debug rfapi-dev unregister vn 10.0.0.3 un 3.3.3.3 prefix 33.33.33.0/24"','', 'none', 'Prefix removed') luCommand('r4','vtysh -c "debug rfapi-dev unregister vn 10.0.0.3 un 3.3.3.3 prefix 11.11.11.0/24"','', 'none', 'MP prefix removed') luCommand('r4','vtysh -c "show vnc registrations"','Locally: *Active: 0 ','wait','Local registration removed') #luCommand('r4','vtysh -c "debug rfapi-dev close vn 10.0.0.3 un 3.3.3.3"','status 0', 'pass', 'Closed RFAPI') luCommand('r4','vtysh -c "clear vnc nve *"','.', 'pass', 'Cleared NVEs') luCommand('r1','vtysh -c "show vnc registrations"','Locally: *Active: 0 .* Remotely: *Active: 0','wait','All registrations cleared') luCommand('r3','vtysh -c "show vnc registrations"','Locally: *Active: 0 .* Remotely: *Active: 0','wait','All registrations cleared') luCommand('r4','vtysh -c "show vnc registrations"','Locally: *Active: 0 .* Remotely: *Active: 0','wait','All registrations cleared') num = '0 exist' luCommand('r1','vtysh -c "show bgp ipv4 vpn"',num,'pass','VPN SAFI clear') luCommand('r2','vtysh -c "show bgp ipv4 vpn"',num,'pass','VPN SAFI clear') luCommand('r3','vtysh -c "show bgp ipv4 vpn"',num,'pass','VPN SAFI clear') luCommand('r4','vtysh -c "show bgp ipv4 vpn"',num,'pass','VPN SAFI clear') luCommand('r1','vtysh -c "show vnc registrations"','Locally: *Active: 0 .* Remotely: *Active: 0 .*In Holddown: *Active: 0','wait','No holddowns',20) luCommand('r3','vtysh -c "show vnc registrations"','Locally: *Active: 0 .* Remotely: *Active: 0 .*In Holddown: *Active: 0','wait','No holddowns') luCommand('r4','vtysh -c "show vnc registrations"','Locally: *Active: 0 .* Remotely: *Active: 0 .*In Holddown: *Active: 0','wait','No holddowns') luCommand('r1','vtysh -c "show vnc summary"','.','none') luCommand('r3','vtysh -c "show vnc summary"','.','none')
from lutil import luCommand luCommand('r1','vtysh -c "clear vrf cust1 prefix 99.0.0.1/32"','.','none','Cleared VRF route') luCommand('r3','vtysh -c "clear vrf cust1 prefix 99.0.0.2/32"','.','none','Cleared VRF route') luCommand('r4','vtysh -c "clear vrf cust1 prefix 99.0.0.3/32"','.','none','Cleared VRF route') luCommand('r1','vtysh -c "show vnc registrations local"','99.0.0.1','fail','Local Registration cleared') luCommand('r3','vtysh -c "show vnc registrations local"','99.0.0.2','fail','Local Registration cleared') luCommand('r4','vtysh -c "show vnc registrations local"','99.0.0.3','fail','Local Registration cleared') luCommand('r1','vtysh -c "show bgp ipv4 uni"','2 routes and 2','wait','Unicast SAFI updated') luCommand('r2','vtysh -c "show bgp ipv4 uni"','No BGP prefixes displayed','pass','Unicast SAFI') luCommand('r3','vtysh -c "show bgp ipv4 uni"','2 routes and 2','wait','Unicast SAFI updated') luCommand('r4','vtysh -c "show bgp ipv4 uni"','2 routes and 2','wait','Unicast SAFI updated') luCommand('ce1','vtysh -c "show bgp ipv4 uni"','2 routes and 2','wait','Local and remote routes') luCommand('ce2','vtysh -c "show bgp ipv4 uni"','2 routes and 2','wait','Local and remote routes') luCommand('ce3','vtysh -c "show bgp ipv4 uni"','2 routes and 2','wait','Local and remote routes') luCommand('r1','vtysh -c "show vnc registrations remote"','Prefix ','fail','Remote Registration cleared') luCommand('r3','vtysh -c "show vnc registrations remote"','Prefix ','fail','Remote Registration cleared') luCommand('r4','vtysh -c "show vnc registrations remote"','Prefix ','fail','Remote Registration cleared')
from lutil import luCommand rtrs = ['r1', 'r3', 'r4'] for rtr in rtrs: luCommand(rtr, 'ip link show type vrf {}-cust1'.format(rtr),'cust1: .*UP,LOWER_UP','pass','VRF cust1 up') luCommand(rtr, 'ip add show vrf {}-cust1'.format(rtr),'r..eth4: .*UP,LOWER_UP.* 192.168','pass','VRF cust1 IP config') luCommand(rtr, 'ip route show vrf {}-cust1'.format(rtr),'192.168...0/24 dev r.-eth','pass','VRF cust1 interface route') luCommand('r4', 'ip link show type vrf r4-cust2','cust2: .*UP,LOWER_UP','pass','VRF cust2 up') luCommand('r4', 'ip add show vrf r4-cust2','r..eth5.*UP,LOWER_UP.* 192.168','pass','VRF cust1 IP config') luCommand(rtr, 'ip route show vrf r4-cust2'.format(rtr),'192.168...0/24 dev r.-eth','pass','VRF cust2 interface route') rtrs = ['ce1', 'ce2', 'ce3'] for rtr in rtrs: luCommand(rtr, 'ip route show','192.168...0/24 dev ce.-eth0','pass','CE interface route') luCommand(rtr,'ping 192.168.1.1 -c 1',' 0. packet loss','wait','CE->PE ping') luCommand('ce4','ping 192.168.2.1 -c 1',' 0. packet loss','wait','CE4->PE4 ping')
from lutil import luCommand, luLast from lib import topotest ret = luCommand('r2', 'ip -M route show', '\d*(?= via inet 10.0.2.4 dev r2-eth1)', 'wait', 'See mpls route to r4') found = luLast() if ret != False and found != None: label4r4 = found.group(0) luCommand('r2', 'ip -M route show', '.', 'pass', 'See %s as label to r4' % label4r4) ret = luCommand('r2', 'ip -M route show', '\d*(?= via inet 10.0.1.1 dev r2-eth0)', 'wait', 'See mpls route to r1') found = luLast() if ret != False and found != None: label4r1 = found.group(0) luCommand('r2', 'ip -M route show', '.', 'pass', 'See %s as label to r1' % label4r1) luCommand('ce4', 'ip route add default via 192.168.2.1') luCommand('ce1', 'ip route add default via 192.168.1.1') luCommand( 'r1', 'ip route add 99.0.0.1 vrf r1-cust1 dev r1-eth4 via 192.168.1.2') luCommand( 'r4', 'ip route add 99.0.0.4 vrf r4-cust2 dev r4-eth4 via 192.168.2.2') # luCommand('r1','ip -M route add 101 dev r1-cust1') # luCommand('r4','ip -M route add 104 dev r4-cust2') # luCommand('r1','ip route add 99.0.0.4/32 vrf r1-cust1 nexthop encap mpls %s/104 via 10.0.1.2 dev r1-eth0'%label4r4) # luCommand('r4','ip route add 99.0.0.1/32 vrf r4-cust2 nexthop encap mpls %s/101 via 10.0.2.2 dev r4-eth0'%label4r1)
from lutil import luCommand from customize import l3mdev_accept l3mdev_rtrs = ['r1', 'r3', 'r4', 'ce4'] for rtr in l3mdev_rtrs: luCommand(rtr,'sysctl net.ipv4.tcp_l3mdev_accept',' = \d*','none','') found = luLast() luCommand(rtr,'ss -naep',':179','pass','IPv4:bgp, l3mdev{}'.format(found.group(0))) luCommand(rtr,'ss -naep',':.*:179','pass','IPv6:bgp') luCommand(rtr,'sysctl net.ipv4.tcp_l3mdev_accept',' = {}'.format(l3mdev_accept),'pass','l3mdev matches expected (real/expected{}/{})'.format(found.group(0),l3mdev_accept)) rtrs = ['r1', 'r3', 'r4'] for rtr in rtrs: luCommand(rtr, 'ip link show type vrf {}-cust1'.format(rtr),'cust1: .*UP,LOWER_UP','pass','VRF cust1 up') luCommand(rtr, 'ip add show vrf {}-cust1'.format(rtr),'r..eth4: .*UP,LOWER_UP.* 192.168','pass','VRF cust1 IP config') luCommand(rtr, 'ip route show vrf {}-cust1'.format(rtr),'192.168...0/24 dev r.-eth','pass','VRF cust1 interface route') luCommand('r4', 'ip link show type vrf r4-cust2','cust2: .*UP,LOWER_UP','pass','VRF cust2 up') luCommand('r4', 'ip add show vrf r4-cust2','r..eth5.*UP,LOWER_UP.* 192.168','pass','VRF cust1 IP config') luCommand(rtr, 'ip route show vrf r4-cust2'.format(rtr),'192.168...0/24 dev r.-eth','pass','VRF cust2 interface route') rtrs = ['ce1', 'ce2', 'ce3'] for rtr in rtrs: luCommand(rtr, 'ip route show','192.168...0/24 dev ce.-eth0','pass','CE interface route') luCommand(rtr,'ping 192.168.1.1 -c 1',' 0. packet loss','wait','CE->PE ping') luCommand('ce4', 'ip link show type vrf ce4-cust2','cust2: .*UP,LOWER_UP','pass','VRF cust2 up') luCommand('ce4', 'ip route show vrf ce4-cust2','192.168...0/24 dev ce.-eth0','pass','CE interface route') luCommand('ce4','ping 192.168.2.1 -c 1 -I ce4-cust2',' 0. packet loss','wait','CE4->PE4 ping')
from lutil import luCommand from customize import l3mdev_accept l3mdev_rtrs = ['r1', 'r3', 'r4', 'ce4'] for rtr in l3mdev_rtrs: luCommand(rtr, 'sysctl net.ipv4.tcp_l3mdev_accept', ' = \d*', 'none', '') found = luLast() luCommand(rtr, 'ss -naep', ':179', 'pass', 'IPv4:bgp, l3mdev{}'.format(found.group(0))) luCommand(rtr, 'ss -naep', ':.*:179', 'pass', 'IPv6:bgp') luCommand( rtr, 'sysctl net.ipv4.tcp_l3mdev_accept', ' = {}'.format(l3mdev_accept), 'pass', 'l3mdev matches expected (real/expected{}/{})'.format( found.group(0), l3mdev_accept)) rtrs = ['r1', 'r3', 'r4'] for rtr in rtrs: luCommand(rtr, 'ip link show type vrf {}-cust1'.format(rtr), 'cust1: .*UP', 'pass', 'VRF cust1 intf up') luCommand(rtr, 'ip add show vrf {}-cust1'.format(rtr), 'r..eth4.*UP', 'pass', 'VRF cust1 IP intf up') luCommand(rtr, 'ip add show vrf {}-cust1'.format(rtr), '192.168', 'pass', 'VRF cust1 IP config') luCommand(rtr, 'ip route show vrf {}-cust1'.format(rtr), '192.168...0/24 dev r.-eth', 'pass', 'VRF cust1 interface route') luCommand('r4', 'ip link show type vrf r4-cust2', 'cust2: .*UP', 'pass', 'VRF cust2 up') luCommand('r4', 'ip add show vrf r4-cust2', 'r..eth5.*UP.* 192.168', 'pass', 'VRF cust1 IP config') luCommand(rtr, 'ip route show vrf r4-cust2'.format(rtr),
b = int(num/(256*256)) if b > 0: r = num - b * (256*256) else: r = num c = int(r/256) if c > 0: d = r - c * 256 - 1 else: d = r wait = num/1000 mem = {} rtrs = ['ce1', 'ce2', 'ce3', 'r1', 'r2', 'r3', 'r4'] for rtr in rtrs: mem[rtr] = {'value': 0, 'units': 'unknown'} ret = luCommand(rtr, 'vtysh -c "show memory"', 'bgpd: System allocator statistics: Total heap allocated: *(\d*) ([A-Za-z]*)', 'none', 'collect bgpd memory stats') found = luLast() if ret != False and found != None: mem[rtr] = {'value': int(found.group(1)), 'units': found.group(2)} luCommand('ce1', 'vtysh -c "sharp data nexthop"', 'sharpd is not running', 'none','check if sharpd running') doSharp = True found = luLast() if ret != False and found != None: if len(found.group()): luCommand('ce1', 'vtysh -c "sharp data nexthop"', 'sharpd is not running', 'pass','sharpd NOT running, skipping test') doSharp = False if doSharp == True: luCommand('ce1', 'vtysh -c "sharp install routes 10.0.0.0 nexthop 99.0.0.1 {}"'.format(num),'','pass','Adding {} routes'.format(num)) luCommand('ce2', 'vtysh -c "sharp install routes 10.0.0.0 nexthop 99.0.0.2 {}"'.format(num),'','pass','Adding {} routes'.format(num))
{ "p": "99.0.0.4/32", "n": "192.168.2.2" }, ] bgpribRequireUnicastRoutes("r4", "ipv4", "r4-cust2", "Customer 2 routes in r4 vrf", want_r4_cust2_routes) ######################################################################## # PE routers: core unicast routes are empty ######################################################################## luCommand( "r1", 'vtysh -c "show bgp ipv4 uni"', "No BGP prefixes displayed", "pass", "Core Unicast SAFI clean", ) luCommand( "r2", 'vtysh -c "show bgp ipv4 uni"', "No BGP prefixes displayed", "pass", "Core Unicast SAFI clean", ) luCommand( "r3", 'vtysh -c "show bgp ipv4 uni"', "No BGP prefixes displayed", "pass",
from lutil import luCommand rtrs = ['r1', 'r3', 'r4', 'ce1', 'ce2', 'ce3', 'ce4'] for rtr in rtrs: luCommand(rtr,'sysctl net.ipv4.tcp_l3mdev_accept',' = \d*','none','') found = luLast() luCommand(rtr,'ss -aep',':bgp','pass','IPv4:bgp, l3mdev%s' % found.group(0)) luCommand(rtr,'ss -aep',':.:bgp','pass','IPv6:bgp') rtrs = ['r1', 'r3', 'r4'] for rtr in rtrs: luCommand(rtr, 'ip link show type vrf {}-cust1'.format(rtr),'cust1: .*UP,LOWER_UP','pass','VRF cust1 up') luCommand(rtr, 'ip add show vrf {}-cust1'.format(rtr),'r..eth4: .*UP,LOWER_UP.* 192.168','pass','VRF cust1 IP config') luCommand(rtr, 'ip route show vrf {}-cust1'.format(rtr),'192.168...0/24 dev r.-eth','pass','VRF cust1 interface route') luCommand('r4', 'ip link show type vrf r4-cust2','cust2: .*UP,LOWER_UP','pass','VRF cust2 up') luCommand('r4', 'ip add show vrf r4-cust2','r..eth5.*UP,LOWER_UP.* 192.168','pass','VRF cust1 IP config') luCommand(rtr, 'ip route show vrf r4-cust2'.format(rtr),'192.168...0/24 dev r.-eth','pass','VRF cust2 interface route') rtrs = ['ce1', 'ce2', 'ce3'] for rtr in rtrs: luCommand(rtr, 'ip route show','192.168...0/24 dev ce.-eth0','pass','CE interface route') luCommand(rtr,'ping 192.168.1.1 -c 1',' 0. packet loss','wait','CE->PE ping') luCommand('ce4', 'ip link show type vrf ce4-cust2','cust2: .*UP,LOWER_UP','pass','VRF cust2 up') luCommand('ce4', 'ip route show vrf ce4-cust2','192.168...0/24 dev ce.-eth0','pass','CE interface route') luCommand('ce4','ping 192.168.2.1 -c 1 -I ce4-cust2',' 0. packet loss','wait','CE4->PE4 ping')
from lutil import luCommand holddownFactorSet = luCommand( "r1", 'vtysh -c "show running"', "rfp holddown-factor", "none", "Holddown factor set", ) if not holddownFactorSet: to = "-1" else: to = "1" luCommand( "r1", 'vtysh -c "debug rfapi-dev open vn 20.0.0.1 un 1.1.1.21"', "rfapi_set_response_cb: status 0", "pass", "Opened RFAPI", ) luCommand( "r1", 'vtysh -c "debug rfapi-dev register vn 20.0.0.1 un 1.1.1.21 prefix 111.111.111.0/24 lifetime {}"' .format(to), "", "none", "Prefix registered", ) luCommand( "r1", 'vtysh -c "show vnc registrations local"',
from lutil import luCommand luCommand( "r1", 'vtysh -c "clear vrf cust1 prefix 99.0.0.1/32"', ".", "none", "Cleared VRF route", ) luCommand( "r3", 'vtysh -c "clear vrf cust1 prefix 99.0.0.2/32"', ".", "none", "Cleared VRF route", ) luCommand( "r4", 'vtysh -c "clear vrf cust1 prefix 99.0.0.3/32"', ".", "none", "Cleared VRF route", ) luCommand( "r1", 'vtysh -c "show vnc registrations local"', "99.0.0.1", "fail", "Local Registration cleared", ) luCommand(
from lutil import luCommand holddownFactorSet = luCommand('r1','vtysh -c "show running"','rfp holddown-factor','none','Holddown factor set') if not holddownFactorSet: to = "-1" cost = "" else: to = "6" cost = "cost 50" luCommand('r1','vtysh -c "debug rfapi-dev open vn 10.0.0.1 un 1.1.1.1"','rfapi_set_response_cb: status 0', 'pass', 'Opened RFAPI') luCommand('r1','vtysh -c "debug rfapi-dev query vn 10.0.0.1 un 1.1.1.1 target 11.11.11.11"','rc=2', 'pass', 'Clean query') luCommand('r1','vtysh -c "debug rfapi-dev register vn 10.0.0.1 un 1.1.1.1 prefix 11.11.11.0/24 lifetime {}"'.format(to),'', 'none', 'Prefix registered') luCommand('r1','vtysh -c "show vnc registrations local"','1 out of 1','wait','Local registration') luCommand('r1','vtysh -c "debug rfapi-dev response-omit-self off"','.','none') luCommand('r1','vtysh -c "debug rfapi-dev query vn 10.0.0.1 un 1.1.1.1 target 11.11.11.11"','11.11.11.0/24', 'pass', 'Query self') luCommand('r3','vtysh -c "debug rfapi-dev open vn 10.0.0.2 un 2.2.2.2"','rfapi_set_response_cb: status 0', 'pass', 'Opened RFAPI') luCommand('r3','vtysh -c "debug rfapi-dev register vn 10.0.0.2 un 2.2.2.2 prefix 22.22.22.0/24 lifetime {}"'.format(to),'', 'none', 'Prefix registered') luCommand('r3','vtysh -c "show vnc registrations local"','1 out of 1','wait','Local registration') luCommand('r3','vtysh -c "debug rfapi-dev response-omit-self on"','.','none') luCommand('r3','vtysh -c "debug rfapi-dev query vn 10.0.0.2 un 2.2.2.2 target 22.22.22.22"','rc=2', 'pass', 'Self excluded') luCommand('r3','vtysh -c "debug rfapi-dev open vn 10.0.1.2 un 2.1.1.2"','rfapi_set_response_cb: status 0', 'pass', 'Opened query only RFAPI') luCommand('r3','vtysh -c "debug rfapi-dev query vn 10.0.1.2 un 2.1.1.2 target 22.22.22.22"','22.22.22.0/24', 'pass', 'See local') luCommand('r4','vtysh -c "debug rfapi-dev open vn 10.0.0.3 un 3.3.3.3"','rfapi_set_response_cb: status 0', 'pass', 'Opened RFAPI') luCommand('r4','vtysh -c "debug rfapi-dev register vn 10.0.0.3 un 3.3.3.3 prefix 33.33.33.0/24 lifetime {}"'.format(to),'', 'none', 'Prefix registered') luCommand('r4','vtysh -c "show vnc registrations local"','1 out of 1','wait','Local registration') luCommand('r4','vtysh -c "debug rfapi-dev response-omit-self off"','.','none') luCommand('r4','vtysh -c "debug rfapi-dev query vn 10.0.0.3 un 3.3.3.3 target 33.33.33.33"','33.33.33.0/24', 'pass', 'Query self') luCommand('r4','vtysh -c "debug rfapi-dev register vn 10.0.0.3 un 3.3.3.3 prefix 11.11.11.0/24 lifetime {} {}"'.format(to, cost),'', 'none', 'MP Prefix registered') luCommand('r4','vtysh -c "show vnc registrations local"','2 out of 2','wait','Local registration')
if b > 0: r = num - b * (256 * 256) else: r = num c = int(r / 256) if c > 0: d = r - c * 256 - 1 else: d = r wait = num / 1000 mem = {} rtrs = ['ce1', 'ce2', 'ce3', 'r1', 'r2', 'r3', 'r4'] for rtr in rtrs: mem[rtr] = {'value': 0, 'units': 'unknown'} ret = luCommand( rtr, 'vtysh -c "show memory"', 'bgpd: System allocator statistics: Total heap allocated: *(\d*) ([A-Za-z]*)', 'none', 'collect bgpd memory stats') found = luLast() if ret != False and found != None: mem[rtr] = {'value': int(found.group(1)), 'units': found.group(2)} luCommand('ce1', 'vtysh -c "sharp data nexthop"', 'sharpd is not running', 'none', 'check if sharpd running') doSharp = True found = luLast() if ret != False and found != None: if len(found.group()): luCommand('ce1', 'vtysh -c "sharp data nexthop"', 'sharpd is not running', 'pass', 'sharpd NOT running, skipping test') doSharp = False
from lutil import luCommand, luLast from lib import topotest ret = luCommand('r2', 'ip -M route show', '\d*(?= via inet 10.0.2.4 dev r2-eth1)', 'wait', 'See mpls route to r4') found = luLast() if ret != False and found != None: label4r4 = found.group(0) luCommand('r2', 'ip -M route show', '.', 'pass', 'See %s as label to r4' % label4r4) ret = luCommand('r2', 'ip -M route show', '\d*(?= via inet 10.0.1.1 dev r2-eth0)', 'wait', 'See mpls route to r1') found = luLast() if ret != False and found != None: label4r1 = found.group(0) luCommand('r2', 'ip -M route show', '.', 'pass', 'See %s as label to r1' % label4r1) luCommand('r1', 'ip route show vrf r1-cust1', '99.0.0.4', 'pass', 'VRF->MPLS PHP route installed') luCommand('r4', 'ip route show vrf r4-cust2', '99.0.0.1', 'pass', 'VRF->MPLS PHP route installed') luCommand('r1', 'ip -M route show', '101', 'pass', 'MPLS->VRF route installed') luCommand('r4', 'ip -M route show', '1041', 'pass', 'MPLS->VRF1 route installed')
from lutil import luCommand ret = luCommand( "ce1", 'vtysh -c "show ip route" | grep -c \\ 10\\.\\*/32', "(.*)", "pass", "Looking for sharp routes", ) found = luLast() if ret != False and found != None: num = int(found.group()) luCommand( "ce3", 'vtysh -c "show bgp sum"', ".", "pass", "See %s sharp routes" % num ) if num > 0: rtrs = ["ce1", "ce2", "ce3"] for rtr in rtrs: luCommand( rtr, 'vtysh -c "show bgp ipv4 uni" | grep Display', ".", "none", "BGP routes pre remove", ) luCommand( rtr, "ip route show | cat -n | tail", ".", "none", "Linux routes pre remove",
from lutil import luCommand luCommand('ce1', 'vtysh -c "show bgp ipv4 uni"', '7 routes and 7', 'wait', 'Local and remote routes') luCommand('ce2', 'vtysh -c "show bgp ipv4 uni"', '7 routes and 9', 'wait', 'Local and remote routes') luCommand('ce3', 'vtysh -c "show bgp ipv4 uni"', '7 routes and 7', 'wait', 'Local and remote routes') luCommand('r1', 'vtysh -c "show bgp ipv4 uni"', '7 routes and 9', 'pass', 'Unicast SAFI') luCommand('r2', 'vtysh -c "show bgp ipv4 uni"', 'No BGP prefixes displayed', 'pass', 'Unicast SAFI') luCommand('r3', 'vtysh -c "show bgp ipv4 uni"', '7 routes and 9', 'pass', 'Unicast SAFI') luCommand('r4', 'vtysh -c "show bgp ipv4 uni"', '7 routes and 9', 'pass', 'Unicast SAFI') have2ndImports = luCommand('r3', 'vtysh -c "show vnc registrations imported"', '2 out of 2 imported', 'none', 'Imported Registrations', 2) if have2ndImports: num = '9 routes and 9' else: num = '7 routes and 7' luCommand('r1', 'vtysh -c "show bgp ipv4 vpn"', num, 'pass', 'VPN SAFI') luCommand('r2', 'vtysh -c "show bgp ipv4 vpn"', num, 'pass', 'VPN SAFI') luCommand('r3', 'vtysh -c "show bgp ipv4 vpn"', num, 'pass', 'VPN SAFI') luCommand('r4', 'vtysh -c "show bgp ipv4 vpn"', num, 'pass', 'VPN SAFI')
from lutil import luCommand luCommand( 'r1', 'vtysh -c "debug rfapi-dev unregister vn 10.0.0.1 un 1.1.1.1 prefix 11.11.11.0/24"', '', 'none', 'Prefix removed') luCommand('r1', 'vtysh -c "show vnc registrations"', 'Locally: *Active: 0 ', 'wait', 'Local registration removed') luCommand('r1', 'vtysh -c "debug rfapi-dev close vn 10.0.0.1 un 1.1.1.1"', 'status 0', 'pass', 'Closed RFAPI') luCommand( 'r3', 'vtysh -c "debug rfapi-dev unregister vn 10.0.0.2 un 2.2.2.2 prefix 22.22.22.0/24"', '', 'none', 'Prefix removed') luCommand('r3', 'vtysh -c "show vnc registrations"', 'Locally: *Active: 0 ', 'wait', 'Local registration removed') luCommand('r3', 'vtysh -c "debug rfapi-dev close vn 10.0.0.2 un 2.2.2.2"', 'status 0', 'pass', 'Closed RFAPI') luCommand( 'r4', 'vtysh -c "debug rfapi-dev unregister vn 10.0.0.3 un 3.3.3.3 prefix 33.33.33.0/24"', '', 'none', 'Prefix removed') luCommand( 'r4', 'vtysh -c "debug rfapi-dev unregister vn 10.0.0.3 un 3.3.3.3 prefix 11.11.11.0/24"', '', 'none', 'MP prefix removed') luCommand('r4', 'vtysh -c "show vnc registrations"', 'Locally: *Active: 0 ', 'wait', 'Local registration removed') luCommand('r4', 'vtysh -c "debug rfapi-dev close vn 10.0.0.3 un 3.3.3.3"',
from lutil import luCommand luCommand('ce1','vtysh -c "show bgp ipv4 uni"','7 routes and 7','wait','Local and remote routes') luCommand('ce2','vtysh -c "show bgp ipv4 uni"','7 routes and 9','wait','Local and remote routes') luCommand('ce3','vtysh -c "show bgp ipv4 uni"','7 routes and 7','wait','Local and remote routes') luCommand('r1','vtysh -c "show bgp ipv4 uni"','7 routes and 9','pass','Unicast SAFI') luCommand('r2','vtysh -c "show bgp ipv4 uni"','No BGP prefixes displayed','pass','Unicast SAFI') luCommand('r3','vtysh -c "show bgp ipv4 uni"','7 routes and 9','pass','Unicast SAFI') luCommand('r4','vtysh -c "show bgp ipv4 uni"','7 routes and 9','pass','Unicast SAFI') have2ndImports = luCommand('r3','vtysh -c "show vnc registrations imported"','2 out of 2 imported','none','Imported Registrations',2) if have2ndImports: num = '9 routes and 9' else: num = '7 routes and 7' luCommand('r1','vtysh -c "show bgp ipv4 vpn"',num,'pass','VPN SAFI') luCommand('r2','vtysh -c "show bgp ipv4 vpn"',num,'pass','VPN SAFI') luCommand('r3','vtysh -c "show bgp ipv4 vpn"',num,'pass','VPN SAFI') luCommand('r4','vtysh -c "show bgp ipv4 vpn"',num,'pass','VPN SAFI')
from lutil import luCommand holddownFactorSet = luCommand( "r1", 'vtysh -c "show running"', "rfp holddown-factor", "none", "Holddown factor set", ) luCommand("r1", 'vtysh -c "show vnc registrations"', ".", "none") luCommand("r3", 'vtysh -c "show vnc registrations"', ".", "none") luCommand("r4", 'vtysh -c "show vnc registrations"', ".", "none") if not holddownFactorSet: luCommand( "r1", 'vtysh -c "show vnc summary"', ".", "pass", "Holddown factor not set -- skipping test", ) else: # holddown time test luCommand( "r1", 'vtysh -c "debug rfapi-dev register vn 10.0.0.1 un 1.1.1.1 prefix 1.111.0.0/16 lifetime 10"', "", "none", "Prefix registered", ) luCommand( "r1",
from lutil import luCommand luCommand( "ce1", 'vtysh -c "show bgp ipv4 uni"', "7 routes and 7", "wait", "Local and remote routes", ) luCommand( "ce2", 'vtysh -c "show bgp ipv4 uni"', "7 routes and 9", "wait", "Local and remote routes", ) luCommand( "ce3", 'vtysh -c "show bgp ipv4 uni"', "7 routes and 7", "wait", "Local and remote routes", ) luCommand( "r1", 'vtysh -c "show bgp ipv4 uni"', "7 routes and 9", "pass", "Unicast SAFI" ) luCommand( "r2", 'vtysh -c "show bgp ipv4 uni"', "No BGP prefixes displayed", "pass",
from lutil import luCommand luCommand( "r1", 'vtysh -c "show bgp next"', "99.0.0.. valid", "wait", "See CE static NH" ) luCommand( "r3", 'vtysh -c "show bgp next"', "99.0.0.. valid", "wait", "See CE static NH" ) luCommand( "r4", 'vtysh -c "show bgp next"', "99.0.0.. valid", "wait", "See CE static NH" ) luCommand("r1", 'vtysh -c "show bgp ipv4 uni"', "i5.*i5", "wait", "See CE routes") luCommand("r3", 'vtysh -c "show bgp ipv4 uni"', "i5.*i5", "wait", "See CE routes") luCommand("r4", 'vtysh -c "show bgp ipv4 uni"', "i5.*i5", "wait", "See CE routes") luCommand("ce1", 'vtysh -c "show bgp ipv4 uni 5.1.0.0/24"', "", "none", "See CE routes") luCommand("r1", 'vtysh -c "show bgp ipv4 uni 5.1.0.0/24"', "", "none", "See CE routes") luCommand("ce2", 'vtysh -c "show bgp ipv4 uni 5.1.0.0/24"', "", "none", "See CE routes") luCommand("r3", 'vtysh -c "show bgp ipv4 uni 5.1.0.0/24"', "", "none", "See CE routes") luCommand("ce3", 'vtysh -c "show bgp ipv4 uni 5.1.2.0/24"', "", "none", "See CE routes") luCommand("r4", 'vtysh -c "show bgp ipv4 uni 5.1.2.0/24"', "", "none", "See CE routes") luCommand( "r1", 'vtysh -c "add vrf cust1 prefix 99.0.0.1/32"', ".", "none", "IP Address" ) luCommand( "r1", 'vtysh -c "show vnc registrations local"', "99.0.0.1", "wait", "Local Registration", )
from lutil import luCommand luCommand('ce1','vtysh -c "show bgp summary"',' 00:0','wait','Adjacencies up',180) luCommand('ce2','vtysh -c "show bgp summary"',' 00:0','wait','Adjacencies up') luCommand('ce3','vtysh -c "show bgp summary"',' 00:0','wait','Adjacencies up') luCommand('ce4','vtysh -c "show bgp vrf all summary"',' 00:0','wait','Adjacencies up',180) luCommand('r1','ping 2.2.2.2 -c 1',' 0. packet loss','wait','PE->P2 (loopback) ping',60) luCommand('r3','ping 2.2.2.2 -c 1',' 0. packet loss','wait','PE->P2 (loopback) ping',60) luCommand('r4','ping 2.2.2.2 -c 1',' 0. packet loss','wait','PE->P2 (loopback) ping',60) luCommand('r2','vtysh -c "show bgp summary"',' 00:0.* 00:0.* 00:0','wait','Core adjacencies up',300) luCommand('r1','vtysh -c "show bgp summary"',' 00:0','pass','Core adjacencies up') luCommand('r3','vtysh -c "show bgp summary"',' 00:0','pass','Core adjacencies up') luCommand('r4','vtysh -c "show bgp summary"',' 00:0','pass','Core adjacencies up') luCommand('r1','vtysh -c "show bgp vrf all summary"',' 00:0.* 00:0','pass','All adjacencies up') luCommand('r3','vtysh -c "show bgp vrf all summary"',' 00:0.* 00:0','pass','All adjacencies up') luCommand('r4','vtysh -c "show bgp vrf all summary"',' 00:0.* 00:0.* 00:0','pass','All adjacencies up') luCommand('r1','ping 3.3.3.3 -c 1',' 0. packet loss','wait','PE->PE3 (loopback) ping') luCommand('r1','ping 4.4.4.4 -c 1',' 0. packet loss','wait','PE->PE4 (loopback) ping') luCommand('r4','ping 3.3.3.3 -c 1',' 0. packet loss','wait','PE->PE3 (loopback) ping')
from lutil import luCommand luCommand('ce1','ping 192.168.1.1 -c 1',' 0. packet loss','pass','CE->PE ping') luCommand('ce2','ping 192.168.1.1 -c 1',' 0. packet loss','pass','CE->PE ping') luCommand('ce3','ping 192.168.1.1 -c 1',' 0. packet loss','pass','CE->PE ping') luCommand('ce1','vtysh -c "show bgp summary"',' 00:0','wait','Adjacencies up',90) luCommand('ce2','vtysh -c "show bgp summary"',' 00:0','wait','Adjacencies up') luCommand('ce3','vtysh -c "show bgp summary"',' 00:0','wait','Adjacencies up') luCommand('r1','ping 2.2.2.2 -c 1',' 0. packet loss','wait','PE->P2 (loopback) ping',60) luCommand('r3','ping 2.2.2.2 -c 1',' 0. packet loss','wait','PE->P2 (loopback) ping',60) luCommand('r4','ping 2.2.2.2 -c 1',' 0. packet loss','wait','PE->P2 (loopback) ping',60) luCommand('r2','vtysh -c "show bgp summary"',' 00:0.* 00:0.* 00:0','wait','Core adjacencies up') luCommand('r1','vtysh -c "show bgp summary"',' 00:0','pass','Core adjacencies up') luCommand('r3','vtysh -c "show bgp summary"',' 00:0','pass','Core adjacencies up') luCommand('r4','vtysh -c "show bgp summary"',' 00:0','pass','Core adjacencies up') luCommand('r1','vtysh -c "show bgp vrf all summary"',' 00:0.* 00:0','pass','All adjacencies up') luCommand('r3','vtysh -c "show bgp vrf all summary"',' 00:0.* 00:0','pass','All adjacencies up') luCommand('r4','vtysh -c "show bgp vrf all summary"',' 00:0.* 00:0','pass','All adjacencies up') luCommand('r1','ping 3.3.3.3 -c 1',' 0. packet loss','wait','PE->PE3 (loopback) ping') luCommand('r1','ping 4.4.4.4 -c 1',' 0. packet loss','wait','PE->PE4 (loopback) ping') luCommand('r4','ping 3.3.3.3 -c 1',' 0. packet loss','wait','PE->PE3 (loopback) ping')
from lutil import luCommand luCommand('r1','vtysh -c "show bgp ipv4 vpn"','','none','VPN SAFI') luCommand('r2','vtysh -c "show bgp ipv4 vpn"','','none','VPN SAFI') luCommand('r3','vtysh -c "show bgp ipv4 vpn"','','none','VPN SAFI') luCommand('r4','vtysh -c "show bgp ipv4 vpn"','','none','VPN SAFI') luCommand('r1','vtysh -c "show vnc registrations"','Locally: *Active: 1 .* Remotely: *Active: 3','wait','See all registrations') luCommand('r3','vtysh -c "show vnc registrations"','Locally: *Active: 1 .* Remotely: *Active: 3','wait','See all registrations') luCommand('r4','vtysh -c "show vnc registrations"','Locally: *Active: 2 .* Remotely: *Active: 2','wait','See all registrations') num = '4 routes and 4' luCommand('r1','vtysh -c "show bgp ipv4 vpn"',num,'pass','VPN SAFI okay') luCommand('r2','vtysh -c "show bgp ipv4 vpn"',num,'pass','VPN SAFI okay') luCommand('r3','vtysh -c "show bgp ipv4 vpn"',num,'pass','VPN SAFI okay') luCommand('r4','vtysh -c "show bgp ipv4 vpn"',num,'pass','VPN SAFI okay') luCommand('r1','vtysh -c "debug rfapi-dev query vn 10.0.0.1 un 1.1.1.1 target 22.22.22.22"','pfx=', 'pass', 'Query R2s info') luCommand('r1','vtysh -c "debug rfapi-dev query vn 10.0.0.1 un 1.1.1.1 target 33.33.33.33"','pfx=', 'pass', 'Query R4s info') luCommand('r3','vtysh -c "debug rfapi-dev query vn 10.0.0.2 un 2.2.2.2 target 11.11.11.11"','11.11.11.0/24.*11.11.11.0/24.*', 'pass', 'Query R1s+R4s info') luCommand('r3','vtysh -c "debug rfapi-dev query vn 10.0.0.2 un 2.2.2.2 target 33.33.33.33"','pfx=', 'pass', 'Query R4s info') luCommand('r4','vtysh -c "debug rfapi-dev query vn 10.0.0.3 un 3.3.3.3 target 11.11.11.11"','11.11.11.0/24.*11.11.11.0/24.*', 'pass', 'Query R1s+R4s info') luCommand('r4','vtysh -c "debug rfapi-dev query vn 10.0.0.3 un 3.3.3.3 target 22.22.22.22"','pfx=', 'pass', 'Query R2s info')
from lutil import luCommand luCommand("r1", 'vtysh -c "show bgp ipv4 vpn"', "", "none", "VPN SAFI") luCommand("r2", 'vtysh -c "show bgp ipv4 vpn"', "", "none", "VPN SAFI") luCommand("r3", 'vtysh -c "show bgp ipv4 vpn"', "", "none", "VPN SAFI") luCommand("r4", 'vtysh -c "show bgp ipv4 vpn"', "", "none", "VPN SAFI") luCommand( "r1", 'vtysh -c "show vnc registrations"', "Locally: *Active: 1 .* Remotely: *Active: 3", "wait", "See all registrations", ) luCommand( "r3", 'vtysh -c "show vnc registrations"', "Locally: *Active: 1 .* Remotely: *Active: 3", "wait", "See all registrations", ) luCommand( "r4", 'vtysh -c "show vnc registrations"', "Locally: *Active: 2 .* Remotely: *Active: 2", "wait", "See all registrations", ) num = "4 routes and 4" luCommand("r1", 'vtysh -c "show bgp ipv4 vpn"', num, "pass", "VPN SAFI okay") luCommand("r2", 'vtysh -c "show bgp ipv4 vpn"', num, "pass", "VPN SAFI okay") luCommand("r3", 'vtysh -c "show bgp ipv4 vpn"', num, "pass", "VPN SAFI okay")
from lutil import luCommand luCommand('r1','vtysh -c "show bgp next"','99.0.0.. valid', 'wait', 'See CE static NH') luCommand('r3','vtysh -c "show bgp next"','99.0.0.. valid', 'wait', 'See CE static NH') luCommand('r4','vtysh -c "show bgp next"','99.0.0.. valid', 'wait', 'See CE static NH') luCommand('r1','vtysh -c "show bgp ipv4 uni"','i5.*i5','wait','See CE routes') luCommand('r3','vtysh -c "show bgp ipv4 uni"','i5.*i5','wait','See CE routes') luCommand('r4','vtysh -c "show bgp ipv4 uni"','i5.*i5','wait','See CE routes') luCommand('ce1','vtysh -c "show bgp ipv4 uni 5.1.0.0/24"','','none','See CE routes') luCommand('r1','vtysh -c "show bgp ipv4 uni 5.1.0.0/24"','','none','See CE routes') luCommand('ce2','vtysh -c "show bgp ipv4 uni 5.1.0.0/24"','','none','See CE routes') luCommand('r3','vtysh -c "show bgp ipv4 uni 5.1.0.0/24"','','none','See CE routes') luCommand('ce3','vtysh -c "show bgp ipv4 uni 5.1.2.0/24"','','none','See CE routes') luCommand('r4','vtysh -c "show bgp ipv4 uni 5.1.2.0/24"','','none','See CE routes') luCommand('r1','vtysh -c "add vrf cust1 prefix 99.0.0.1/32"','.','none','IP Address') luCommand('r1','vtysh -c "show vnc registrations local"','99.0.0.1','wait','Local Registration') luCommand('r1','vtysh -c "show vnc registrations imported"','2 out of 2 imported','wait','Imported Registrations') luCommand('r3','vtysh -c "show bgp ipv4 vpn"','i99.0.0.1/32','wait','See R1s static address') luCommand('r4','vtysh -c "show bgp ipv4 vpn"','i99.0.0.1/32','wait','See R1s static address') luCommand('r3','vtysh -c "show bgp ipv4 vpn rd 10:1"','i5.*i5','wait','See R1s imports') luCommand('r4','vtysh -c "show bgp ipv4 vpn rd 10:1"','i5.*i5','wait','See R1s imports') luCommand('r3','vtysh -c "add vrf cust1 prefix 99.0.0.2/32"','.','none','IP Address') luCommand('r3','vtysh -c "show vnc registrations local"','99.0.0.2','wait','Local Registration') have2ndImports = luCommand('r3','vtysh -c "show vnc registrations imported"','2 out of 2 imported','none','Imported Registrations',2) if have2ndImports: luCommand('r3','vtysh -c "show vnc registrations imported"','2 out of 2 imported','pass','Imported Registrations') luCommand('r1','vtysh -c "show bgp ipv4 vpn"','i99.0.0.2/32','wait','See R3s static address') luCommand('r4','vtysh -c "show bgp ipv4 vpn"','i99.0.0.2/32','wait','See R3s static address') if have2ndImports: luCommand('r1','vtysh -c "show bgp ipv4 vpn rd 10:3"','i5.*i5','none','See R3s imports')