From f5f32e7dcfd7b3d85c5c44cf68b92ed49346ac84 Mon Sep 17 00:00:00 2001 From: Brandon Minnix Date: Fri, 7 Nov 2025 15:55:49 -0500 Subject: [PATCH] Adding LIBRENMS mappings for netutils Updating for comments and conflicts. --- changes/765.added | 1 + development_scripts.py | 12 ++++++++++++ docs/user/lib_mapper/librenms.md | 8 ++++++++ docs/user/lib_mapper/librenms_reverse.md | 8 ++++++++ netutils/lib_mapper.py | 25 +++++++++++++++++++++++- tests/unit/test_lib_mapper.py | 1 + 6 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 changes/765.added create mode 100644 docs/user/lib_mapper/librenms.md create mode 100644 docs/user/lib_mapper/librenms_reverse.md diff --git a/changes/765.added b/changes/765.added new file mode 100644 index 00000000..027f112f --- /dev/null +++ b/changes/765.added @@ -0,0 +1 @@ +Add a Library Mapper for LibreNMS obtained values in order to map with existing network_drivers. \ No newline at end of file diff --git a/development_scripts.py b/development_scripts.py index 47b7acc3..2c553c51 100755 --- a/development_scripts.py +++ b/development_scripts.py @@ -108,6 +108,18 @@ "_dict": lib_mapper.HIERCONFIG_LIB_MAPPER_REVERSE, "_file": "docs/user/lib_mapper/hierconfig_reverse.md", }, + "librenms": { + "header_src": "LIBRENMS", + "header_dst": "NORMALIZED", + "_dict": lib_mapper.LIBRENMS_LIB_MAPPER, + "_file": "docs/user/lib_mapper/librenms.md", + }, + "librenms_reverse": { + "header_src": "NORMALIZED", + "header_dst": "LIBRENMS", + "_dict": lib_mapper.LIBRENMS_LIB_MAPPER_REVERSE, + "_file": "docs/user/lib_mapper/librenms_reverse.md", + }, "napalm": { "header_src": "NAPALM", "header_dst": "NORMALIZED", diff --git a/docs/user/lib_mapper/librenms.md b/docs/user/lib_mapper/librenms.md new file mode 100644 index 00000000..80c6bf5a --- /dev/null +++ b/docs/user/lib_mapper/librenms.md @@ -0,0 +1,8 @@ +| LIBRENMS | | NORMALIZED | +| ---------- | -- | ------ | +| arista_eos | → | arista_eos | +| iosxe | → | cisco_xe | +| iosxr | → | cisco_xr | +| junos | → | juniper_junos | +| nxos | → | cisco_nxos | +| procera | → | applogic_procera | \ No newline at end of file diff --git a/docs/user/lib_mapper/librenms_reverse.md b/docs/user/lib_mapper/librenms_reverse.md new file mode 100644 index 00000000..5060baf8 --- /dev/null +++ b/docs/user/lib_mapper/librenms_reverse.md @@ -0,0 +1,8 @@ +| NORMALIZED | | LIBRENMS | +| ---------- | -- | ------ | +| applogic_procera | → | procera | +| arista_eos | → | arista_eos | +| cisco_nxos | → | nxos | +| cisco_xe | → | iosxe | +| cisco_xr | → | iosxr | +| juniper_junos | → | junos | \ No newline at end of file diff --git a/netutils/lib_mapper.py b/netutils/lib_mapper.py index 2f473f2d..79e338a9 100644 --- a/netutils/lib_mapper.py +++ b/netutils/lib_mapper.py @@ -145,7 +145,17 @@ # REMOVE IN 2.X, kept for backward compatibility DNA_CENTER_LIB_MAPPER_REVERSE = copy.deepcopy(DNACENTER_LIB_MAPPER_REVERSE) -# Normalized | Netmiko +# LibreNMS | Normalized +LIBRENMS_LIB_MAPPER: t.Dict[str, str] = { + "arista_eos": "arista_eos", + "iosxe": "cisco_xe", + "iosxr": "cisco_xr", + "junos": "juniper_junos", + "nxos": "cisco_nxos", + "procera": "applogic_procera", +} + +# Netmiko | Normalized NETMIKO_LIB_MAPPER: t.Dict[str, str] = { "a10": "a10", "accedian": "accedian", @@ -656,6 +666,16 @@ "paloalto_panos": "PAN_OS", } +# Normalized | LibreNMS +LIBRENMS_LIB_MAPPER_REVERSE: t.Dict[str, str] = { + "applogic_procera": "procera", + "arista_eos": "arista_eos", + "cisco_nxos": "nxos", + "cisco_xe": "iosxe", + "cisco_xr": "iosxr", + "juniper_junos": "junos", +} + # Normalized | NIST NIST_LIB_MAPPER_REVERSE: t.Dict[str, str] = { "arista_eos": "arista:eos", @@ -672,6 +692,7 @@ # Deep copy the reverse, where there is no actual translation happening with special # consideration for OS's not in netmiko. _MAIN_LIB_MAPPER = copy.deepcopy(NETMIKO_LIB_MAPPER) +_MAIN_LIB_MAPPER["applogic_procera"] = "applogic_procera" _MAIN_LIB_MAPPER["aruba_aoscx"] = "aruba_aoscx" _MAIN_LIB_MAPPER["cisco_aireos"] = "cisco_aireos" _MAIN_LIB_MAPPER["cisco_dnac"] = "cisco_dnac" @@ -709,6 +730,7 @@ "dna_center": DNACENTER_LIB_MAPPER, "forward_networks": FORWARDNETWORKS_LIB_MAPPER, "hier_config": HIERCONFIG_LIB_MAPPER, + "librenms": LIBRENMS_LIB_MAPPER, "napalm": NAPALM_LIB_MAPPER, "netmiko": NETMIKO_LIB_MAPPER, "netutils_parser": NETUTILSPARSER_LIB_MAPPER, @@ -727,6 +749,7 @@ "dna_center": DNACENTER_LIB_MAPPER_REVERSE, "forward_networks": FORWARDNETWORKS_LIB_MAPPER_REVERSE, "hier_config": HIERCONFIG_LIB_MAPPER_REVERSE, + "librenms": LIBRENMS_LIB_MAPPER_REVERSE, "napalm": NAPALM_LIB_MAPPER_REVERSE, "netmiko": NETMIKO_LIB_MAPPER_REVERSE, "netutils_parser": NETUTILSPARSER_LIB_MAPPER_REVERSE, diff --git a/tests/unit/test_lib_mapper.py b/tests/unit/test_lib_mapper.py index 878ec180..ec16baeb 100644 --- a/tests/unit/test_lib_mapper.py +++ b/tests/unit/test_lib_mapper.py @@ -11,6 +11,7 @@ "CAPIRCA", "FORWARDNETWORKS", "HIERCONFIG", + "LIBRENMS", "NETMIKO", "NETUTILSPARSER", "NTCTEMPLATES",