예제 #1
0
def test_ospfv3_show_p1(request):
    """Verify ospf show commands with json output."""
    tc_name = request.node.name
    write_test_header(tc_name)
    tgen = get_topogen()

    # Don't run this test if we have any failure.
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    input_dict = {
        "r2": {
            "debug": {
                "log_file": "debug.log",
                "enable": ["ospf6"]
            }
        }
    }

    result = create_debug_log_config(tgen, input_dict)

    # Code coverage steps #Do Not upstream
    input_dict_config = {
        "r1": {
            "raw_config": [
                "end",
                "debug ospf6 event",
                "debug ospf6 gr helper",
                "debug ospf6 ism events",
                "debug ospf6 ism status",
                "debug ospf6 ism timers",
                "debug ospf6 nsm events",
                "debug ospf6 nsm status",
                "debug ospf6 nsm timers ",
                "debug ospf6 nssa",
                "debug ospf6 lsa aggregate",
                "debug ospf6 lsa flooding ",
                "debug ospf6 lsa generate",
                "debug ospf6 lsa install ",
                "debug ospf6 lsa refresh",
                "debug ospf6 packet all detail",
                "debug ospf6 packet all recv",
                "debug ospf6 packet all send",
                "debug ospf6 packet dd detail",
                "debug ospf6 packet dd recv",
                "debug ospf6 packet dd send ",
                "debug ospf6 packet hello detail",
                "debug ospf6 packet hello recv",
                "debug ospf6 packet hello send",
                "debug ospf6 packet ls-ack detail",
                "debug ospf6 packet ls-ack recv",
                "debug ospf6 packet ls-ack send",
                "debug ospf6 packet ls-request detail",
                "debug ospf6 packet ls-request recv",
                "debug ospf6 packet ls-request send",
                "debug ospf6 packet ls-update detail",
                "debug ospf6 packet ls-update recv",
                "debug ospf6 packet ls-update send",
                "debug ospf6 sr",
                "debug ospf6 te ",
                "debug ospf6 zebra interface",
                "debug ospf6 zebra redistribute",
            ]
        }
    }

    apply_raw_config(tgen, input_dict_config)

    for rtr in topo["routers"]:
        clear_ospf(tgen, rtr, ospf="ospf6")

    step(" Bring up the base config as per the topology")
    reset_config_on_routers(tgen)

    for rtr in topo["routers"]:
        clear_ospf(tgen, rtr, ospf="ospf6")

    dut = "r1"
    input_dict = {
        "r1": {
            "links": {
                "r0": {
                    "ospf6": {
                        "status": "up",
                        "type": "BROADCAST",
                        "ospf6Enabled": True,
                        "attachedToArea": True,
                        "instanceId": 0,
                        "interfaceMtu": 1500,
                        "autoDetect": 1500,
                        "mtuMismatchDetection": "enabled",
                        "areaId": "0.0.0.0",
                        "cost": 10,
                        "transmitDelaySec": 1,
                        "priority": 1,
                        "timerIntervalsConfigHello": 1,
                        "timerIntervalsConfigDead": 4,
                        "timerIntervalsConfigRetransmit": 5,
                        "dr": "0.0.0.0",
                        "bdr": "0.0.0.0",
                        "numberOfInterfaceScopedLsa": 2,
                        "pendingLsaLsUpdateCount": 0,
                        "lsUpdateSendThread": "off",
                        "pendingLsaLsAckCount": 0,
                        "lsAckSendThread": "off",
                    }
                }
            }
        }
    }
    result = verify_ospf6_interface(tgen, topo, dut=dut, input_dict=input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    ip = topo["routers"]["r0"]["links"]["r3"]["ipv6"]
    ip_net = str(ipaddress.ip_interface(u"{}".format(ip)).network)
    nh = topo["routers"]["r0"]["links"]["r1"]["ipv6"].split("/")[0]
    input_dict = {
        "r1": {
            "static_routes": [{
                "network": ip_net,
                "no_of_ip": 1,
                "routeType": "Network"
            }]
        }
    }

    dut = "r1"
    result = verify_ospf6_rib(tgen, dut, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    write_test_footer(tc_name)
예제 #2
0
def test_ospfv3_ecmp_tc17_p0(request):
    """
    Verify OSPF ECMP.

    Verify OSPF ECMP with max path configured as 2 (Edge having 2 uplink ports)
    """
    tc_name = request.node.name
    write_test_header(tc_name)
    tgen = get_topogen()

    # Don't run this test if we have any failure.
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    global topo
    step("Bring up the base config as per the topology")
    step("Configure 2 interfaces between R1 and R2 & enable ospf in area 0.")

    reset_config_on_routers(tgen)

    step("Verify that OSPF is up with 2 neighborship sessions.")
    dut = "r1"
    ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut)
    assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
        ospf_covergence)

    step("Configure a static route in R0 and redistribute in OSPF.")

    input_dict = {
        "r0": {
            "static_routes": [{
                "network": NETWORK["ipv6"][0],
                "no_of_ip": 5,
                "next_hop": "Null0",
            }]
        }
    }
    result = create_static_routes(tgen, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    dut = "r0"
    red_static(dut)

    step("Verify that route in R2 in stalled with 2 next hops.")

    llip = get_llip("r0", "r1-link1")
    assert llip is not None, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    nh1 = llip

    llip = get_llip("r0", "r1")
    assert llip is not None, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    nh2 = llip

    nh = [nh1, nh2]

    dut = "r1"
    result = verify_ospf6_rib(tgen, dut, input_dict, next_hop=nh)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    protocol = "ospf"
    result = verify_rib(tgen,
                        "ipv6",
                        dut,
                        input_dict,
                        protocol=protocol,
                        next_hop=nh)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Configure ECMP value as 1.")
    max_path = {"r1": {"ospf6": {"maximum-paths": 1}}}
    result = create_router_ospf(tgen, topo, max_path)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    result = verify_rib(tgen,
                        "ipv6",
                        dut,
                        input_dict,
                        protocol=protocol,
                        next_hop=nh2)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    dut = "r1"
    max_path = {"r1": {"ospf6": {"maximum-paths": 2}}}
    result = create_router_ospf(tgen, topo, max_path)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    result = verify_rib(tgen,
                        "ipv6",
                        dut,
                        input_dict,
                        protocol=protocol,
                        next_hop=nh)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Configure cost on R0 as 100")
    r0_ospf_cost = {"r0": {"links": {"r1": {"ospf6": {"cost": 100}}}}}
    result = config_ospf6_interface(tgen, topo, r0_ospf_cost)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    dut = "r1"
    result = verify_ospf6_rib(tgen, dut, input_dict, next_hop=nh)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    protocol = "ospf"
    result = verify_rib(tgen,
                        "ipv6",
                        dut,
                        input_dict,
                        protocol=protocol,
                        next_hop=nh)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    write_test_footer(tc_name)
예제 #3
0
def test_ospfv3_redistribution_tc6_p0(request):
    """Test OSPF inter area route calculations."""
    tc_name = request.node.name
    write_test_header(tc_name)
    tgen = get_topogen()

    # Don't run this test if we have any failure.
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    global topo
    step("Bring up the base config.")
    reset_config_on_routers(tgen)

    step("Verify that OSPF neighbors are FULL.")
    ospf_covergence = verify_ospf6_neighbor(tgen, topo)
    assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
        ospf_covergence
    )

    step("verify intra area route is calculated for r0-r3 interface ip in R1")
    ip = topo["routers"]["r0"]["links"]["r3"]["ipv6"]
    ip_net = str(ipaddress.ip_interface(u"{}".format(ip)).network)
    llip = get_llip("r0", "r1")
    assert llip is not None, "Testcase {} : Failed \n Error: {}".format(tc_name, llip)
    nh = llip
    input_dict = {
        "r1": {"static_routes": [{"network": ip_net, "no_of_ip": 1, "routeType": "N"}]}
    }

    dut = "r1"
    result = verify_ospf6_rib(tgen, dut, input_dict, next_hop=nh)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    protocol = "ospf"
    result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol, next_hop=nh)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    step("Delete the ip address on newly configured loopback of R0")
    topo1 = {
        "r0": {
            "links": {
                "r3": {
                    "ipv6": topo["routers"]["r0"]["links"]["r3"]["ipv6"],
                    "interface": topo["routers"]["r0"]["links"]["r3"]["interface"],
                    "delete": True,
                }
            }
        }
    }

    result = create_interfaces_cfg(tgen, topo1)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    dut = "r1"
    result = verify_ospf6_rib(tgen, dut, input_dict, next_hop=nh, expected=False)
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route present in RIB. Error: {}".format(tc_name, result)

    protocol = "ospf"
    result = verify_rib(
        tgen, "ipv6", dut, input_dict, protocol=protocol, next_hop=nh, expected=False
    )
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route present in RIB. Error: {}".format(tc_name, result)

    step("Add back the deleted ip address on newly configured interface of R0")
    topo1 = {
        "r0": {
            "links": {
                "r3": {
                    "ipv6": topo["routers"]["r0"]["links"]["r3"]["ipv6"],
                    "interface": topo["routers"]["r0"]["links"]["r3"]["interface"],
                }
            }
        }
    }

    result = create_interfaces_cfg(tgen, topo1)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    dut = "r1"
    result = verify_ospf6_rib(tgen, dut, input_dict, next_hop=nh)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    protocol = "ospf"
    result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol, next_hop=nh)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    step("Shut no shut interface on R0")
    dut = "r0"
    intf = topo["routers"]["r0"]["links"]["r3"]["interface"]
    shutdown_bringup_interface(tgen, dut, intf, False)

    step("Verify that intraroute calculated for R1 intf on R0 is deleted.")
    dut = "r1"

    step("un shut the OSPF interface on R0")
    dut = "r0"
    shutdown_bringup_interface(tgen, dut, intf, True)

    dut = "r1"
    result = verify_ospf6_rib(tgen, dut, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    protocol = "ospf"
    result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol, next_hop=nh)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    write_test_footer(tc_name)
