summaryrefslogtreecommitdiff
path: root/tests/topotests/lib/ospf.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/topotests/lib/ospf.py')
-rw-r--r--tests/topotests/lib/ospf.py115
1 files changed, 23 insertions, 92 deletions
diff --git a/tests/topotests/lib/ospf.py b/tests/topotests/lib/ospf.py
index c425e121af..92d29ad1ab 100644
--- a/tests/topotests/lib/ospf.py
+++ b/tests/topotests/lib/ospf.py
@@ -265,35 +265,6 @@ def __create_ospf_global(tgen, input_dict, router, build, load_config, ospf):
cmd = "no {}".format(cmd)
config_data.append(cmd)
- # area interface information for ospf6d only
- if ospf == "ospf6":
- area_iface = ospf_data.setdefault("neighbors", {})
- if area_iface:
- for neighbor in area_iface:
- if "area" in area_iface[neighbor]:
- iface = input_dict[router]["links"][neighbor]["interface"]
- cmd = "interface {} area {}".format(
- iface, area_iface[neighbor]["area"]
- )
- if area_iface[neighbor].setdefault("delete", False):
- cmd = "no {}".format(cmd)
- config_data.append(cmd)
-
- try:
- if "area" in input_dict[router]["links"][neighbor]["ospf6"]:
- iface = input_dict[router]["links"][neighbor]["interface"]
- cmd = "interface {} area {}".format(
- iface,
- input_dict[router]["links"][neighbor]["ospf6"]["area"],
- )
- if input_dict[router]["links"][neighbor].setdefault(
- "delete", False
- ):
- cmd = "no {}".format(cmd)
- config_data.append(cmd)
- except KeyError:
- pass
-
# summary information
summary_data = ospf_data.setdefault("summary-address", {})
if summary_data:
@@ -363,69 +334,6 @@ def __create_ospf_global(tgen, input_dict, router, build, load_config, ospf):
return config_data
-def create_router_ospf6(
- tgen, topo=None, input_dict=None, build=False, load_config=True
-):
- """
- API to configure ospf on router
-
- Parameters
- ----------
- * `tgen` : Topogen object
- * `topo` : json file data
- * `input_dict` : Input dict data, required when configuring from testcase
- * `build` : Only for initial setup phase this is set as True.
-
- Usage
- -----
- input_dict = {
- "r1": {
- "ospf6": {
- "router_id": "22.22.22.22",
- }
- }
-
- Returns
- -------
- True or False
- """
- logger.debug("Entering lib API: create_router_ospf6()")
- result = False
-
- if topo is None:
- topo = tgen.json_topo
-
- if not input_dict:
- input_dict = deepcopy(topo)
- else:
- topo = topo["routers"]
- input_dict = deepcopy(input_dict)
-
- config_data_dict = {}
-
- for router in input_dict.keys():
- if "ospf6" not in input_dict[router]:
- logger.debug("Router %s: 'ospf6' not present in input_dict", router)
- continue
-
- config_data = __create_ospf_global(
- tgen, input_dict, router, build, load_config, "ospf6"
- )
- if config_data:
- config_data_dict[router] = config_data
-
- try:
- result = create_common_configurations(
- tgen, config_data_dict, "ospf6", build, load_config
- )
- except InvalidCLIError:
- logger.error("create_router_ospf6", exc_info=True)
- result = False
-
- logger.debug("Exiting lib API: create_router_ospf6()")
- return result
-
-
def config_ospf_interface(
tgen, topo=None, input_dict=None, build=False, load_config=True
):
@@ -874,6 +782,16 @@ def verify_ospf6_neighbor(tgen, topo=None, dut=None, input_dict=None, lan=False)
}
result = verify_ospf6_neighbor(tgen, topo, dut, input_dict, lan=True)
+ 3. To check there are no neighbors.
+ input_dict = {
+ "r0": {
+ "ospf6": {
+ "neighbors": []
+ }
+ }
+ }
+ result = verify_ospf6_neighbor(tgen, topo, dut, input_dict)
+
Returns
-------
True or False (Error Message)
@@ -904,6 +822,19 @@ def verify_ospf6_neighbor(tgen, topo=None, dut=None, input_dict=None, lan=False)
ospf_data_list = input_dict[router]["ospf6"]
ospf_nbr_list = ospf_data_list["neighbors"]
+ # Check if looking for no neighbors
+ if ospf_nbr_list == []:
+ if show_ospf_json["neighbors"] == []:
+ logger.info("[DUT: {}] OSPF6 no neighbors found".format(router))
+ return True
+ else:
+ errormsg = (
+ "[DUT: {}] OSPF6 active neighbors found, expected None".format(
+ router
+ )
+ )
+ return errormsg
+
for ospf_nbr, nbr_data in ospf_nbr_list.items():
try: