diff --git a/docs/user/lib_mapper/ntctemplates.md b/docs/user/lib_mapper/ntctemplates.md index d3c7ff4e..500c4ca6 100644 --- a/docs/user/lib_mapper/ntctemplates.md +++ b/docs/user/lib_mapper/ntctemplates.md @@ -33,7 +33,7 @@ | cisco_s300 | → | cisco_s300 | | cisco_tp | → | cisco_tp | | cisco_wlc | → | cisco_wlc | -| cisco_xe | → | cisco_ios | +| cisco_xe | → | cisco_xe | | cisco_xr | → | cisco_xr | | cloudgenix_ion | → | cloudgenix_ion | | coriant | → | coriant | diff --git a/docs/user/lib_mapper/ntctemplates_reverse.md b/docs/user/lib_mapper/ntctemplates_reverse.md index ebff60fe..413010ae 100644 --- a/docs/user/lib_mapper/ntctemplates_reverse.md +++ b/docs/user/lib_mapper/ntctemplates_reverse.md @@ -33,6 +33,7 @@ | cisco_s300 | → | cisco_s300 | | cisco_tp | → | cisco_tp | | cisco_wlc | → | cisco_wlc | +| cisco_xe | → | cisco_ios | | cisco_xr | → | cisco_xr | | cloudgenix_ion | → | cloudgenix_ion | | coriant | → | coriant | diff --git a/netutils/lib_mapper.py b/netutils/lib_mapper.py index 8e9d0900..d638958a 100644 --- a/netutils/lib_mapper.py +++ b/netutils/lib_mapper.py @@ -260,7 +260,6 @@ # ntc templates is primarily based on netmiko, so a copy is in order _NTCTEMPLATES_LIB_MAPPER = copy.deepcopy(NETMIKO_LIB_MAPPER) _NTCTEMPLATES_LIB_MAPPER["aruba_aoscx"] = "aruba_aoscx" -_NTCTEMPLATES_LIB_MAPPER["cisco_xe"] = "cisco_ios" # no reverse _NTCTEMPLATES_LIB_MAPPER["huawei_vrp"] = "huawei_vrp" _NTCTEMPLATES_LIB_MAPPER["vmware_nsxv"] = "vmware_nsxv" _NTCTEMPLATES_LIB_MAPPER["watchguard_firebox"] = "watchguard_firebox" @@ -270,12 +269,13 @@ key: _NTCTEMPLATES_LIB_MAPPER[key] for key in sorted(_NTCTEMPLATES_LIB_MAPPER) } # Normalized | NTCTemplates -NTCTEMPLATES_LIB_MAPPER_REVERSE: t.Dict[str, str] = { - value: key - for key, value in NTCTEMPLATES_LIB_MAPPER.items() - if key not in ["f5_ltm", "f5_tmsh", "f5_linux", "cisco_xe"] +_NTCTEMPLATES_LIB_MAPPER_REVERSE: t.Dict[str, str] = { + value: key for key, value in NTCTEMPLATES_LIB_MAPPER.items() if key not in ["f5_ltm", "f5_tmsh", "f5_linux"] } +_NTCTEMPLATES_LIB_MAPPER_REVERSE["cisco_xe"] = "cisco_ios" # only reverse + +NTCTEMPLATES_LIB_MAPPER_REVERSE = copy.deepcopy(_NTCTEMPLATES_LIB_MAPPER_REVERSE) # NAPALM | Normalized NAPALM_LIB_MAPPER: t.Dict[str, str] = { diff --git a/tests/unit/test_lib_mapper.py b/tests/unit/test_lib_mapper.py index 8929220c..3420dce8 100644 --- a/tests/unit/test_lib_mapper.py +++ b/tests/unit/test_lib_mapper.py @@ -64,6 +64,7 @@ def test_lib_mapper_reverse(lib): "FORWARDNETWORKS", "HIERCONFIG", "NETUTILSPARSER", + "NTCTEMPLATES", "NAPALM", "PYATS", "PYNTC", @@ -87,6 +88,14 @@ def test_lib_mapper_reverse(lib): assert mapper == rev_mapper +def test_lib_mapper_ntctemplates_reverse_only(): + """Cisco XE is the only one that has a reverse ONLY mapping.""" + assert lib_mapper.NTCTEMPLATES_LIB_MAPPER_REVERSE["cisco_xe"] == "cisco_ios" + assert lib_mapper.NTCTEMPLATES_LIB_MAPPER_REVERSE["cisco_ios"] == "cisco_ios" + assert lib_mapper.NTCTEMPLATES_LIB_MAPPER["cisco_ios"] == "cisco_ios" + assert lib_mapper.NTCTEMPLATES_LIB_MAPPER["cisco_xe"] == "cisco_xe" + + @pytest.mark.parametrize("lib", LIBRARIES) def test_lib_mapper_alpha(lib): original = list(getattr(lib_mapper, f"{lib}_LIB_MAPPER").keys())