예제 #4
0
def test_ospfv3_routemaps_functionality_tc24_p0(request):
    """
    OSPF Route map - Multiple set clauses.

    Verify OSPF route map support functionality when we
    add/remove route-maps with multiple match clauses and without
    any set statement.(Match only)

    """
    tc_name = request.node.name
    write_test_header(tc_name)
    tgen = get_topogen()
    global topo
    step("Bring up the base config as per the topology")

    reset_config_on_routers(tgen)

    step(
        "Create static routes(10.0.20.1/32) in R1 and redistribute to "
        "OSPF using route map."
    )
    # Create Static routes
    input_dict = {
        "r0": {
            "static_routes": [
                {
                    "network": NETWORK["ipv6"][0],
                    "no_of_ip": 1,
                    "next_hop": "Null0",
                }
            ]
        }
    }
    result = create_static_routes(tgen, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    ospf_red_r0 = {
        "r0": {
            "ospf6": {
                "redistribute": [{"redist_type": "static", "route_map": "rmap_ipv6"}]
            }
        }
    }
    result = create_router_ospf(tgen, topo, ospf_red_r0)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    # Create ip prefix list
    pfx_list = {
        "r0": {
            "prefix_lists": {
                "ipv6": {
                    "pf_list_1_ipv6": [
                        {"seqid": 10, "network": "any", "action": "permit"}
                    ]
                }
            }
        }
    }
    result = create_prefix_lists(tgen, pfx_list)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    step("verify that prefix-list is created in R0.")
    result = verify_prefix_lists(tgen, pfx_list)
    assert (
        result is not True
    ), "Testcase {} : Failed \n Prefix list not " "present. Error: {}".format(
        tc_name, result
    )

    # Create route map
    routemaps = {
        "r0": {
            "route_maps": {
                "rmap_ipv6": [
                    {
                        "action": "permit",
                        "match": {"ipv6": {"prefix_lists": "pf_list_1_ipv6"}},
                    }
                ]
            }
        }
    }
    result = create_route_maps(tgen, routemaps)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    step("Verify that metric falls back to original metric for ospf routes.")
    dut = "r1"
    protocol = "ospf"

    result = verify_ospf6_rib(tgen, dut, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    step(
        "Create static routes(10.0.20.1/32) in R1 and redistribute to "
        "OSPF using route map."
    )
    # Create Static routes
    input_dict = {
        "r0": {
            "static_routes": [
                {
                    "network": NETWORK["ipv6"][1],
                    "no_of_ip": 1,
                    "next_hop": "Null0",
                    "tag": 1000,
                }
            ]
        }
    }
    result = create_static_routes(tgen, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    # Create ip prefix list
    pfx_list = {
        "r0": {
            "prefix_lists": {
                "ipv6": {
                    "pf_list_1_ipv6": [
                        {"seqid": 10, "network": "any", "action": "permit"}
                    ]
                }
            }
        }
    }
    result = create_prefix_lists(tgen, pfx_list)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    step("verify that prefix-list is created in R0.")
    result = verify_prefix_lists(tgen, pfx_list)
    assert (
        result is not True
    ), "Testcase {} : Failed \n Prefix list not " "present. Error: {}".format(
        tc_name, result
    )

    # Create route map
    routemaps = {
        "r0": {
            "route_maps": {
                "rmap_ipv6": [{"action": "permit", "match": {"ipv6": {"tag": "1000"}}}]
            }
        }
    }
    result = create_route_maps(tgen, routemaps)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    step("Verify that metric falls back to original metric for ospf routes.")
    dut = "r1"
    protocol = "ospf"

    result = verify_ospf6_rib(tgen, dut, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    step("Delete the match clause with tag in route map")
    # Create route map
    routemaps = {
        "r0": {
            "route_maps": {
                "rmap_ipv6": [
                    {
                        "action": "permit",
                        "match": {"ipv6": {"tag": "1000", "delete": True}},
                    }
                ]
            }
        }
    }
    result = create_route_maps(tgen, routemaps)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    step("Verify that metric falls back to original metric for ospf routes.")
    dut = "r1"
    protocol = "ospf"

    result = verify_ospf6_rib(tgen, dut, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    step("Delete the match clause with metric in route map.")

    # Create route map
    routemaps = {
        "r0": {
            "route_maps": {
                "rmap_ipv6": [
                    {
                        "action": "permit",
                        "match": {"ipv6": {"prefix_lists": "pf_list_1_ipv6"}},
                    }
                ]
            }
        }
    }
    result = create_route_maps(tgen, routemaps)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    result = verify_ospf6_rib(tgen, dut, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    write_test_footer(tc_name)
예제 #5
0
def test_ospfv3_ecmp_tc16_p0(request):
    """
    Verify OSPF ECMP.

    Verify OSPF ECMP with max path configured as 8 (ECMP
    configured at FRR level)
    """
    tc_name = request.node.name
    write_test_header(tc_name)
    tgen = get_topogen()

    # Don't run this test if we have any failure.
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    global topo
    step("Bring up the base config as per the topology")
    step("Configure 8 interfaces between R1 and R2 and enable ospf in area 0.")

    reset_config_on_routers(tgen)

    step("Verify that OSPF is up with 8 neighborship sessions.")
    dut = "r1"
    ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut)
    assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
        ospf_covergence)

    step("Configure a static route in R0 and redistribute in OSPF.")

    input_dict = {
        "r0": {
            "static_routes": [{
                "network": NETWORK["ipv6"][0],
                "no_of_ip": 5,
                "next_hop": "Null0",
            }]
        }
    }
    result = create_static_routes(tgen, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    dut = "r0"
    red_static(dut)

    llip = get_llip("r0", "r1-link1")
    assert llip is not None, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Verify that route in R2 in stalled with 8 next hops.")
    nh = []
    for item in range(1, 7):
        nh.append(llip)

    llip = get_llip("r0", "r1")
    assert llip is not None, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    nh2 = llip

    nh.append(nh2)

    dut = "r1"
    result = verify_ospf6_rib(tgen, dut, input_dict, next_hop=nh)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    protocol = "ospf"
    result = verify_rib(tgen,
                        "ipv6",
                        dut,
                        input_dict,
                        protocol=protocol,
                        next_hop=nh)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("shut no shut all the interfaces on the remote router - R2")
    dut = "r1"
    for intfr in range(1, 7):
        intf = topo["routers"]["r1"]["links"]["r0-link{}".format(
            intfr)]["interface"]
        shutdown_bringup_interface(tgen, dut, intf, False)

    result = verify_ospf6_rib(tgen,
                              dut,
                              input_dict,
                              next_hop=nh,
                              expected=False)
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route present in OSPF RIB.  Error: {}".format(
        tc_name, result)

    protocol = "ospf"
    result = verify_rib(tgen,
                        "ipv6",
                        dut,
                        input_dict,
                        protocol=protocol,
                        next_hop=nh,
                        expected=False)
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route present in RIB. Error: {}".format(
        tc_name, result)

    for intfr in range(1, 7):
        intf = topo["routers"]["r1"]["links"]["r0-link{}".format(
            intfr)]["interface"]
        shutdown_bringup_interface(tgen, dut, intf, True)

    result = verify_ospf6_rib(tgen, dut, input_dict, next_hop=nh)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    protocol = "ospf"
    result = verify_rib(tgen,
                        "ipv6",
                        dut,
                        input_dict,
                        protocol=protocol,
                        next_hop=nh)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("shut no shut on all the interfaces on DUT (r1)")
    for intfr in range(1, 7):
        intf = topo["routers"]["r1"]["links"]["r0-link{}".format(
            intfr)]["interface"]
        shutdown_bringup_interface(tgen, dut, intf, False)

    for intfr in range(1, 7):
        intf = topo["routers"]["r1"]["links"]["r0-link{}".format(
            intfr)]["interface"]
        shutdown_bringup_interface(tgen, dut, intf, True)

    step("Verify that all the neighbours are up and routes are installed"
         " with 8 next hop in ospf and ip route tables on R1.")

    step("Verify that OSPF is up with 8 neighborship sessions.")
    dut = "r1"
    ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut)
    assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
        ospf_covergence)

    dut = "r1"
    result = verify_ospf6_rib(tgen, dut, input_dict, next_hop=nh)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    protocol = "ospf"
    result = verify_rib(tgen,
                        "ipv6",
                        dut,
                        input_dict,
                        protocol=protocol,
                        next_hop=nh)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    write_test_footer(tc_name)
예제 #6
0
def test_ospfv3_routemaps_functionality_tc25_p0(request):
    """
    OSPF route map support functionality.

    Verify OSPF route map support functionality
    when route map actions are toggled.

    """
    tc_name = request.node.name
    write_test_header(tc_name)
    tgen = get_topogen()
    global topo
    step("Bring up the base config as per the topology")

    reset_config_on_routers(tgen)

    step(
        "Create static routes(10.0.20.1/32) in R1 and redistribute "
        "to OSPF using route map."
    )

    # Create Static routes
    input_dict = {
        "r0": {
            "static_routes": [
                {
                    "network": NETWORK["ipv6"][0],
                    "no_of_ip": 5,
                    "next_hop": "Null0",
                }
            ]
        }
    }
    result = create_static_routes(tgen, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    ospf_red_r0 = {
        "r0": {
            "ospf6": {
                "redistribute": [{"redist_type": "static", "route_map": "rmap_ipv6"}]
            }
        }
    }
    result = create_router_ospf(tgen, topo, ospf_red_r0)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
    step("Configure route map with permit rule")
    # Create route map
    routemaps = {"r0": {"route_maps": {"rmap_ipv6": [{"action": "permit"}]}}}
    result = create_route_maps(tgen, routemaps)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    step("Verify that route is advertised to R1.")
    dut = "r1"
    protocol = "ospf"
    result = verify_ospf6_rib(tgen, dut, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
    step("Configure route map with deny rule")
    # Create route map
    routemaps = {
        "r0": {"route_maps": {"rmap_ipv6": [{"seq_id": 10, "action": "deny"}]}}
    }
    result = create_route_maps(tgen, routemaps)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    # Api call verify whether OSPF is converged
    ospf_covergence = verify_ospf6_neighbor(tgen, topo)
    assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
        ospf_covergence
    )

    step("Verify that route is not advertised to R1.")
    dut = "r1"
    protocol = "ospf"
    result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
        tc_name, result
    )

    result = verify_rib(
        tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
    )
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
        tc_name, result
    )

    write_test_footer(tc_name)
