diff --git a/docs/user/lib_mapper/aerleon.md b/docs/user/lib_mapper/aerleon.md index 663a5964..80affc5f 100644 --- a/docs/user/lib_mapper/aerleon.md +++ b/docs/user/lib_mapper/aerleon.md @@ -2,20 +2,20 @@ | ---------- | -- | ------ | | arista | → | arista_eos | | aruba | → | aruba_aoscx | -| brocade | → | ruckus_fastiron | +| brocade | → | brocade_nos | | cisco | → | cisco_ios | | ciscoasa | → | cisco_asa | | cisconx | → | cisco_nxos | -| ciscoxr | → | cisco_iosxr | +| ciscoxr | → | cisco_xr | | cloudarmor | → | cloudarmor | | gce | → | gce | | gcp_hf | → | gcp_hf | | ipset | → | ipset | | iptables | → | iptables | | juniper | → | juniper_junos | -| juniperevo | → | juniper_evo | +| juniperevo | → | juniper_junos | | k8s | → | k8s | -| msmpc | → | juniper_msmpc | +| msmpc | → | juniper_junos | | nsxt | → | vmware_nsxt | | nsxv | → | vmware_nsxv | | openconfig | → | openconfig | @@ -24,7 +24,7 @@ | pcap | → | pcap | | sonic | → | sonic | | speedway | → | speedway | -| srx | → | juniper_srx | -| srxlo | → | juniper_srx | +| srx | → | juniper_junos | +| srxlo | → | juniper_junos | | windows | → | windows | -| windows_advfirewall | → | windows_advfirewall | \ No newline at end of file +| windows_advfirewall | → | windows | \ No newline at end of file diff --git a/docs/user/lib_mapper/aerleon_reverse.md b/docs/user/lib_mapper/aerleon_reverse.md index 03173e19..f433e340 100644 --- a/docs/user/lib_mapper/aerleon_reverse.md +++ b/docs/user/lib_mapper/aerleon_reverse.md @@ -2,30 +2,25 @@ | ---------- | -- | ------ | | arista_eos | → | arista | | aruba_aoscx | → | aruba | -| brocade_fastiron | → | brocade | -| brocade_netiron | → | brocade | +| brocade_nos | → | brocade | | cisco_asa | → | ciscoasa | | cisco_ios | → | cisco | -| cisco_iosxr | → | ciscoxr | | cisco_nxos | → | cisconx | +| cisco_xe | → | cisco | +| cisco_xr | → | ciscoxr | | cloudarmor | → | cloudarmor | | gce | → | gce | | gcp_hf | → | gcp_hf | | ipset | → | ipset | | iptables | → | iptables | -| juniper_evo | → | juniperevo | | juniper_junos | → | juniper | -| juniper_msmpc | → | msmpc | -| juniper_srx | → | srxlo | | k8s | → | k8s | | openconfig | → | openconfig | | packetfilter | → | packetfilter | | paloalto_panos | → | paloalto | | pcap | → | pcap | -| ruckus_fastiron | → | brocade | | sonic | → | sonic | | speedway | → | speedway | | vmware_nsxt | → | nsxt | | vmware_nsxv | → | nsxv | -| windows_advfirewall | → | windows_advfirewall | -| windows_ipsec | → | windows | \ No newline at end of file +| windows | → | windows | \ No newline at end of file diff --git a/docs/user/lib_mapper/capirca.md b/docs/user/lib_mapper/capirca.md index c28b13ad..b688adcb 100644 --- a/docs/user/lib_mapper/capirca.md +++ b/docs/user/lib_mapper/capirca.md @@ -2,20 +2,20 @@ | ---------- | -- | ------ | | arista | → | arista_eos | | aruba | → | aruba_aoscx | -| brocade | → | ruckus_fastiron | +| brocade | → | brocade_nos | | cisco | → | cisco_ios | | ciscoasa | → | cisco_asa | | cisconx | → | cisco_nxos | -| ciscoxr | → | cisco_iosxr | +| ciscoxr | → | cisco_xr | | cloudarmor | → | cloudarmor | | gce | → | gce | | gcp_hf | → | gcp_hf | | ipset | → | ipset | | iptables | → | iptables | | juniper | → | juniper_junos | -| juniperevo | → | juniper_evo | +| juniperevo | → | juniper_junos | | k8s | → | k8s | -| msmpc | → | juniper_msmpc | +| msmpc | → | juniper_junos | | nsxt | → | vmware_nsxt | | nsxv | → | vmware_nsxv | | openconfig | → | openconfig | @@ -24,7 +24,7 @@ | pcap | → | pcap | | sonic | → | sonic | | speedway | → | speedway | -| srx | → | juniper_srx | -| srxlo | → | juniper_srx | +| srx | → | juniper_junos | +| srxlo | → | juniper_junos | | windows | → | windows | -| windows_advfirewall | → | windows_advfirewall | \ No newline at end of file +| windows_advfirewall | → | windows | \ No newline at end of file diff --git a/docs/user/lib_mapper/capirca_reverse.md b/docs/user/lib_mapper/capirca_reverse.md index 7a829011..73bd3595 100644 --- a/docs/user/lib_mapper/capirca_reverse.md +++ b/docs/user/lib_mapper/capirca_reverse.md @@ -2,30 +2,25 @@ | ---------- | -- | ------ | | arista_eos | → | arista | | aruba_aoscx | → | aruba | -| brocade_fastiron | → | brocade | -| brocade_netiron | → | brocade | +| brocade_nos | → | brocade | | cisco_asa | → | ciscoasa | | cisco_ios | → | cisco | -| cisco_iosxr | → | ciscoxr | | cisco_nxos | → | cisconx | +| cisco_xe | → | cisco | +| cisco_xr | → | ciscoxr | | cloudarmor | → | cloudarmor | | gce | → | gce | | gcp_hf | → | gcp_hf | | ipset | → | ipset | | iptables | → | iptables | -| juniper_evo | → | juniperevo | | juniper_junos | → | juniper | -| juniper_msmpc | → | msmpc | -| juniper_srx | → | srxlo | | k8s | → | k8s | | openconfig | → | openconfig | | packetfilter | → | packetfilter | | paloalto_panos | → | paloalto | | pcap | → | pcap | -| ruckus_fastiron | → | brocade | | sonic | → | sonic | | speedway | → | speedway | | vmware_nsxt | → | nsxt | | vmware_nsxv | → | nsxv | -| windows_advfirewall | → | windows_advfirewall | -| windows_ipsec | → | windows | \ No newline at end of file +| windows | → | windows | \ No newline at end of file diff --git a/docs/user/lib_mapper/forwardnetworks.md b/docs/user/lib_mapper/forwardnetworks.md index 5fbf7f20..da7f3520 100644 --- a/docs/user/lib_mapper/forwardnetworks.md +++ b/docs/user/lib_mapper/forwardnetworks.md @@ -5,10 +5,10 @@ | ASA | → | cisco_asa | | EXTREME_NOS | → | extreme_netiron | | F5 | → | bigip_f5 | -| FORTINET | → | fortinet_fortios | +| FORTINET | → | fortinet | | IOS | → | cisco_ios | | IOS_XE | → | cisco_ios | -| IOS_XR | → | cisco_iosxr | +| IOS_XR | → | cisco_xr | | JUNOS | → | juniper_junos | | LINUX | → | linux | | LINUX_OVS_OFCTL | → | linux | diff --git a/docs/user/lib_mapper/forwardnetworks_reverse.md b/docs/user/lib_mapper/forwardnetworks_reverse.md index d8ce6ba4..06c3d629 100644 --- a/docs/user/lib_mapper/forwardnetworks_reverse.md +++ b/docs/user/lib_mapper/forwardnetworks_reverse.md @@ -5,10 +5,11 @@ | bigip_f5 | → | F5 | | cisco_asa | → | ASA | | cisco_ios | → | IOS | -| cisco_iosxr | → | IOS_XR | | cisco_nxos | → | NXOS | +| cisco_xe | → | IOS | +| cisco_xr | → | IOS_XR | | extreme_netiron | → | EXTREME_NOS | -| fortinet_fortios | → | FORTINET | +| fortinet | → | FORTINET | | juniper_junos | → | JUNOS | | linux | → | LINUX | | netscaler | → | NETSCALER | diff --git a/docs/user/lib_mapper/hierconfig.md b/docs/user/lib_mapper/hierconfig.md index 0b361614..3ab69d18 100644 --- a/docs/user/lib_mapper/hierconfig.md +++ b/docs/user/lib_mapper/hierconfig.md @@ -3,7 +3,7 @@ | eos | → | arista_eos | | fastiron | → | ruckus_fastiron | | ios | → | cisco_ios | -| iosxe | → | cisco_xe | +| iosxe | → | cisco_ios | | iosxr | → | cisco_xr | | junos | → | juniper_junos | | nxos | → | cisco_nxos | diff --git a/docs/user/lib_mapper/hierconfig_reverse.md b/docs/user/lib_mapper/hierconfig_reverse.md index 3e5b9775..3159d1f9 100644 --- a/docs/user/lib_mapper/hierconfig_reverse.md +++ b/docs/user/lib_mapper/hierconfig_reverse.md @@ -4,7 +4,7 @@ | brocade_vyos | → | vyos | | cisco_ios | → | ios | | cisco_nxos | → | nxos | -| cisco_xe | → | iosxe | +| cisco_xe | → | ios | | cisco_xr | → | iosxr | | juniper_junos | → | junos | | ruckus_fastiron | → | fastiron | \ No newline at end of file diff --git a/docs/user/lib_mapper/napalm_reverse.md b/docs/user/lib_mapper/napalm_reverse.md index 67811a1c..03c859fb 100644 --- a/docs/user/lib_mapper/napalm_reverse.md +++ b/docs/user/lib_mapper/napalm_reverse.md @@ -8,7 +8,7 @@ | cisco_ios | → | ios | | cisco_nxos | → | nxos | | cisco_wlc | → | cisco_wlc_ssh | -| cisco_xe | → | cisco_ios | +| cisco_xe | → | ios | | cisco_xr | → | iosxr | | fortinet | → | fortios | | huawei | → | huawei_vrp | diff --git a/docs/user/lib_mapper/netmiko.md b/docs/user/lib_mapper/netmiko.md index 36610fbf..cda9d14a 100644 --- a/docs/user/lib_mapper/netmiko.md +++ b/docs/user/lib_mapper/netmiko.md @@ -13,6 +13,7 @@ | aruba_procurve | → | aruba_procurve | | avaya_ers | → | avaya_ers | | avaya_vsp | → | avaya_vsp | +| bigip_f5 | → | bigip_f5 | | broadcom_icos | → | broadcom_icos | | brocade_fastiron | → | brocade_fastiron | | brocade_fos | → | brocade_fos | @@ -57,9 +58,9 @@ | extreme_vdx | → | extreme_vdx | | extreme_vsp | → | extreme_vsp | | extreme_wing | → | extreme_wing | -| f5_linux | → | f5_linux | -| f5_ltm | → | f5_ltm | -| f5_tmsh | → | f5_tmsh | +| f5_linux | → | bigip_f5 | +| f5_ltm | → | bigip_f5 | +| f5_tmsh | → | bigip_f5 | | flexvnf | → | flexvnf | | fortinet | → | fortinet | | generic | → | generic | diff --git a/docs/user/lib_mapper/netmiko_reverse.md b/docs/user/lib_mapper/netmiko_reverse.md index 9a9bd6c4..5c775b89 100644 --- a/docs/user/lib_mapper/netmiko_reverse.md +++ b/docs/user/lib_mapper/netmiko_reverse.md @@ -13,6 +13,7 @@ | aruba_procurve | → | aruba_procurve | | avaya_ers | → | avaya_ers | | avaya_vsp | → | avaya_vsp | +| bigip_f5 | → | bigip_f5 | | broadcom_icos | → | broadcom_icos | | brocade_fastiron | → | brocade_fastiron | | brocade_fos | → | brocade_fos | @@ -57,9 +58,6 @@ | extreme_vdx | → | extreme_vdx | | extreme_vsp | → | extreme_vsp | | extreme_wing | → | extreme_wing | -| f5_linux | → | f5_linux | -| f5_ltm | → | f5_ltm | -| f5_tmsh | → | f5_tmsh | | flexvnf | → | flexvnf | | fortinet | → | fortinet | | generic | → | generic | diff --git a/docs/user/lib_mapper/netutilsparser.md b/docs/user/lib_mapper/netutilsparser.md index cea138aa..548be432 100644 --- a/docs/user/lib_mapper/netutilsparser.md +++ b/docs/user/lib_mapper/netutilsparser.md @@ -10,7 +10,7 @@ | cisco_nxos | → | cisco_nxos | | citrix_netscaler | → | citrix_netscaler | | extreme_netiron | → | extreme_netiron | -| fortinet_fortios | → | fortinet_fortios | +| fortinet_fortios | → | fortinet | | juniper_junos | → | juniper_junos | | linux | → | linux | | mikrotik_routeros | → | mikrotik_routeros | diff --git a/docs/user/lib_mapper/netutilsparser_reverse.md b/docs/user/lib_mapper/netutilsparser_reverse.md index 7db2c9b3..8ea29c2d 100644 --- a/docs/user/lib_mapper/netutilsparser_reverse.md +++ b/docs/user/lib_mapper/netutilsparser_reverse.md @@ -7,10 +7,11 @@ | cisco_asa | → | cisco_asa | | cisco_ios | → | cisco_ios | | cisco_nxos | → | cisco_nxos | +| cisco_xe | → | cisco_ios | | cisco_xr | → | cisco_iosxr | | citrix_netscaler | → | citrix_netscaler | | extreme_netiron | → | extreme_netiron | -| fortinet_fortios | → | fortinet_fortios | +| fortinet | → | fortinet_fortios | | juniper_junos | → | juniper_junos | | linux | → | linux | | mikrotik_routeros | → | mikrotik_routeros | diff --git a/docs/user/lib_mapper/ntctemplates.md b/docs/user/lib_mapper/ntctemplates.md index 61524043..500c4ca6 100644 --- a/docs/user/lib_mapper/ntctemplates.md +++ b/docs/user/lib_mapper/ntctemplates.md @@ -14,6 +14,7 @@ | aruba_procurve | → | aruba_procurve | | avaya_ers | → | avaya_ers | | avaya_vsp | → | avaya_vsp | +| bigip_f5 | → | bigip_f5 | | broadcom_icos | → | broadcom_icos | | brocade_fastiron | → | brocade_fastiron | | brocade_fos | → | brocade_fos | @@ -58,9 +59,9 @@ | extreme_vdx | → | extreme_vdx | | extreme_vsp | → | extreme_vsp | | extreme_wing | → | extreme_wing | -| f5_linux | → | f5_linux | -| f5_ltm | → | f5_ltm | -| f5_tmsh | → | f5_tmsh | +| f5_linux | → | bigip_f5 | +| f5_ltm | → | bigip_f5 | +| f5_tmsh | → | bigip_f5 | | flexvnf | → | flexvnf | | fortinet | → | fortinet | | generic | → | generic | diff --git a/docs/user/lib_mapper/ntctemplates_reverse.md b/docs/user/lib_mapper/ntctemplates_reverse.md index e5d2ff86..2dfae971 100644 --- a/docs/user/lib_mapper/ntctemplates_reverse.md +++ b/docs/user/lib_mapper/ntctemplates_reverse.md @@ -14,6 +14,7 @@ | aruba_procurve | → | aruba_procurve | | avaya_ers | → | avaya_ers | | avaya_vsp | → | avaya_vsp | +| bigip_f5 | → | bigip_f5 | | broadcom_icos | → | broadcom_icos | | brocade_fastiron | → | brocade_fastiron | | brocade_fos | → | brocade_fos | @@ -58,9 +59,6 @@ | extreme_vdx | → | extreme_vdx | | extreme_vsp | → | extreme_vsp | | extreme_wing | → | extreme_wing | -| f5_linux | → | f5_linux | -| f5_ltm | → | f5_ltm | -| f5_tmsh | → | f5_tmsh | | flexvnf | → | flexvnf | | fortinet | → | fortinet | | generic | → | generic | diff --git a/docs/user/lib_mapper/pyats.md b/docs/user/lib_mapper/pyats.md index 1ee1d38c..d6d35b56 100644 --- a/docs/user/lib_mapper/pyats.md +++ b/docs/user/lib_mapper/pyats.md @@ -1,7 +1,7 @@ | PYATS | | NORMALIZED | | ---------- | -- | ------ | | asa | → | cisco_asa | -| bigip | → | f5_tmsh | +| bigip | → | bigip_f5 | | dnac | → | cisco_dnac | | ios | → | cisco_ios | | iosxe | → | cisco_ios | diff --git a/docs/user/lib_mapper/pyats_reverse.md b/docs/user/lib_mapper/pyats_reverse.md index dddad0bb..3128e3d4 100644 --- a/docs/user/lib_mapper/pyats_reverse.md +++ b/docs/user/lib_mapper/pyats_reverse.md @@ -1,5 +1,6 @@ | NORMALIZED | | PYATS | | ---------- | -- | ------ | +| bigip_f5 | → | bigip | | cisco_asa | → | asa | | cisco_dnac | → | dnac | | cisco_ios | → | iosxe | @@ -7,7 +8,6 @@ | cisco_viptella | → | viptela | | cisco_xe | → | iosxe | | cisco_xr | → | iosxr | -| f5_tmsh | → | bigip | | juniper_junos | → | junos | | linux | → | linux | | nokia_sros | → | sros | \ No newline at end of file diff --git a/docs/user/lib_mapper/pyntc.md b/docs/user/lib_mapper/pyntc.md index e6bdde4f..7b06e2af 100644 --- a/docs/user/lib_mapper/pyntc.md +++ b/docs/user/lib_mapper/pyntc.md @@ -5,5 +5,5 @@ | cisco_asa_ssh | → | cisco_asa | | cisco_ios_ssh | → | cisco_ios | | cisco_nxos_nxapi | → | cisco_nxos | -| f5_tmos_icontrol | → | f5_tmsh | +| f5_tmos_icontrol | → | bigip_f5 | | juniper_junos_netconf | → | juniper_junos | \ No newline at end of file diff --git a/docs/user/lib_mapper/pyntc_reverse.md b/docs/user/lib_mapper/pyntc_reverse.md index 80691ee5..eb362eb8 100644 --- a/docs/user/lib_mapper/pyntc_reverse.md +++ b/docs/user/lib_mapper/pyntc_reverse.md @@ -1,10 +1,10 @@ | NORMALIZED | | PYNTC | | ---------- | -- | ------ | | arista_eos | → | arista_eos_eapi | +| bigip_f5 | → | f5_tmos_icontrol | | cisco_asa | → | cisco_asa_ssh | | cisco_ios | → | cisco_ios_ssh | | cisco_nxos | → | cisco_nxos_nxapi | | cisco_wlc | → | cisco_aireos_ssh | | cisco_xe | → | cisco_ios_ssh | -| f5_tmsh | → | f5_tmos_icontrol | | juniper_junos | → | juniper_junos_netconf | \ No newline at end of file diff --git a/docs/user/lib_mapper/scrapli_reverse.md b/docs/user/lib_mapper/scrapli_reverse.md index ffb981a7..68833359 100644 --- a/docs/user/lib_mapper/scrapli_reverse.md +++ b/docs/user/lib_mapper/scrapli_reverse.md @@ -4,5 +4,6 @@ | aruba_aoscx | → | aruba_aoscx | | cisco_ios | → | cisco_iosxe | | cisco_nxos | → | cisco_nxos | +| cisco_xe | → | cisco_iosxe | | cisco_xr | → | cisco_iosxr | | juniper_junos | → | juniper_junos | \ No newline at end of file diff --git a/netutils/lib_mapper.py b/netutils/lib_mapper.py index 70abfdc8..6603a4cd 100644 --- a/netutils/lib_mapper.py +++ b/netutils/lib_mapper.py @@ -4,249 +4,243 @@ import typing as t # AERLEON | Normalized -AERLEON_LIB_MAPPER = { +AERLEON_LIB_MAPPER: t.Dict[str, str] = { "arista": "arista_eos", "aruba": "aruba_aoscx", - "brocade": "ruckus_fastiron", + "brocade": "brocade_nos", "cisco": "cisco_ios", "ciscoasa": "cisco_asa", "cisconx": "cisco_nxos", - "ciscoxr": "cisco_iosxr", + "ciscoxr": "cisco_xr", "cloudarmor": "cloudarmor", "gce": "gce", "gcp_hf": "gcp_hf", "ipset": "ipset", "iptables": "iptables", "juniper": "juniper_junos", - "juniperevo": "juniper_evo", + "juniperevo": "juniper_junos", # no reverse "k8s": "k8s", - "msmpc": "juniper_msmpc", + "msmpc": "juniper_junos", # no reverse + "nsxt": "vmware_nsxt", + "nsxv": "vmware_nsxv", "openconfig": "openconfig", - "pcap": "pcap", "packetfilter": "packetfilter", - "speedway": "speedway", - "srx": "juniper_srx", - "srxlo": "juniper_srx", "paloalto": "paloalto_panos", - "nsxv": "vmware_nsxv", - "nsxt": "vmware_nsxt", + "pcap": "pcap", "sonic": "sonic", + "speedway": "speedway", + "srx": "juniper_junos", # no reverse + "srxlo": "juniper_junos", # no reverse "windows": "windows", - "windows_advfirewall": "windows_advfirewall", + "windows_advfirewall": "windows", # no reverse } # Normalized | AERLEON -AERLEON_LIB_MAPPER_REVERSE = { +AERLEON_LIB_MAPPER_REVERSE: t.Dict[str, str] = { "arista_eos": "arista", "aruba_aoscx": "aruba", - "brocade_fastiron": "brocade", - "brocade_netiron": "brocade", - "cisco_ios": "cisco", + "brocade_nos": "brocade", "cisco_asa": "ciscoasa", + "cisco_ios": "cisco", "cisco_nxos": "cisconx", - "cisco_iosxr": "ciscoxr", + "cisco_xe": "cisco", + "cisco_xr": "ciscoxr", "cloudarmor": "cloudarmor", "gce": "gce", "gcp_hf": "gcp_hf", "ipset": "ipset", "iptables": "iptables", "juniper_junos": "juniper", - "juniper_evo": "juniperevo", - "juniper_msmpc": "msmpc", - "juniper_srx": "srxlo", "k8s": "k8s", "openconfig": "openconfig", "packetfilter": "packetfilter", "paloalto_panos": "paloalto", "pcap": "pcap", - "ruckus_fastiron": "brocade", - "vmware_nsxv": "nsxv", - "vmware_nsxt": "nsxt", - "speedway": "speedway", "sonic": "sonic", - "windows_ipsec": "windows", - "windows_advfirewall": "windows_advfirewall", + "speedway": "speedway", + "vmware_nsxt": "nsxt", + "vmware_nsxv": "nsxv", + "windows": "windows", } # CAPIRCA | Normalized -CAPIRCA_LIB_MAPPER = { +CAPIRCA_LIB_MAPPER: t.Dict[str, str] = { "arista": "arista_eos", "aruba": "aruba_aoscx", - "brocade": "ruckus_fastiron", + "brocade": "brocade_nos", "cisco": "cisco_ios", "ciscoasa": "cisco_asa", "cisconx": "cisco_nxos", - "ciscoxr": "cisco_iosxr", + "ciscoxr": "cisco_xr", "cloudarmor": "cloudarmor", "gce": "gce", "gcp_hf": "gcp_hf", "ipset": "ipset", "iptables": "iptables", "juniper": "juniper_junos", - "juniperevo": "juniper_evo", + "juniperevo": "juniper_junos", # no reverse "k8s": "k8s", - "msmpc": "juniper_msmpc", + "msmpc": "juniper_junos", + "nsxt": "vmware_nsxt", + "nsxv": "vmware_nsxv", "openconfig": "openconfig", - "pcap": "pcap", "packetfilter": "packetfilter", - "speedway": "speedway", - "srx": "juniper_srx", - "srxlo": "juniper_srx", "paloalto": "paloalto_panos", - "nsxv": "vmware_nsxv", - "nsxt": "vmware_nsxt", + "pcap": "pcap", "sonic": "sonic", + "speedway": "speedway", + "srx": "juniper_junos", # no reverse + "srxlo": "juniper_junos", # no reverse "windows": "windows", - "windows_advfirewall": "windows_advfirewall", + "windows_advfirewall": "windows", # no reverse } # Normalized | CAPIRCA -CAPIRCA_LIB_MAPPER_REVERSE = { +CAPIRCA_LIB_MAPPER_REVERSE: t.Dict[str, str] = { "arista_eos": "arista", "aruba_aoscx": "aruba", - "brocade_fastiron": "brocade", - "brocade_netiron": "brocade", - "cisco_ios": "cisco", + "brocade_nos": "brocade", "cisco_asa": "ciscoasa", + "cisco_ios": "cisco", "cisco_nxos": "cisconx", - "cisco_iosxr": "ciscoxr", + "cisco_xe": "cisco", + "cisco_xr": "ciscoxr", "cloudarmor": "cloudarmor", "gce": "gce", "gcp_hf": "gcp_hf", "ipset": "ipset", "iptables": "iptables", "juniper_junos": "juniper", - "juniper_evo": "juniperevo", - "juniper_msmpc": "msmpc", - "juniper_srx": "srxlo", "k8s": "k8s", "openconfig": "openconfig", "packetfilter": "packetfilter", "paloalto_panos": "paloalto", "pcap": "pcap", - "ruckus_fastiron": "brocade", - "vmware_nsxv": "nsxv", - "vmware_nsxt": "nsxt", - "speedway": "speedway", "sonic": "sonic", - "windows_ipsec": "windows", - "windows_advfirewall": "windows_advfirewall", + "speedway": "speedway", + "vmware_nsxt": "nsxt", + "vmware_nsxv": "nsxv", + "windows": "windows", } - -_NETMIKO_LIB_MAPPER: t.Dict[str, t.Dict[str, str]] = { - "a10": {}, - "accedian": {}, - "adtran_os": {}, - "alcatel_aos": {}, - "alcatel_sros": {}, - "apresia_aeos": {}, - "arista_eos": {}, - "aruba_os": {}, - "aruba_osswitch": {}, - "aruba_procurve": {}, - "avaya_ers": {}, - "avaya_vsp": {}, - "allied_telesis_awplus": {}, - "broadcom_icos": {}, - "brocade_fos": {}, - "brocade_fastiron": {}, - "brocade_netiron": {}, - "brocade_nos": {}, - "brocade_vdx": {}, - "brocade_vyos": {}, - "checkpoint_gaia": {}, - "calix_b6": {}, - "centec_os": {}, - "ciena_saos": {}, - "cisco_asa": {}, - "cisco_ftd": {}, - "cisco_ios": {}, - "cisco_nxos": {}, - "cisco_s300": {}, - "cisco_tp": {}, - "cisco_wlc": {}, - "cisco_xe": {}, - "cisco_xr": {}, - "cloudgenix_ion": {}, - "coriant": {}, - "dell_dnos9": {}, - "dell_force10": {}, - "dell_os6": {}, - "dell_os9": {}, - "dell_os10": {}, - "dell_powerconnect": {}, - "dell_isilon": {}, - "dlink_ds": {}, - "endace": {}, - "eltex": {}, - "eltex_esr": {}, - "enterasys": {}, - "ericsson_ipos": {}, - "extreme": {}, - "extreme_ers": {}, - "extreme_exos": {}, - "extreme_netiron": {}, - "extreme_nos": {}, - "extreme_slx": {}, - "extreme_vdx": {}, - "extreme_vsp": {}, - "extreme_wing": {}, - "f5_ltm": {}, - "f5_tmsh": {}, - "f5_linux": {}, - "flexvnf": {}, - "fortinet": {}, - "generic": {}, - "generic_termserver": {}, - "hp_comware": {}, - "hp_procurve": {}, - "huawei": {}, - "huawei_smartax": {}, - "huawei_olt": {}, - "huawei_vrpv8": {}, - "ipinfusion_ocnos": {}, - "juniper": {}, - "juniper_junos": {}, - "juniper_screenos": {}, - "keymile": {}, - "keymile_nos": {}, - "linux": {}, - "mikrotik_routeros": {}, - "mikrotik_switchos": {}, - "mellanox": {}, - "mellanox_mlnxos": {}, - "mrv_lx": {}, - "mrv_optiswitch": {}, - "netapp_cdot": {}, - "netgear_prosafe": {}, - "netscaler": {}, - "nokia_sros": {}, - "oneaccess_oneos": {}, - "ovs_linux": {}, - "paloalto_panos": {}, - "pluribus": {}, - "quanta_mesh": {}, - "rad_etx": {}, - "raisecom_roap": {}, - "ruckus_fastiron": {}, - "ruijie_os": {}, - "sixwind_os": {}, - "sophos_sfos": {}, - "tplink_jetstream": {}, - "ubiquiti_edge": {}, - "ubiquiti_edgerouter": {}, - "ubiquiti_edgeswitch": {}, - "ubiquiti_unifiswitch": {}, - "vyatta_vyos": {}, - "vyos": {}, - "watchguard_fireware": {}, - "zte_zxros": {}, - "yamaha": {}, +# Normalized | Netmiko +NETMIKO_LIB_MAPPER: t.Dict[str, str] = { + "a10": "a10", + "accedian": "accedian", + "adtran_os": "adtran_os", + "alcatel_aos": "alcatel_aos", + "alcatel_sros": "alcatel_sros", + "allied_telesis_awplus": "allied_telesis_awplus", + "apresia_aeos": "apresia_aeos", + "arista_eos": "arista_eos", + "aruba_os": "aruba_os", + "aruba_osswitch": "aruba_osswitch", + "aruba_procurve": "aruba_procurve", + "avaya_ers": "avaya_ers", + "avaya_vsp": "avaya_vsp", + "bigip_f5": "bigip_f5", # not in netmiko + "broadcom_icos": "broadcom_icos", + "brocade_fastiron": "brocade_fastiron", + "brocade_fos": "brocade_fos", + "brocade_netiron": "brocade_netiron", + "brocade_nos": "brocade_nos", + "brocade_vdx": "brocade_vdx", + "brocade_vyos": "brocade_vyos", + "calix_b6": "calix_b6", + "centec_os": "centec_os", + "checkpoint_gaia": "checkpoint_gaia", + "ciena_saos": "ciena_saos", + "cisco_asa": "cisco_asa", + "cisco_ftd": "cisco_ftd", + "cisco_ios": "cisco_ios", + "cisco_nxos": "cisco_nxos", + "cisco_s300": "cisco_s300", + "cisco_tp": "cisco_tp", + "cisco_wlc": "cisco_wlc", + "cisco_xe": "cisco_xe", + "cisco_xr": "cisco_xr", + "cloudgenix_ion": "cloudgenix_ion", + "coriant": "coriant", + "dell_dnos9": "dell_dnos9", + "dell_force10": "dell_force10", + "dell_isilon": "dell_isilon", + "dell_os10": "dell_os10", + "dell_os6": "dell_os6", + "dell_os9": "dell_os9", + "dell_powerconnect": "dell_powerconnect", + "dlink_ds": "dlink_ds", + "eltex": "eltex", + "eltex_esr": "eltex_esr", + "endace": "endace", + "enterasys": "enterasys", + "ericsson_ipos": "ericsson_ipos", + "extreme": "extreme", + "extreme_ers": "extreme_ers", + "extreme_exos": "extreme_exos", + "extreme_netiron": "extreme_netiron", + "extreme_nos": "extreme_nos", + "extreme_slx": "extreme_slx", + "extreme_vdx": "extreme_vdx", + "extreme_vsp": "extreme_vsp", + "extreme_wing": "extreme_wing", + "f5_linux": "bigip_f5", # no reverse + "f5_ltm": "bigip_f5", # no reverse + "f5_tmsh": "bigip_f5", # no reverse + "flexvnf": "flexvnf", + "fortinet": "fortinet", + "generic": "generic", + "generic_termserver": "generic_termserver", + "hp_comware": "hp_comware", + "hp_procurve": "hp_procurve", + "huawei": "huawei", + "huawei_olt": "huawei_olt", + "huawei_smartax": "huawei_smartax", + "huawei_vrpv8": "huawei_vrpv8", + "ipinfusion_ocnos": "ipinfusion_ocnos", + "juniper": "juniper", + "juniper_junos": "juniper_junos", + "juniper_screenos": "juniper_screenos", + "keymile": "keymile", + "keymile_nos": "keymile_nos", + "linux": "linux", + "mellanox": "mellanox", + "mellanox_mlnxos": "mellanox_mlnxos", + "mikrotik_routeros": "mikrotik_routeros", + "mikrotik_switchos": "mikrotik_switchos", + "mrv_lx": "mrv_lx", + "mrv_optiswitch": "mrv_optiswitch", + "netapp_cdot": "netapp_cdot", + "netgear_prosafe": "netgear_prosafe", + "netscaler": "netscaler", + "nokia_sros": "nokia_sros", + "oneaccess_oneos": "oneaccess_oneos", + "ovs_linux": "ovs_linux", + "paloalto_panos": "paloalto_panos", + "pluribus": "pluribus", + "quanta_mesh": "quanta_mesh", + "rad_etx": "rad_etx", + "raisecom_roap": "raisecom_roap", + "ruckus_fastiron": "ruckus_fastiron", + "ruijie_os": "ruijie_os", + "sixwind_os": "sixwind_os", + "sophos_sfos": "sophos_sfos", + "tplink_jetstream": "tplink_jetstream", + "ubiquiti_edge": "ubiquiti_edge", + "ubiquiti_edgerouter": "ubiquiti_edgerouter", + "ubiquiti_edgeswitch": "ubiquiti_edgeswitch", + "ubiquiti_unifiswitch": "ubiquiti_unifiswitch", + "vyatta_vyos": "vyatta_vyos", + "vyos": "vyos", + "watchguard_fireware": "watchguard_fireware", + "yamaha": "yamaha", + "zte_zxros": "zte_zxros", } # netmiko is the base name, so every key is a value, this ensure that. -NETMIKO_LIB_MAPPER = {key: key for key in sorted(_NETMIKO_LIB_MAPPER)} +# Netmiko | Normalized +NETMIKO_LIB_MAPPER_REVERSE: t.Dict[str, str] = { + value: key for key, value in NETMIKO_LIB_MAPPER.items() if key not in ["f5_ltm", "f5_tmsh", "f5_linux"] +} # ntc templates is primarily based on netmiko, so a copy is in order _NTCTEMPLATES_LIB_MAPPER = copy.deepcopy(NETMIKO_LIB_MAPPER) @@ -254,10 +248,19 @@ _NTCTEMPLATES_LIB_MAPPER["huawei_vrp"] = "huawei_vrp" _NTCTEMPLATES_LIB_MAPPER["vmware_nsxv"] = "vmware_nsxv" _NTCTEMPLATES_LIB_MAPPER["watchguard_firebox"] = "watchguard_firebox" -NTCTEMPLATES_LIB_MAPPER = {key: _NTCTEMPLATES_LIB_MAPPER[key] for key in sorted(_NTCTEMPLATES_LIB_MAPPER)} + +# NTCTemplates | Normalized +NTCTEMPLATES_LIB_MAPPER: t.Dict[str, str] = { + 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"] +} + # NAPALM | Normalized -NAPALM_LIB_MAPPER = { +NAPALM_LIB_MAPPER: t.Dict[str, str] = { "aoscx": "aruba_aoscx", "asa": "cisco_asa", "cisco_wlc_ssh": "cisco_wlc", @@ -269,7 +272,7 @@ "iosxr": "cisco_xr", "junos": "juniper_junos", "nxos": "cisco_nxos", - "nxos_ssh": "cisco_nxos", + "nxos_ssh": "cisco_nxos", # no reverse "panos": "paloalto_panos", "ros": "mikrotik_routeros", "sros": "nokia_sros", @@ -277,18 +280,18 @@ } # PYTNC | Normalized -PYNTC_LIB_MAPPER = { +PYNTC_LIB_MAPPER: t.Dict[str, str] = { "arista_eos_eapi": "arista_eos", "cisco_aireos_ssh": "cisco_wlc", "cisco_asa_ssh": "cisco_asa", "cisco_ios_ssh": "cisco_ios", "cisco_nxos_nxapi": "cisco_nxos", - "f5_tmos_icontrol": "f5_tmsh", + "f5_tmos_icontrol": "bigip_f5", "juniper_junos_netconf": "juniper_junos", } # Ansible | Normalized -ANSIBLE_LIB_MAPPER = { +ANSIBLE_LIB_MAPPER: t.Dict[str, str] = { "a10.acos_axapi.a10": "a10", "arista.eos.eos": "arista_eos", "arubanetworks.aoscx": "aruba_aoscx", @@ -323,9 +326,9 @@ } # PYATS | Normalized -PYATS_LIB_MAPPER = { +PYATS_LIB_MAPPER: t.Dict[str, str] = { "asa": "cisco_asa", - "bigip": "f5_tmsh", + "bigip": "bigip_f5", "dnac": "cisco_dnac", "ios": "cisco_ios", "iosxe": "cisco_ios", @@ -338,7 +341,7 @@ } # SCRAPLI | Normalized -SCRAPLI_LIB_MAPPER = { +SCRAPLI_LIB_MAPPER: t.Dict[str, str] = { "arista_eos": "arista_eos", "aruba_aoscx": "aruba_aoscx", "cisco_iosxe": "cisco_ios", @@ -348,11 +351,11 @@ } # HIERCONFIG | Normalized -HIERCONFIG_LIB_MAPPER = { +HIERCONFIG_LIB_MAPPER: t.Dict[str, str] = { "eos": "arista_eos", "fastiron": "ruckus_fastiron", "ios": "cisco_ios", - "iosxe": "cisco_xe", + "iosxe": "cisco_ios", # no reverse "iosxr": "cisco_xr", "junos": "juniper_junos", "nxos": "cisco_nxos", @@ -360,7 +363,7 @@ } # Netutils Parser | Normalized -NETUTILSPARSER_LIB_MAPPER = { +NETUTILSPARSER_LIB_MAPPER: t.Dict[str, str] = { "arista_eos": "arista_eos", "aruba_aoscx": "aruba_aoscx", "bigip_f5": "bigip_f5", @@ -371,7 +374,7 @@ "cisco_nxos": "cisco_nxos", "citrix_netscaler": "citrix_netscaler", "extreme_netiron": "extreme_netiron", - "fortinet_fortios": "fortinet_fortios", + "fortinet_fortios": "fortinet", "juniper_junos": "juniper_junos", "linux": "linux", "mikrotik_routeros": "mikrotik_routeros", @@ -384,27 +387,27 @@ } # Forward Networks Parser | Normalized -FORWARDNETWORKS_LIB_MAPPER = { +FORWARDNETWORKS_LIB_MAPPER: t.Dict[str, str] = { "ARISTA_EOS": "arista_eos", "ARUBA_SWITCH": "aruba_aoscx", "ASA": "cisco_asa", "EXTREME_NOS": "extreme_netiron", - "FORTINET": "fortinet_fortios", "F5": "bigip_f5", + "FORTINET": "fortinet", "IOS": "cisco_ios", - "IOS_XE": "cisco_ios", - "IOS_XR": "cisco_iosxr", + "IOS_XE": "cisco_ios", # no reverse + "IOS_XR": "cisco_xr", "JUNOS": "juniper_junos", "LINUX": "linux", - "LINUX_OVS_OFCTL": "linux", + "LINUX_OVS_OFCTL": "linux", # no reverse "NETSCALER": "netscaler", "NXOS": "cisco_nxos", "PAN_OS": "paloalto_panos", - "SRX": "juniper_junos", + "SRX": "juniper_junos", # no reverse } # Normalized | NAPALM -NAPALM_LIB_MAPPER_REVERSE = { +NAPALM_LIB_MAPPER_REVERSE: t.Dict[str, str] = { "arista_eos": "eos", "aruba_aoscx": "aoscx", "bigip_f5": "f5", @@ -413,8 +416,8 @@ "cisco_ios": "ios", "cisco_nxos": "nxos", "cisco_wlc": "cisco_wlc_ssh", + "cisco_xe": "ios", # no reverse "cisco_xr": "iosxr", - "cisco_xe": "cisco_ios", "fortinet": "fortios", "huawei": "huawei_vrp", "juniper_junos": "junos", @@ -424,29 +427,29 @@ } # Normalized | PYTNC -PYNTC_LIB_MAPPER_REVERSE = { +PYNTC_LIB_MAPPER_REVERSE: t.Dict[str, str] = { "arista_eos": "arista_eos_eapi", + "bigip_f5": "f5_tmos_icontrol", "cisco_asa": "cisco_asa_ssh", "cisco_ios": "cisco_ios_ssh", - "cisco_xe": "cisco_ios_ssh", "cisco_nxos": "cisco_nxos_nxapi", "cisco_wlc": "cisco_aireos_ssh", - "f5_tmsh": "f5_tmos_icontrol", + "cisco_xe": "cisco_ios_ssh", # no reverse "juniper_junos": "juniper_junos_netconf", } # Normalized | ANSIBLE -ANSIBLE_LIB_MAPPER_REVERSE = { +ANSIBLE_LIB_MAPPER_REVERSE: t.Dict[str, str] = { "a10": "a10.acos_axapi.a10", "arista_eos": "arista.eos.eos", "aruba_aoscx": "arubanetworks.aoscx", "bigip_f5": "f5networks.f5_bigip.bigip", "ciena_saos": "ciena.saos6.saos6", "cisco_asa": "cisco.asa.asa", - "cisco_xe": "cisco.ios.ios", "cisco_ios": "cisco.ios.ios", "cisco_meraki": "cisco.meraki.meraki", "cisco_nxos": "cisco.nxos.nxos", + "cisco_xe": "cisco.ios.ios", # no reverse "cisco_xr": "cisco.iosxr.iosxr", "dell_os10": "dellemc.os10.0s10", "dell_os6": "dellemc.os6.os6", @@ -472,44 +475,45 @@ } # Normalized | PYATS -PYATS_LIB_MAPPER_REVERSE = { +PYATS_LIB_MAPPER_REVERSE: t.Dict[str, str] = { + "bigip_f5": "bigip", "cisco_asa": "asa", "cisco_dnac": "dnac", "cisco_ios": "iosxe", "cisco_nxos": "nxos", - "cisco_xe": "iosxe", "cisco_viptella": "viptela", + "cisco_xe": "iosxe", # no reverse "cisco_xr": "iosxr", - "f5_tmsh": "bigip", "juniper_junos": "junos", "linux": "linux", "nokia_sros": "sros", } # Normalized | Scrapli -SCRAPLI_LIB_MAPPER_REVERSE = { +SCRAPLI_LIB_MAPPER_REVERSE: t.Dict[str, str] = { "arista_eos": "arista_eos", "aruba_aoscx": "aruba_aoscx", "cisco_ios": "cisco_iosxe", "cisco_nxos": "cisco_nxos", + "cisco_xe": "cisco_iosxe", "cisco_xr": "cisco_iosxr", "juniper_junos": "juniper_junos", } # Normalized | HIERCONFIG -HIERCONFIG_LIB_MAPPER_REVERSE = { +HIERCONFIG_LIB_MAPPER_REVERSE: t.Dict[str, str] = { "arista_eos": "eos", "brocade_vyos": "vyos", "cisco_ios": "ios", "cisco_nxos": "nxos", - "cisco_xe": "iosxe", + "cisco_xe": "ios", "cisco_xr": "iosxr", "juniper_junos": "junos", "ruckus_fastiron": "fastiron", } # Normalized | Netutils Parser -NETUTILSPARSER_LIB_MAPPER_REVERSE = { +NETUTILSPARSER_LIB_MAPPER_REVERSE: t.Dict[str, str] = { "arista_eos": "arista_eos", "aruba_aoscx": "aruba_aoscx", "bigip_f5": "bigip_f5", @@ -517,10 +521,11 @@ "cisco_asa": "cisco_asa", "cisco_ios": "cisco_ios", "cisco_nxos": "cisco_nxos", + "cisco_xe": "cisco_ios", "cisco_xr": "cisco_iosxr", "citrix_netscaler": "citrix_netscaler", "extreme_netiron": "extreme_netiron", - "fortinet_fortios": "fortinet_fortios", + "fortinet": "fortinet_fortios", "juniper_junos": "juniper_junos", "linux": "linux", "mikrotik_routeros": "mikrotik_routeros", @@ -533,40 +538,51 @@ } # Normalized | Forward Networks Parser -FORWARDNETWORKS_LIB_MAPPER_REVERSE = { +FORWARDNETWORKS_LIB_MAPPER_REVERSE: t.Dict[str, str] = { "arista_eos": "ARISTA_EOS", "aruba_aoscx": "ARUBA_SWITCH", "bigip_f5": "F5", "cisco_asa": "ASA", "cisco_ios": "IOS", - "cisco_iosxr": "IOS_XR", "cisco_nxos": "NXOS", + "cisco_xe": "IOS", + "cisco_xr": "IOS_XR", "extreme_netiron": "EXTREME_NOS", - "fortinet_fortios": "FORTINET", + "fortinet": "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) - - # 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["aruba_aoscx"] = "aruba_aoscx" +_MAIN_LIB_MAPPER["cisco_aireos"] = "cisco_aireos" _MAIN_LIB_MAPPER["cisco_dnac"] = "cisco_dnac" _MAIN_LIB_MAPPER["cisco_meraki"] = "cisco_meraki" _MAIN_LIB_MAPPER["cisco_viptella"] = "cisco_viptella" +_MAIN_LIB_MAPPER["citrix_netscaler"] = "citrix_netscaler" +_MAIN_LIB_MAPPER["cloudarmor"] = "cloudarmor" +_MAIN_LIB_MAPPER["gce"] = "gce" +_MAIN_LIB_MAPPER["gcp_hf"] = "gcp_hf" _MAIN_LIB_MAPPER["huawei_vrp"] = "huawei_vrp" +_MAIN_LIB_MAPPER["ipset"] = "ipset" +_MAIN_LIB_MAPPER["iptables"] = "iptables" +_MAIN_LIB_MAPPER["k8s"] = "k8s" _MAIN_LIB_MAPPER["lenovo_cnos"] = "lenovo_cnos" _MAIN_LIB_MAPPER["lenovo_enos"] = "lenovo_enos" +_MAIN_LIB_MAPPER["openconfig"] = "openconfig" +_MAIN_LIB_MAPPER["packetfilter"] = "packetfilter" +_MAIN_LIB_MAPPER["pcap"] = "pcap" +_MAIN_LIB_MAPPER["speedway"] = "speedway" _MAIN_LIB_MAPPER["ruckus_icx"] = "ruckus_icx" _MAIN_LIB_MAPPER["ruckus_smartzone"] = "ruckus_smartzone" _MAIN_LIB_MAPPER["sonic"] = "sonic" +_MAIN_LIB_MAPPER["ubiquiti_airos"] = "ubiquiti_airos" _MAIN_LIB_MAPPER["vmware_nsxv"] = "vmware_nsxv" +_MAIN_LIB_MAPPER["vmware_nsxt"] = "vmware_nsxt" _MAIN_LIB_MAPPER["watchguard_firebox"] = "watchguard_firebox" -MAIN_LIB_MAPPER = {key: _MAIN_LIB_MAPPER[key] for key in sorted(_MAIN_LIB_MAPPER)} +_MAIN_LIB_MAPPER["windows"] = "windows" +MAIN_LIB_MAPPER: t.Dict[str, str] = {key: _MAIN_LIB_MAPPER[key] for key in sorted(_MAIN_LIB_MAPPER)} diff --git a/tests/unit/test_lib_mapper.py b/tests/unit/test_lib_mapper.py index 736c95f9..a3fac35a 100644 --- a/tests/unit/test_lib_mapper.py +++ b/tests/unit/test_lib_mapper.py @@ -5,7 +5,20 @@ from netutils import lib_mapper from netutils.config.compliance import parser_map -LIBRARIES = ["ANSIBLE", "NETMIKO", "NTCTEMPLATES", "NAPALM", "PYATS", "PYNTC", "HIERCONFIG", "NETUTILSPARSER"] +LIBRARIES = [ + "AERLEON", + "ANSIBLE", + "CAPIRCA", + "FORWARDNETWORKS", + "HIERCONFIG", + "NETMIKO", + "NETUTILSPARSER", + "NTCTEMPLATES", + "NAPALM", + "PYATS", + "PYNTC", + "SCRAPLI", +] def test_lib_mapper(): @@ -30,13 +43,42 @@ def test_lib_mapper(): @pytest.mark.parametrize("lib", LIBRARIES) def test_lib_mapper_reverse(lib): + """Test that the forward is same as reverse, some accommodations must be made.""" + rev_mapper = getattr(lib_mapper, f"{lib}_LIB_MAPPER_REVERSE").copy() _mapper = getattr(lib_mapper, f"{lib}_LIB_MAPPER").copy() if lib == "NAPALM": _mapper.pop("nxos_ssh") - mapper = dict((v, k) for k, v in _mapper.items()) - rev_mapper = getattr(lib_mapper, f"{lib}_LIB_MAPPER_REVERSE") - if lib in ["ANSIBLE", "NAPALM", "PYATS", "PYNTC"]: + if lib in ["NETMIKO", "NTCTEMPLATES"]: + _mapper.pop("f5_ltm") + _mapper.pop("f5_tmsh") + _mapper.pop("f5_linux") + if lib in [ + "AERLEON", + "ANSIBLE", + "CAPIRCA", + "FORWARDNETWORKS", + "HIERCONFIG", + "NETUTILSPARSER", + "NAPALM", + "PYATS", + "PYNTC", + "SCRAPLI", + ]: rev_mapper.pop("cisco_xe") + if lib in ["HIERCONFIG"]: + _mapper.pop("iosxe") + if lib in ["FORWARDNETWORKS"]: + _mapper.pop("LINUX_OVS_OFCTL") + _mapper.pop("IOS_XE") + _mapper.pop("SRX") + if lib in ["AERLEON", "CAPIRCA"]: + _mapper.pop("juniperevo") + _mapper.pop("srx") + _mapper.pop("srxlo") + _mapper.pop("msmpc") + _mapper.pop("windows_advfirewall") + mapper = dict((v, k) for k, v in _mapper.items()) + assert mapper == rev_mapper @@ -54,3 +96,12 @@ def test_netutils_parser(): """Test that the parser_map in compliance have been added to NETUTILSPARSER lib mappers.""" assert parser_map.keys() == lib_mapper.NETUTILSPARSER_LIB_MAPPER.keys() assert list(parser_map.keys()) == sorted(list(lib_mapper.NETUTILSPARSER_LIB_MAPPER.keys())) + + +@pytest.mark.parametrize("lib", LIBRARIES) +def test_lib_mapper_normalized_name(lib): + """Ensure that MAIN_LIB_MAPPER is kept up to date.""" + for key in getattr(lib_mapper, f"{lib}_LIB_MAPPER_REVERSE").keys(): + assert key in lib_mapper.MAIN_LIB_MAPPER + for value in getattr(lib_mapper, f"{lib}_LIB_MAPPER").values(): + assert value in lib_mapper.MAIN_LIB_MAPPER