Skip to content

Commit

Permalink
Revert "Feature/platform mapper (networktocode#220)"
Browse files Browse the repository at this point in the history
This reverts commit e835dc3.
  • Loading branch information
itdependsnetworks committed Mar 8, 2024
1 parent db056d7 commit 8f89fc8
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 490 deletions.
5 changes: 0 additions & 5 deletions docs/dev/code_reference/nist.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/dev/code_reference/platform_mapper.md

This file was deleted.

2 changes: 0 additions & 2 deletions docs/user/include_jinja_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
| mac_to_int | netutils.mac.mac_to_int |
| mac_type | netutils.mac.mac_type |
| get_upgrade_path | netutils.os_version.get_upgrade_path |
| juniper_junos_version_parser | netutils.os_version.juniper_junos_version_parser |
| compare_cisco_type5 | netutils.password.compare_cisco_type5 |
| compare_cisco_type7 | netutils.password.compare_cisco_type7 |
| compare_cisco_type9 | netutils.password.compare_cisco_type9 |
Expand All @@ -76,7 +75,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: 0 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,9 @@ nav:
- Library Helpers: "dev/code_reference/lib_helpers.md"
- Library Mapping: "dev/code_reference/lib_mapping.md"
- Mac Address: "dev/code_reference/mac.md"
- NIST: "dev/code_reference/nist.md"
- OS Version: "dev/code_reference/os_version.md"
- Password: "dev/code_reference/password.md"
- Ping: "dev/code_reference/ping.md"
- Platform Mapper: "dev/code_reference/platform_mapper.md"
- Protocol Mapper: "dev/code_reference/protocol_mapper.md"
- Regex: "dev/code_reference/regex.md"
- Route: "dev/code_reference/route.md"
Expand Down
141 changes: 0 additions & 141 deletions netutils/nist.py

This file was deleted.

88 changes: 0 additions & 88 deletions netutils/os_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Functions for working with OS Versions."""
import re
import typing as t
from distutils.version import LooseVersion # pylint: disable=deprecated-module

Expand Down Expand Up @@ -48,90 +47,3 @@ def get_upgrade_path(
upgrade_path.append(target_version)

return upgrade_path


def juniper_junos_version_parser(version: str) -> t.Dict[str, t.Any]:
"""Parses JunOS Version into usable bits matching JunOS Standards.
Args:
version
Returns:
A dictionary containing parsed version information
Examples:
>>> parsed_version = juniper_junos_version_parser("12.3R4")
"""
# 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])
re_main_minor_type_build: re.Pattern[str] = re.compile(
r"""
^
(?P<main>\d+) # main train
\. # dot separator
(?P<minor>\d+) # minor version
(?P<type>[xXrRsS])? # version type (optional)
(?P<build>\d+)? # build (optional)
""",
re.VERBOSE,
)
re_service_build_respin: re.Pattern[str] = re.compile(
r"""
(?P<service>[sSdD])? # service (optional)
(?P<service_build>\d+)? # service build (optional)
\.?
(?P<service_respin>\d+)? # service respin (optional)
""",
re.VERBOSE,
)
# Set empty params for service pieces and complete them if a second indice exists from the version split
# Define isservice, isfrs, isspecial, ismaintenance
parsed_version: t.Dict[str, t.Any] = {
"isservice": False,
"ismaintenance": False,
"isfrs": False,
"isspecial": False,
"service": None,
"service_build": None,
"service_respin": None,
}

# Juniper junos marks the division between main, minor, type and build from the service build and respin with a -
version_core_part, *version_service_part = re.split("-|:", version)

# Parse out junos into sections that can be used for logic
parsed_version.update(re_main_minor_type_build.search(version_core_part).groupdict()) # type:ignore

if version_service_part:
parsed_version.update(re_service_build_respin.search(version_service_part[0]).groupdict()) # type:ignore
if parsed_version.get("service", "").lower() == "s":
parsed_version["isservice"] = True
# Juniper looks at the D in special releases like it's the R in normal releases; Use it as the frs identifier
elif parsed_version.get("service").lower() == "d" and ( # type:ignore
parsed_version.get("service_build") is None or int(parsed_version.get("service_build", 1)) <= 1
):
parsed_version["isfrs"] = True

if parsed_version.get("type") is None:
return parsed_version

if parsed_version["type"].lower() == "x":
parsed_version["isspecial"] = True
elif parsed_version["type"].lower() == "s":
parsed_version["isservice"] = True

if parsed_version["type"].lower() == "r" and (
parsed_version.get("build") is None or int(parsed_version.get("build")) <= 1 # type:ignore
):
parsed_version["isfrs"] = True
elif parsed_version["type"].lower() == "r":
parsed_version["ismaintenance"] = True

return parsed_version


os_version_parsers = {
"juniper": {
"junos": juniper_junos_version_parser,
}
}
96 changes: 0 additions & 96 deletions netutils/platform_mapper.py

This file was deleted.

2 changes: 0 additions & 2 deletions netutils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@
"get_napalm_getters": "lib_helpers.get_napalm_getters",
"paloalto_panos_brace_to_set": "config.conversion.paloalto_panos_brace_to_set",
"get_upgrade_path": "os_version.get_upgrade_path",
"os_platform_object_builder": "platform_mapper.os_platform_object_builder",
"juniper_junos_version_parser": "os_version.juniper_junos_version_parser",
"hash_data": "hash.hash_data",
}

Expand Down
Loading

0 comments on commit 8f89fc8

Please sign in to comment.