예제 #7
0
def test_ospfv3_routemaps_functionality_tc22_p0(request):
    """
    OSPF Route map - Multiple sequence numbers.

    Verify OSPF route map support  functionality with multiple sequence
    numbers in a single  route-map for different match/set clauses.

    """
    tc_name = request.node.name
    write_test_header(tc_name)
    tgen = get_topogen()
    global topo
    step("Bring up the base config as per the topology")

    reset_config_on_routers(tgen)

    step(
        "Configure route map with seq number 10 to with ip prefix"
        " permitting route 10.0.20.1/32 in R1"
    )
    step(
        "Configure route map with seq number 20 to with  ip prefix"
        "  permitting route 10.0.20.2/32 in R1"
    )

    # Create route map
    input_dict_3 = {
        "r0": {
            "route_maps": {
                "rmap_ipv6": [
                    {
                        "action": "permit",
                        "seq_id": "10",
                        "match": {"ipv6": {"prefix_lists": "pf_list_1_ipv6"}},
                    },
                    {
                        "action": "permit",
                        "seq_id": "20",
                        "match": {"ipv6": {"prefix_lists": "pf_list_2_ipv4"}},
                    },
                ]
            }
        }
    }
    result = create_route_maps(tgen, input_dict_3)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    # Create ip prefix list
    input_dict_2 = {
        "r0": {
            "prefix_lists": {
                "ipv4": {
                    "pf_list_1_ipv6": [
                        {"seqid": 10, "network": NETWORK["ipv6"][0], "action": "permit"}
                    ]
                }
            }
        }
    }
    result = create_prefix_lists(tgen, input_dict_2)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    # Create ip prefix list
    input_dict_2 = {
        "r0": {
            "prefix_lists": {
                "ipv4": {
                    "pf_list_2_ipv4": [
                        {"seqid": 10, "network": NETWORK["ipv6"][1], "action": "permit"}
                    ]
                }
            }
        }
    }
    result = create_prefix_lists(tgen, input_dict_2)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    step("Configure static routes 10.0.20.1/32 and 10.0.20.2 in R1")
    # Create Static routes
    input_dict = {
        "r0": {
            "static_routes": [
                {
                    "network": NETWORK["ipv6"][0],
                    "no_of_ip": 5,
                    "next_hop": "Null0",
                }
            ]
        }
    }
    result = create_static_routes(tgen, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    step("Configure redistribute static route with route map.")
    ospf_red_r0 = {
        "r0": {
            "ospf6": {
                "redistribute": [{"redist_type": "static", "route_map": "rmap_ipv6"}]
            }
        }
    }
    result = create_router_ospf(tgen, topo, ospf_red_r0)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    input_dict = {
        "r0": {
            "static_routes": [
                {
                    "network": NETWORK["ipv6"][0],
                    "no_of_ip": 2,
                    "next_hop": "Null0",
                }
            ]
        }
    }
    result = create_static_routes(tgen, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    step("Verify that both routes are learned in R1 and R2")
    dut = "r1"
    protocol = "ospf"
    result = verify_ospf6_rib(tgen, dut, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    dut = "r2"
    protocol = "ospf"
    result = verify_ospf6_rib(tgen, dut, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    step("Change route map with seq number 20 to deny.")
    # Create route map
    input_dict_3 = {
        "r0": {
            "route_maps": {
                "rmap_ipv6": [
                    {
                        "action": "deny",
                        "seq_id": "20",
                        "match": {"ipv6": {"prefix_lists": "pf_list_2_ipv4"}},
                    }
                ]
            }
        }
    }
    result = create_route_maps(tgen, input_dict_3)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    step(
        "Verify the route 10.0.20.2/32 is withdrawn and not present "
        "in the routing table of R0 and R1."
    )

    input_dict = {
        "r0": {"static_routes": [{"network": NETWORK["ipv6"][1], "next_hop": "Null0"}]}
    }

    dut = "r1"
    protocol = "ospf"
    result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
        tc_name, result
    )

    result = verify_rib(
        tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
    )
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
        tc_name, result
    )

    dut = "r2"
    protocol = "ospf"
    result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
        tc_name, result
    )

    result = verify_rib(
        tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
    )
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
        tc_name, result
    )

    write_test_footer(tc_name)
