Skip to content

Commit

Permalink
Add forward networks mapper (#451)
Browse files Browse the repository at this point in the history
* Add forwardnetworks mapper and update docs
* update docs
  • Loading branch information
jtdub authored Feb 9, 2024
1 parent a026c91 commit 5bcf145
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 1 deletion.
12 changes: 12 additions & 0 deletions development_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@
"_dict": lib_mapper.CAPIRCA_LIB_MAPPER_REVERSE,
"_file": "docs/user/lib_mapper/capirca_reverse.md",
},
"forwardnetworks": {
"header_src": "FORWARDNETWORKS",
"header_dst": "NORMALIZED",
"_dict": lib_mapper.FORWARDNETWORKS_LIB_MAPPER,
"_file": "docs/user/lib_mapper/forwardnetworks.md",
},
"forwardnetworks_reverse": {
"header_src": "NORMALIZED",
"header_dst": "FORWARDNETWORKS",
"_dict": lib_mapper.FORWARDNETWORKS_LIB_MAPPER_REVERSE,
"_file": "docs/user/lib_mapper/forwardnetworks_reverse.md",
},
"hierconfig": {
"header_src": "HIERCONFIG",
"header_dst": "NORMALIZED",
Expand Down
18 changes: 18 additions & 0 deletions docs/user/lib_mapper/forwardnetworks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
| FORWARDNETWORKS | | NORMALIZED |
| ---------- | -- | ------ |
| ARISTA_EOS || arista_eos |
| ARUBA_SWITCH || aruba_aoscx |
| ASA || cisco_asa |
| EXTREME_NOS || extreme_netiron |
| F5 || bigip_f5 |
| FORTINET || fortinet_fortios |
| IOS || cisco_ios |
| IOS_XE || cisco_ios |
| IOS_XR || cisco_iosxr |
| JUNOS || juniper_junos |
| LINUX || linux |
| LINUX_OVS_OFCTL || linux |
| NETSCALER || netscaler |
| NXOS || cisco_nxos |
| PAN_OS || paloalto_panos |
| SRX || juniper_junos |
15 changes: 15 additions & 0 deletions docs/user/lib_mapper/forwardnetworks_reverse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
| NORMALIZED | | FORWARDNETWORKS |
| ---------- | -- | ------ |
| arista_eos || ARISTA_EOS |
| aruba_aoscx || ARUBA_SWITCH |
| bigip_f5 || F5 |
| cisco_asa || ASA |
| cisco_ios || IOS |
| cisco_iosxr || IOS_XR |
| cisco_nxos || NXOS |
| extreme_netiron || EXTREME_NOS |
| fortinet_fortios || FORTINET |
| juniper_junos || JUNOS |
| linux || LINUX |
| netscaler || NETSCALER |
| paloalto_panos || PAN_OS |
8 changes: 8 additions & 0 deletions docs/user/lib_use_cases_lib_mapper.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ Another use case could be using an example like the above in an Ansible filter.

--8<-- "docs/user/lib_mapper/ansible_reverse.md"

## Forward Networks Mapper

--8<-- "docs/user/lib_mapper/forwardnetworks.md"

## Reverse Forward Networks Mapper

--8<-- "docs/user/lib_mapper/forwardnetworks_reverse.md"

## Hier Config Mapper

--8<-- "docs/user/lib_mapper/hierconfig.md"
Expand Down
37 changes: 37 additions & 0 deletions netutils/lib_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,26 @@
"ubiquiti_airos": "ubiquiti_airos",
}

# Forward Networks Parser | Normalized
FORWARDNETWORKS_LIB_MAPPER = {
"ARISTA_EOS": "arista_eos",
"ARUBA_SWITCH": "aruba_aoscx",
"ASA": "cisco_asa",
"EXTREME_NOS": "extreme_netiron",
"FORTINET": "fortinet_fortios",
"F5": "bigip_f5",
"IOS": "cisco_ios",
"IOS_XE": "cisco_ios",
"IOS_XR": "cisco_iosxr",
"JUNOS": "juniper_junos",
"LINUX": "linux",
"LINUX_OVS_OFCTL": "linux",
"NETSCALER": "netscaler",
"NXOS": "cisco_nxos",
"PAN_OS": "paloalto_panos",
"SRX": "juniper_junos",
}

# Normalized | NAPALM
NAPALM_LIB_MAPPER_REVERSE = {
"arista_eos": "eos",
Expand Down Expand Up @@ -508,6 +528,23 @@
"ubiquiti_airos": "ubiquiti_airos",
}

# Normalized | Forward Networks Parser
FORWARDNETWORKS_LIB_MAPPER_REVERSE = {
"arista_eos": "ARISTA_EOS",
"aruba_aoscx": "ARUBA_SWITCH",
"bigip_f5": "F5",
"cisco_asa": "ASA",
"cisco_ios": "IOS",
"cisco_iosxr": "IOS_XR",
"cisco_nxos": "NXOS",
"extreme_netiron": "EXTREME_NOS",
"fortinet_fortios": "FORTINET",
"juniper_junos": "JUNOS",
"linux": "LINUX",
"netscaler": "NETSCALER",
"paloalto_panos": "PAN_OS",
}

# Deep copy the reverse, where there is no actual translation happening.
NETMIKO_LIB_MAPPER_REVERSE = copy.deepcopy(NETMIKO_LIB_MAPPER)
NTCTEMPLATES_LIB_MAPPER_REVERSE = copy.deepcopy(NTCTEMPLATES_LIB_MAPPER)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "netutils"
version = "1.6.0"
version = "1.6.1"
description = "Common helper functions useful in network automation."
authors = ["Network to Code, LLC <[email protected]>"]
license = "Apache-2.0"
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/test_lib_mapper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test for the lib_mapper definitions."""

import pytest

from netutils import lib_mapper
Expand All @@ -23,6 +24,8 @@ def test_lib_mapper():
assert lib_mapper.NAPALM_LIB_MAPPER_REVERSE[lib_mapper.ANSIBLE_LIB_MAPPER["cisco.ios.ios"]] == "ios"
assert lib_mapper.HIERCONFIG_LIB_MAPPER["ios"] == "cisco_ios"
assert lib_mapper.HIERCONFIG_LIB_MAPPER_REVERSE[lib_mapper.HIERCONFIG_LIB_MAPPER["ios"]] == "ios"
assert lib_mapper.FORWARDNETWORKS_LIB_MAPPER["IOS"] == "cisco_ios"
assert lib_mapper.FORWARDNETWORKS_LIB_MAPPER_REVERSE[lib_mapper.FORWARDNETWORKS_LIB_MAPPER["IOS"]] == "IOS"


@pytest.mark.parametrize("lib", LIBRARIES)
Expand Down

0 comments on commit 5bcf145

Please sign in to comment.