summaryrefslogtreecommitdiff
path: root/tests/topotests/lib/topotest.py
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2019-06-06 11:49:15 -0400
committerMark Stapp <mjs@voltanet.io>2019-06-06 13:22:04 -0400
commite394d9aa5fdc67dc902bf48c02c340ca94bea99c (patch)
tree529102b6cb1d1f54e6192c598b7bf810d483cad7 /tests/topotests/lib/topotest.py
parent92a9c7bd28179b486465e16e12550ce0cc26c4a5 (diff)
tests: Add ip6_route_zebra lib function
Add a common function to retrieve and canonicalize 'show ipv6 route' output for use in topotests. Use that in the test_ospf6_topo1 test; update the corresponding 'expected' results files to match the lib function. Replace some 'print' with 'logger' statements in that test also. Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'tests/topotests/lib/topotest.py')
-rw-r--r--tests/topotests/lib/topotest.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/topotests/lib/topotest.py b/tests/topotests/lib/topotest.py
index e0da20e07f..2acb04fb0e 100644
--- a/tests/topotests/lib/topotest.py
+++ b/tests/topotests/lib/topotest.py
@@ -429,6 +429,33 @@ def ip4_route_zebra(node, vrf_name=None):
lines = lines[1:]
return '\n'.join(lines)
+def ip6_route_zebra(node, vrf_name=None):
+ """
+ Retrieves the output of 'show ipv6 route [vrf vrf_name]', then
+ canonicalizes it by eliding link-locals.
+ """
+
+ if vrf_name == None:
+ tmp = node.vtysh_cmd('show ipv6 route')
+ else:
+ tmp = node.vtysh_cmd('show ipv6 route vrf {0}'.format(vrf_name))
+
+ # Mask out timestamp
+ output = re.sub(r" [0-2][0-9]:[0-5][0-9]:[0-5][0-9]", " XX:XX:XX", tmp)
+
+ # Mask out the link-local addresses
+ output = re.sub(r'fe80::[^ ]+,', 'fe80::XXXX:XXXX:XXXX:XXXX,', output)
+
+ lines = output.splitlines()
+ header_found = False
+ while lines and (not lines[0].strip() or not header_found):
+ if '> - selected route' in lines[0]:
+ header_found = True
+ lines = lines[1:]
+
+ return '\n'.join(lines)
+
+
def proto_name_to_number(protocol):
return {
'bgp': '186',