예제 #8
0
def test_ospfv3_routemaps_functionality_tc20_p0(request):
    """
    OSPF route map support functionality.

    Verify OSPF route map support functionality when route map is not
    configured at system level but configured in OSPF

    """
    tc_name = request.node.name
    write_test_header(tc_name)
    tgen = get_topogen()
    global topo
    step("Bring up the base config as per the topology")

    reset_config_on_routers(tgen)

    step("Create static routes(10.0.20.1/32 and 10.0.20.2/32) in R0")
    # Create Static routes
    input_dict = {
        "r0": {
            "static_routes": [
                {
                    "network": NETWORK["ipv6"][0],
                    "no_of_ip": 5,
                    "next_hop": "Null0",
                }
            ]
        }
    }
    result = create_static_routes(tgen, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    step("Redistribute to ospf using route map ( non existent route map)")
    ospf_red_r1 = {
        "r0": {
            "ospf6": {
                "redistribute": [{"redist_type": "static", "route_map": "rmap_ipv6"}]
            }
        }
    }
    result = create_router_ospf(tgen, topo, ospf_red_r1)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    step(
        "Verify that routes are not allowed in OSPF even tough no "
        "matching routing map is configured."
    )

    dut = "r1"
    protocol = "ospf"
    result = verify_ospf6_rib(tgen, dut, input_dict)
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
        tc_name, result
    )

    result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
        tc_name, result
    )

    step(
        "configure the route map with the same name that is used "
        "in the ospf with deny rule."
    )

    # Create route map
    routemaps = {"r0": {"route_maps": {"rmap_ipv6": [{"action": "deny"}]}}}
    result = create_route_maps(tgen, routemaps)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    step("verify that now route map is activated & routes are denied in OSPF.")
    dut = "r1"
    protocol = "ospf"
    result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
        tc_name, result
    )

    result = verify_rib(
        tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
    )
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
        tc_name, result
    )

    # Create route map
    routemaps = {"r0": {"route_maps": {"rmap_ipv6": [{"action": "deny"}]}}}
    result = create_route_maps(tgen, routemaps)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    step("verify that now route map is activated & routes are denied in OSPF.")
    dut = "r1"
    protocol = "ospf"
    result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
        tc_name, result
    )

    result = verify_rib(
        tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
    )
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
        tc_name, result
    )

    step("Delete the route map.")
    # Create route map
    routemaps = {
        "r0": {"route_maps": {"rmap_ipv6": [{"action": "deny", "delete": True}]}}
    }
    result = create_route_maps(tgen, routemaps)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)

    step(
        "Verify that routes are allowed in OSPF even tough "
        "no matching routing map is configured."
    )
    dut = "r1"
    protocol = "ospf"
    result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
        tc_name, result
    )

    result = verify_rib(
        tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
    )
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
        tc_name, result
    )

    write_test_footer(tc_name)
