Beispiel #1
0
def compare_show_ipv6_ospf6(rname, expected):
    """
    Calls 'show ipv6 ospf6 route' for router `rname` and compare the obtained
    result with the expected output.
    """
    tgen = get_topogen()
    current = tgen.gears[rname].vtysh_cmd('show ipv6 ospf6 route')

    # This output has space formating and random IPv6 link addresses, we have to
    # remove them first before testing.
    current = topotest.normalize_text(current)
    expected = topotest.normalize_text(expected)

    # Remove the link addresses
    current = re.sub(r'fe80::[^ ]+', 'fe80::xxxx:xxxx:xxxx:xxxx', current)
    expected = re.sub(r'fe80::[^ ]+', 'fe80::xxxx:xxxx:xxxx:xxxx', expected)

    # Remove the time
    current = re.sub(r'\d+:\d{2}:\d{2}', '', current)
    expected = re.sub(r'\d+:\d{2}:\d{2}', '', expected)

    return topotest.difflines(current,
                              expected,
                              title1="Current output",
                              title2="Expected output")
Beispiel #2
0
def compare_show_ipv6_vrf(rname, expected):
    """
    Calls 'show ipv6 route' for router `rname` and compare the obtained
    result with the expected output.
    """
    tgen = get_topogen()

    # Use the vtysh output, with some masking to make comparison easy
    vrf_name = "{0}-cust1".format(rname)
    current = topotest.ip6_route_zebra(tgen.gears[rname], vrf_name)

    # Use just the 'O'spf lines of the output
    linearr = []
    for line in current.splitlines():
        if re.match("^O", line):
            linearr.append(line)

    current = "\n".join(linearr)

    return topotest.difflines(
        topotest.normalize_text(current),
        topotest.normalize_text(expected),
        title1="Current output",
        title2="Expected output",
    )
Beispiel #3
0
def compare_mpls_table(rname, expected):
    """
    Calls 'show mpls table json' for router `rname` and compare the obtained
    result with the expected output.
    """
    tgen = get_topogen()
    current = tgen.gears[rname].vtysh_cmd('show mpls table json')
    return topotest.difflines(current, expected,
                              title1="Current output",
                              title2="Expected output")
Beispiel #4
0
def compare_mpls_table(rname, expected):
    """
    Calls 'show mpls table json' for router `rname` and compare the obtained
    result with the expected output.
    """
    tgen = get_topogen()
    current = tgen.gears[rname].vtysh_cmd('show mpls table json')
    return topotest.difflines(current,
                              expected,
                              title1="Current output",
                              title2="Expected output")
Beispiel #5
0
def compare_ospf_srdb(rname, expected):
    """
    Calls 'show ip ospf database segment-routing json' for router `rname`
    and compare the obtained result with the expected output.
    """
    tgen = get_topogen()
    current = tgen.gears[rname].vtysh_cmd(
        'show ip ospf database segment-routing json')
    return topotest.difflines(current, expected,
                              title1="Current output",
                              title2="Expected output")
Beispiel #6
0
def compare_show_ip_route_vrf(rname, expected, vrf_name):
    """
    Calls 'show ip route vrf [vrf_name] route' and compare the obtained
    result with the expected output.
    """
    tgen = get_topogen()
    current = topotest.ip4_route_zebra(tgen.gears[rname], vrf_name)
    ret = topotest.difflines(current,
                             expected,
                             title1="Current output",
                             title2="Expected output")
    return ret
Beispiel #7
0
def compare_show_ip_route_vrf(rname, expected):
    """
    Calls 'show ip ospf vrf [rname]-cust1 route' for router `rname` and compare the obtained
    result with the expected output.
    """
    tgen = get_topogen()
    vrf_name = "{0}-cust1".format(rname)
    current = topotest.ip4_route_zebra(tgen.gears[rname], vrf_name)
    ret = topotest.difflines(
        current, expected, title1="Current output", title2="Expected output"
    )
    return ret
Beispiel #8
0
def compare_show_ip_route_vrf(rname, expected):
    """
    Calls 'show ip ospf vrf [rname]-cust1 route' for router `rname` and compare the obtained
    result with the expected output.
    """
    tgen = get_topogen()
    vrf_name = '{0}-cust1'.format(rname)
    current = topotest.ip4_route_zebra(tgen.gears[rname], vrf_name)
    ret = topotest.difflines(current, expected,
                             title1="Current output",
                             title2="Expected output")
    return ret
Beispiel #9
0
def compare_show_ip_ospf_vrf(rname, expected):
    """
    Calls 'show ip ospf vrf [rname]-cust1 route' for router `rname` and compare the obtained
    result with the expected output.
    """
    tgen = get_topogen()
    if tgen.gears[rname].has_version('<', '4.0') == True:
        return
    current = tgen.gears[rname].vtysh_cmd('show ip ospf vrf {0}-cust1 route'.format(rname))
    return topotest.difflines(current, expected,
                              title1="Current output",
                              title2="Expected output")
Beispiel #10
0
def compare_ospf_srdb(rname, expected):
    """
    Calls 'show ip ospf database segment-routing json' for router `rname`
    and compare the obtained result with the expected output.
    """
    tgen = get_topogen()
    current = tgen.gears[rname].vtysh_cmd(
        'show ip ospf database segment-routing json')
    return topotest.difflines(current,
                              expected,
                              title1="Current output",
                              title2="Expected output")
Beispiel #11
0
def compare_mpls_table(rname, expected):
    """
    Calls 'show mpls table json' for router `rname` and compare the obtained
    result with the expected output.
    """
    tgen = get_topogen()
    current = tgen.gears[rname].vtysh_cmd("show mpls table json")
    # Filter Adjacency SID allocation
    current = re.sub(r'"5000[0-9]":', '"XX":', current)
    current = re.sub(r'"inLabel":5000[0-9],', '"inLabel":"XX",', current)
    return topotest.difflines(
        current, expected, title1="Current output", title2="Expected output"
    )
Beispiel #12
0
def compare_ospf_srdb(rname, expected):
    """
    Calls 'show ip ospf database segment-routing json' for router `rname`
    and compare the obtained result with the expected output.
    """
    tgen = get_topogen()
    current = tgen.gears[rname].vtysh_cmd("show ip ospf database segment-routing json")
    # Filter Adjacency SID allocation
    current = re.sub(r'"sid":5000[0-9],', '"sid":"XX",', current)
    current = re.sub(r'"inputLabel":5000[0-9],', '"inputLabel":"XX",', current)
    return topotest.difflines(
        current, expected, title1="Current output", title2="Expected output"
    )
Beispiel #13
0
def compare_show_ipv6_ospf6(rname, expected):
    """
    Calls 'show ipv6 ospf6 route' for router `rname` and compare the obtained
    result with the expected output.
    """
    tgen = get_topogen()
    current = tgen.gears[rname].vtysh_cmd("show ipv6 ospf6 route")

    # Remove the link addresses
    current = re.sub(r"fe80::[^ ]+", "fe80::xxxx:xxxx:xxxx:xxxx", current)
    expected = re.sub(r"fe80::[^ ]+", "fe80::xxxx:xxxx:xxxx:xxxx", expected)

    # Remove the time
    current = re.sub(r"\d+:\d{2}:\d{2}", "", current)
    expected = re.sub(r"\d+:\d{2}:\d{2}", "", expected)

    return topotest.difflines(
        topotest.normalize_text(current),
        topotest.normalize_text(expected),
        title1="Current output",
        title2="Expected output",
    )