logger.debug("Exiting lib API: clear_ospf()")
+def redistribute_ospf(tgen, topo, dut, route_type, **kwargs):
+ """
+ Redstribution of routes inside ospf.
+
+ Parameters
+ ----------
+ * `tgen`: Topogen object
+ * `topo` : json file data
+ * `dut`: device under test
+ * `route_type`: "static" or "connected" or ....
+ * `kwargs`: pass extra information (see below)
+
+ Usage
+ -----
+ redistribute_ospf(tgen, topo, "r0", "static", delete=True)
+ redistribute_ospf(tgen, topo, "r0", "static", route_map="rmap_ipv4")
+ """
+
+ ospf_red = {dut: {"ospf": {"redistribute": [{"redist_type": route_type}]}}}
+ for k, v in kwargs.items():
+ ospf_red[dut]["ospf"]["redistribute"][0][k] = v
+
+ result = create_router_ospf(tgen, topo, ospf_red)
+ assert result is True, "Testcase : Failed \n Error: {}".format(result)
+
+
################################
# Verification procs
################################
verify_ospf_rib,
create_router_ospf,
verify_ospf_interface,
+ redistribute_ospf,
)
topo = None
logger.info("=" * 40)
-def redistribute(dut, route_type, **kwargs):
- """Local def for redstribution of routes inside ospf."""
- global topo
- tgen = get_topogen()
-
- ospf_red = {dut: {"ospf": {"redistribute": [{"redist_type": route_type}]}}}
- for k, v in kwargs.items():
- ospf_red[dut]["ospf"]["redistribute"][0][k] = v
-
- result = create_router_ospf(tgen, topo, ospf_red)
- assert result is True, "Testcase : Failed \n Error: {}".format(result)
-
-
# ##################################
# Test cases start here.
# ##################################
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
dut = "r0"
- redistribute(dut, "static")
+ redistribute_ospf(tgen, topo, dut, "static")
step("Verify that route in R2 in stalled with 8 next hops.")
nh = []
step(" Un configure static route on R0")
dut = "r0"
- redistribute(dut, "static", delete=True)
+ redistribute_ospf(tgen, topo, dut, "static", delete=True)
# Wait for R0 to flush external LSAs.
sleep(10)
step("Re configure the static route in R0.")
dut = "r0"
- redistribute(dut, "static")
+ redistribute_ospf(tgen, topo, dut, "static")
dut = "r1"
result = verify_ospf_rib(tgen, dut, input_dict, next_hop=nh)
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
dut = "r0"
- redistribute(dut, "static")
+ redistribute_ospf(tgen, topo, dut, "static")
step("Verify that route in R2 in stalled with 2 next hops.")
step(" Un configure static route on R0")
dut = "r0"
- redistribute(dut, "static", delete=True)
+ redistribute_ospf(tgen, topo, dut, "static", delete=True)
# sleep till the route gets withdrawn
sleep(10)
step("Reconfigure the static route in R0.Change ECMP value to 2.")
dut = "r0"
- redistribute(dut, "static")
+ redistribute_ospf(tgen, topo, dut, "static")
step("Configure cost on R0 as 100")
r0_ospf_cost = {"r0": {"links": {"r1": {"ospf": {"cost": 100}}}}}
verify_ospf_rib,
create_router_ospf,
verify_ospf_interface,
+ redistribute_ospf,
)
from ipaddress import IPv4Address
pass
-def redistribute(dut, route_type, **kwargs):
- """Local def for redstribution of routes inside ospf."""
- global topo
- tgen = get_topogen()
-
- ospf_red = {dut: {"ospf": {"redistribute": [{"redist_type": route_type}]}}}
- for k, v in kwargs.items():
- ospf_red[dut]["ospf"]["redistribute"][0][k] = v
-
- result = create_router_ospf(tgen, topo, ospf_red)
- assert result is True, "Testcase : Failed \n Error: {}".format(result)
-
-
# ##################################
# Test cases start here.
# ##################################
)
dut = rtr
- redistribute(dut, "static")
+ redistribute_ospf(tgen, topo, dut, "static")
step(
"Verify that route in R0 in stalled with 8 hops. "
pass
-def redistribute(dut, route_type, **kwargs):
- """Local def for redstribution of routes inside ospf."""
- global topo
- tgen = get_topogen()
-
- ospf_red = {dut: {"ospf": {"redistribute": [{"redist_type": route_type}]}}}
- for k, v in kwargs.items():
- ospf_red[dut]["ospf"]["redistribute"][0][k] = v
-
- result = create_router_ospf(tgen, topo, ospf_red)
- assert result is True, "Testcase : Failed \n Error: {}".format(result)
-
-
# ##################################
# Test cases start here.
# ##################################
verify_ospf_rib,
create_router_ospf,
verify_ospf_interface,
+ redistribute_ospf,
)
from lib.topojson import build_topo_from_json, build_config_from_json
from lib.topolog import logger
logger.info("=" * 40)
-def redistribute(dut, route_type, **kwargs):
- """Local def for redstribution of routes inside ospf."""
- global topo
- tgen = get_topogen()
-
- ospf_red = {dut: {"ospf": {"redistribute": [{"redist_type": route_type}]}}}
- for k, v in kwargs.items():
- ospf_red[dut]["ospf"]["redistribute"][0][k] = v
-
- result = create_router_ospf(tgen, topo, ospf_red)
- assert result is True, "Testcase : Failed \n Error: {}".format(result)
-
-
# ##################################
# Test cases start here.
# ##################################
step("Redistribute static route in R2 ospf.")
dut = "r2"
- redistribute(dut, "static")
+ redistribute_ospf(tgen, topo, dut, "static")
step("Verify that Type 5 LSA is originated by R2.")
dut = "r0"
verify_ospf_rib,
create_router_ospf,
verify_ospf_database,
+ redistribute_ospf,
)
# Global variables
logger.info("=" * 40)
-def redistribute(dut, route_type, **kwargs):
- """Local def for redstribution of routes inside ospf."""
- global topo
- tgen = get_topogen()
-
- ospf_red = {dut: {"ospf": {"redistribute": [{"redist_type": route_type}]}}}
- for k, v in kwargs.items():
- ospf_red[dut]["ospf"]["redistribute"][0][k] = v
-
- result = create_router_ospf(tgen, topo, ospf_red)
- assert result is True, "Testcase : Failed \n Error: {}".format(result)
-
-
# ##################################
# Test cases start here.
# ##################################
result = create_static_routes(tgen, input_dict)
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
- redistribute("r0", "static")
+ redistribute_ospf(tgen, topo, "r0", "static")
dut = "r1"
lsid = NETWORK["ipv4"][0].split("/")[0]
result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol)
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
- redistribute("r0", "static", delete=True)
+ redistribute_ospf(tgen, topo, "r0", "static", delete=True)
step(
"Create prefix-list in R0 to permit 10.0.20.1/32 prefix &" " deny 10.0.20.2/32"
" ospf using route map rmap1"
)
- redistribute("r0", "static", route_map="rmap_ipv4")
+ redistribute_ospf(tgen, topo, "r0", "static", route_map="rmap_ipv4")
step("Change prefix rules to permit 10.0.20.2 and deny 10.0.20.1")
# Create ip prefix list
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
step("Redistribute to ospf using route map ( non existent route map)")
- redistribute("r0", "static", route_map="rmap_ipv4")
+ redistribute_ospf(tgen, topo, "r0", "static", route_map="rmap_ipv4")
step(
"Verify that routes are not allowed in OSPF even tough no "
result = create_static_routes(tgen, input_dict)
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
- redistribute("r0", "static", route_map="rmap_ipv4")
+ redistribute_ospf(tgen, topo, "r0", "static", route_map="rmap_ipv4")
# Create route map
routemaps = {
result = create_static_routes(tgen, input_dict)
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
- redistribute("r0", "static", route_map="rmap_ipv4")
+ redistribute_ospf(tgen, topo, "r0", "static", route_map="rmap_ipv4")
# Create ip prefix list
pfx_list = {
clear_ospf,
verify_ospf_rib,
create_router_ospf,
+ redistribute_ospf,
)
# Global variables
logger.info("=" * 40)
-def redistribute(dut, route_type, **kwargs):
- """Local def for redstribution of routes inside ospf."""
- global topo
- tgen = get_topogen()
-
- ospf_red = {dut: {"ospf": {"redistribute": [{"redist_type": route_type}]}}}
- for k, v in kwargs.items():
- ospf_red[dut]["ospf"]["redistribute"][0][k] = v
-
- result = create_router_ospf(tgen, topo, ospf_red)
- assert result is True, "Testcase : Failed \n Error: {}".format(result)
-
-
# ##################################
# Test cases start here.
# ##################################
"advertised/exchaged via ospf"
)
for rtr in topo["routers"]:
- redistribute(rtr, "static")
- redistribute(rtr, "connected")
+ redistribute_ospf(tgen, topo, rtr, "static")
+ redistribute_ospf(tgen, topo, rtr, "connected")
for node in topo["routers"]:
input_dict = {
"r0": {
)
for rtr in topo["routers"]:
- redistribute(rtr, "static", delete=True)
+ redistribute_ospf(tgen, topo, rtr, "static", delete=True)
input_dict = {
"r0": {