예제 #9
0
def test_ospfv3_routemaps_functionality_tc19_p0(request):
    """
    OSPF Route map - Verify OSPF route map support functionality.

    """
    tc_name = request.node.name
    write_test_header(tc_name)
    tgen = get_topogen()
    global topo
    step("Bring up the base config as per the topology")
    reset_config_on_routers(tgen)

    step("Create static routes(10.0.20.1/32 and 10.0.20.2/32) in R0")
    # Create Static routes
    input_dict = {
        "r0": {
            "static_routes": [{
                "network": NETWORK["ipv6"][0],
                "no_of_ip": 5,
                "next_hop": "Null0",
            }]
        }
    }
    result = create_static_routes(tgen, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    ospf_red_r1 = {
        "r0": {
            "ospf6": {
                "redistribute": [{
                    "redist_type": "static"
                }]
            }
        }
    }
    result = create_router_ospf(tgen, topo, ospf_red_r1)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    dut = "r1"
    lsid = NETWORK["ipv6"][0].split("/")[0]
    rid = routerids[0]

    protocol = "ospf"
    result = verify_ospf6_rib(tgen, dut, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    ospf_red_r1 = {
        "r0": {
            "ospf6": {
                "redistribute": [{
                    "redist_type": "static",
                    "del_action": True
                }]
            }
        }
    }
    result = create_router_ospf(tgen, topo, ospf_red_r1)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Create prefix-list in R0 to permit 10.0.20.1/32 prefix &"
         " deny 10.0.20.2/32")

    # Create ip prefix list
    pfx_list = {
        "r0": {
            "prefix_lists": {
                "ipv6": {
                    "pf_list_1_ipv6": [
                        {
                            "seqid": 10,
                            "network": NETWORK["ipv6"][0],
                            "action": "permit",
                        },
                        {
                            "seqid": 11,
                            "network": "any",
                            "action": "deny"
                        },
                    ]
                }
            }
        }
    }
    result = create_prefix_lists(tgen, pfx_list)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("verify that prefix-list is created in R0.")
    result = verify_prefix_lists(tgen, pfx_list)
    assert (
        result is not True
    ), "Testcase {} : Failed \n, prefix list creation failed. Error: {}".format(
        tc_name, result)

    # Create route map
    routemaps = {
        "r0": {
            "route_maps": {
                "rmap_ipv6": [{
                    "action": "permit",
                    "match": {
                        "ipv6": {
                            "prefix_lists": "pf_list_1_ipv6"
                        }
                    },
                }]
            }
        }
    }
    result = create_route_maps(tgen, routemaps)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Configure route map rmap1 and redistribute static routes to"
         " ospf using route map rmap1")

    ospf_red_r1 = {
        "r0": {
            "ospf6": {
                "redistribute": [{
                    "redist_type": "static",
                    "route_map": "rmap_ipv6"
                }]
            }
        }
    }
    result = create_router_ospf(tgen, topo, ospf_red_r1)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)
    step("Verify that route map is activated in OSPF.")

    step("Verify that route 10.0.20.1 is allowed and 10.0.20.2 is denied.")
    dut = "r1"
    input_dict = {
        "r0": {
            "static_routes": [{
                "network": NETWORK["ipv6"][0],
                "no_of_ip": 1,
                "next_hop": "Null0"
            }]
        }
    }
    result = verify_ospf6_rib(tgen, dut, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    dut = "r1"
    lsid = NETWORK["ipv6"][1].split("/")[0]
    rid = routerids[0]

    step("Change prefix rules to permit 10.0.20.2 and deny 10.0.20.1")
    # Create ip prefix list
    pfx_list = {
        "r0": {
            "prefix_lists": {
                "ipv6": {
                    "pf_list_1_ipv6": [
                        {
                            "seqid": 10,
                            "network": NETWORK["ipv6"][1],
                            "action": "permit",
                        },
                        {
                            "seqid": 11,
                            "network": "any",
                            "action": "deny"
                        },
                    ]
                }
            }
        }
    }
    result = create_prefix_lists(tgen, pfx_list)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Verify that route 10.0.20.2 is allowed and 10.0.20.1 is denied.")
    dut = "r1"
    input_dict = {
        "r0": {
            "static_routes": [{
                "network": NETWORK["ipv6"][1],
                "no_of_ip": 1,
                "next_hop": "Null0"
            }]
        }
    }
    result = verify_ospf6_rib(tgen, dut, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    input_dict = {
        "r0": {
            "static_routes": [{
                "network": NETWORK["ipv6"][0],
                "no_of_ip": 1,
                "next_hop": "Null0"
            }]
        }
    }
    result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route found in the RIB,  Error: {}".format(
        tc_name, result)

    result = verify_rib(tgen,
                        "ipv6",
                        dut,
                        input_dict,
                        protocol=protocol,
                        expected=False)
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
        tc_name, result)

    step("Delete and reconfigure prefix list.")
    # Create ip prefix list
    pfx_list = {
        "r0": {
            "prefix_lists": {
                "ipv6": {
                    "pf_list_1_ipv6": [
                        {
                            "seqid": 10,
                            "network": NETWORK["ipv6"][1],
                            "action": "permit",
                            "delete": True,
                        },
                        {
                            "seqid": 11,
                            "network": "any",
                            "action": "deny",
                            "delete": True,
                        },
                    ]
                }
            }
        }
    }
    result = create_prefix_lists(tgen, pfx_list)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    result = verify_prefix_lists(tgen, pfx_list)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    input_dict = {
        "r0": {
            "static_routes": [{
                "network": NETWORK["ipv6"][0],
                "no_of_ip": 5,
                "next_hop": "Null0"
            }]
        }
    }
    result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
        tc_name, result)

    result = verify_rib(tgen,
                        "ipv6",
                        dut,
                        input_dict,
                        protocol=protocol,
                        expected=False)
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
        tc_name, result)

    pfx_list = {
        "r0": {
            "prefix_lists": {
                "ipv6": {
                    "pf_list_1_ipv6": [
                        {
                            "seqid": 10,
                            "network": NETWORK["ipv6"][1],
                            "action": "permit",
                        },
                        {
                            "seqid": 11,
                            "network": "any",
                            "action": "deny"
                        },
                    ]
                }
            }
        }
    }
    result = create_prefix_lists(tgen, pfx_list)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Verify that route 10.0.20.2 is allowed and 10.0.20.1 is denied.")
    dut = "r1"
    input_dict = {
        "r0": {
            "static_routes": [{
                "network": NETWORK["ipv6"][1],
                "no_of_ip": 1,
                "next_hop": "Null0"
            }]
        }
    }
    result = verify_ospf6_rib(tgen, dut, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    input_dict = {
        "r0": {
            "static_routes": [{
                "network": NETWORK["ipv6"][0],
                "no_of_ip": 1,
                "next_hop": "Null0"
            }]
        }
    }
    result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
        tc_name, result)

    result = verify_rib(tgen,
                        "ipv6",
                        dut,
                        input_dict,
                        protocol=protocol,
                        expected=False)
    assert (
        result is not True
    ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
        tc_name, result)

    write_test_footer(tc_name)
