Skip to content

Commit

Permalink
Finishing changes and passing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Minnix authored and Brandon Minnix committed Apr 29, 2024
1 parent 5ff9434 commit 5557274
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 5 deletions.
3 changes: 2 additions & 1 deletion docs/user/include_jinja_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@
| mac_to_format | netutils.mac.mac_to_format |
| mac_to_int | netutils.mac.mac_to_int |
| mac_type | netutils.mac.mac_type |
| os_platform_object_builder | netutils.nist.os_platform_object_builder |
| compare_version_loose | netutils.os_version.compare_version_loose |
| compare_version_strict | netutils.os_version.compare_version_strict |
| default_metadata | netutils.os_version.default_metadata |
| get_upgrade_path | netutils.os_version.get_upgrade_path |
| juniper_junos_metadata | netutils.os_version.juniper_junos_metadata |
| version_metadata | netutils.os_version.version_metadata |
Expand All @@ -81,7 +83,6 @@
| encrypt_type7 | netutils.password.encrypt_type7 |
| get_hash_salt | netutils.password.get_hash_salt |
| tcp_ping | netutils.ping.tcp_ping |
| os_platform_object_builder | netutils.platform_mapper.os_platform_object_builder |
| regex_findall | netutils.regex.regex_findall |
| regex_match | netutils.regex.regex_match |
| regex_search | netutils.regex.regex_search |
Expand Down
2 changes: 1 addition & 1 deletion netutils/os_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def juniper_junos_metadata(version: str) -> t.Dict[str, t.Any]:
Examples:
>>> juniper_junos_metadata("12.3R4")
{'isservice': False, 'ismaintenance': True, 'isfrs': False, 'isspecial': False, 'service': None, 'service_build': None, 'service_respin': None, 'main': '12', 'minor': '3', 'type': 'R', 'build': '4'}
{'isservice': False, 'ismaintenance': True, 'isfrs': False, 'isspecial': False, 'service': None, 'service_build': None, 'service_respin': None, 'main': '12', 'minor': '3', 'type': 'R', 'build': '4', 'major': '12', 'patch': '4'}
"""
# Use regex to group the main, minor, type and build into useable pieces
# re_main_minor_type_build = re.search(r"^(\d+)\.(\d+)([xXrRsS])?(\d+)?", split_version[0])
Expand Down
3 changes: 2 additions & 1 deletion netutils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@
"get_upgrade_path": "os_version.get_upgrade_path",
"hash_data": "hash.hash_data",
"get_ips_sorted": "ip.get_ips_sorted",
"os_platform_object_builder": "platform_mapper.os_platform_object_builder",
"os_platform_object_builder": "nist.os_platform_object_builder",
"juniper_junos_metadata": "os_version.juniper_junos_metadata",
"version_metadata": "os_version.version_metadata",
"default_metadata": "os_version.default_metadata",
}


Expand Down
44 changes: 42 additions & 2 deletions tests/unit/test_nist.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,31 @@
# Cisco and Arista use the generic parsing
{
"sent": {"vendor": "cisco", "platform": "ios", "version": "15.7(2.0z)M"},
"received": {"vendor": "cisco", "os_type": "ios", "version_string": "15.7(2.0z)M"},
"received": {
"vendor": "cisco",
"os_type": "ios",
"version_string": "15.7(2.0z)M",
"major": "15",
"minor": "7",
"patch": None,
"prerelease": None,
"buildmetadata": None,
"vendor_metadata": False,
},
},
{
"sent": {"vendor": "arista", "platform": "eos", "version": "4.15.3f"},
"received": {"vendor": "arista", "os_type": "eos", "version_string": "4.15.3f"},
"received": {
"vendor": "arista",
"os_type": "eos",
"version_string": "4.15.3f",
"major": "4",
"minor": "15",
"patch": None,
"prerelease": None,
"buildmetadata": None,
"vendor_metadata": False,
},
},
# Juniper Junos uses a custom parser
{
Expand All @@ -32,6 +52,11 @@
"service": None,
"service_build": None,
"service_respin": None,
"buildmetadata": None,
"vendor_metadata": True,
"prerelease": None,
"major": "12",
"patch": None,
},
},
{
Expand All @@ -51,6 +76,11 @@
"service": "d",
"service_build": "80",
"service_respin": None,
"buildmetadata": None,
"vendor_metadata": True,
"prerelease": None,
"major": "12",
"patch": "48",
},
},
{
Expand All @@ -70,6 +100,11 @@
"service": "d",
"service_build": "80",
"service_respin": None,
"buildmetadata": None,
"vendor_metadata": True,
"prerelease": None,
"major": "12",
"patch": "48",
},
},
{
Expand All @@ -89,6 +124,11 @@
"service": "S",
"service_build": "15",
"service_respin": None,
"buildmetadata": None,
"vendor_metadata": True,
"prerelease": None,
"major": "12",
"patch": "12",
},
},
]
Expand Down

0 comments on commit 5557274

Please sign in to comment.