예제 #10
0
def test_ospfv3_routemaps_functionality_tc23_p0(request):
    """
    OSPF Route map - Multiple set clauses.

    Verify OSPF route map support functionality when we add/remove route-maps
    with multiple set clauses and without any match statement.(Set only)

    """
    tc_name = request.node.name
    write_test_header(tc_name)
    tgen = get_topogen()
    global topo
    step("Bring up the base config as per the topology")

    reset_config_on_routers(tgen)

    step(" Create static routes(10.0.20.1/32) in R1 and "
         "redistribute to OSPF using route map.")
    # Create Static routes
    input_dict = {
        "r0": {
            "static_routes": [{
                "network": NETWORK["ipv6"][0],
                "no_of_ip": 5,
                "next_hop": "Null0",
            }]
        }
    }
    result = create_static_routes(tgen, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    ospf_red_r0 = {
        "r0": {
            "ospf6": {
                "redistribute": [{
                    "redist_type": "static",
                    "route_map": "rmap_ipv6"
                }]
            }
        }
    }
    result = create_router_ospf(tgen, topo, ospf_red_r0)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Configure route map with set clause (set metric)")
    # Create route map
    routemaps = {
        "r0": {
            "route_maps": {
                "rmap_ipv6": [{
                    "action": "permit",
                    "seq_id": 10,
                    "set": {
                        "metric": 123
                    }
                }]
            }
        }
    }
    result = create_route_maps(tgen, routemaps)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Verify that configured metric is applied to ospf routes.")
    dut = "r1"
    protocol = "ospf"

    result = verify_ospf6_rib(tgen, dut, input_dict, metric=123)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    result = verify_rib(tgen,
                        "ipv6",
                        dut,
                        input_dict,
                        protocol=protocol,
                        metric=123)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("un configure the set clause")
    # Create route map
    routemaps = {
        "r0": {
            "route_maps": {
                "rmap_ipv6": [{
                    "action": "permit",
                    "seq_id": 10,
                    "set": {
                        "metric": 123,
                        "delete": True
                    },
                }]
            }
        }
    }
    result = create_route_maps(tgen, routemaps)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Verify that metric falls back to original metric for ospf routes.")
    dut = "r1"
    protocol = "ospf"

    result = verify_ospf6_rib(tgen, dut, input_dict, metric=20)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    result = verify_rib(tgen,
                        "ipv6",
                        dut,
                        input_dict,
                        protocol=protocol,
                        metric=20)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    write_test_footer(tc_name)
예제 #11
0
def ospfv3_nssa_tc27_p0(request):
    """
    OSPF NSSA.

    Verify that ospf NSSA area DUT is capable receiving & processing
    Type7 N2 route.
    """
    tc_name = request.node.name
    write_test_header(tc_name)
    tgen = get_topogen()

    # Don't run this test if we have any failure.
    if tgen.routers_have_failure():
        check_router_status(tgen)

    global topo
    step("Bring up the base config as per the topology")
    step("Configure ospf area 2 on r0 , r1 & r4, make the area 2 as NSSA area")

    reset_config_on_routers(tgen)

    input_dict = {
        "r2": {
            "static_routes": [{
                "network": NETWORK["ipv6"][0],
                "no_of_ip": 5,
                "next_hop": "Null0"
            }]
        }
    }
    result = create_static_routes(tgen, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Redistribute static route in R2 ospf.")
    dut = "r2"
    red_static(dut)

    step("Verify that Type 5 LSA is originated by R2.")
    dut = "r0"
    protocol = "ospf6"
    result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Un configure redistribute command in R4")
    dut = "r2"
    red_static(dut, config=False)

    input_dict = {
        "r1": {
            "static_routes": [{
                "network": NETWORK["ipv6"][0],
                "no_of_ip": 1,
                "routeType": "Network"
            }]
        }
    }

    dut = "r0"
    result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
    assert result is not True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    result = verify_rib(tgen,
                        "ipv6",
                        dut,
                        input_dict,
                        protocol=protocol,
                        expected=False)
    assert result is not True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    write_test_footer(tc_name)
예제 #12
0
def test_ospfv3_lan_ecmp_tc18_p0(request):
    """
    OSPF ECMP.

    Verify OSPF ECMP with max path configured as 8
    (Edge having 1 uplink port as broadcast network,
    connect to 8 TORs - LAN case)

    """
    tc_name = request.node.name
    write_test_header(tc_name)
    tgen = get_topogen()

    # Don't run this test if we have any failure.
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    global topo
    step("Bring up the base config as per the topology")
    step(". Configure ospf in all the routers on LAN interface.")

    reset_config_on_routers(tgen)

    step("Verify that OSPF is up with 8 neighborship sessions.")

    ospf_covergence = verify_ospf6_neighbor(tgen, topo, lan=True)
    assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
        ospf_covergence)

    step("Configure a static route in all the routes and "
         "redistribute static/connected in OSPF.")

    for rtr in topo["routers"]:
        input_dict = {
            rtr: {
                "static_routes": [{
                    "network": NETWORK["ipv6"][0],
                    "no_of_ip": 5,
                    "next_hop": "Null0"
                }]
            }
        }
        result = create_static_routes(tgen, input_dict)
        assert result is True, "Testcase {} : Failed \n Error: {}".format(
            tc_name, result)

        dut = rtr
        red_static(dut)

    step("Verify that route in R0 in stalled with 8 hops. "
         "Verify ospf route table and ip route table.")

    nh = []
    for rtr in topo["routers"]:
        llip = get_llip(rtr, switch_name)
        assert llip is not None, "Testcase {} : Failed \n Error: {}".format(
            tc_name, result)
        nh.append(llip)

    llip = get_llip("r1", switch_name)
    assert llip is not None, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    nh.remove(llip)
    dut = "r1"
    result = verify_ospf6_rib(tgen, dut, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    protocol = "ospf6"
    result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step(" clear ip ospf interface on DUT(r0)")
    clear_ospf(tgen, "r0", ospf="ospf6")

    step("Verify that after clearing the ospf interface all the "
         "neighbours are up and routes are installed with 8 next hop "
         "in ospf and ip route tables on R0")

    dut = "r0"
    ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut, lan=True)
    assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
        ospf_covergence)

    step(" clear ip ospf interface on R2")
    clear_ospf(tgen, "r2")

    dut = "r2"
    ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut, lan=True)
    assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
        ospf_covergence)

    step("Delete static/connected cmd in ospf in all the routes one by one.")
    for rtr in topo["routers"]:
        input_dict = {
            rtr: {
                "static_routes": [{
                    "network": NETWORK["ipv6"][0],
                    "no_of_ip": 5,
                    "next_hop": "Null0",
                    "delete": True,
                }]
            }
        }
        result = create_static_routes(tgen, input_dict)
        assert result is True, "Testcase {} : Failed \n Error: {}".format(
            tc_name, result)

    write_test_footer(tc_name)