Skip to content

Commit

Permalink
Update spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
itdependsnetworks committed Aug 11, 2023
1 parent 137ffbe commit 445f6ae
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
5 changes: 4 additions & 1 deletion docs/user/lib_use_cases.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,25 @@ As the Python library is intended to be a low-level implementation, the primary

Functions are grouped with like functions, such as IP or MAC address based functions. Included to date are groupings of:

- ASN - Provides the ability to convert BGP ASN from integer to dot notation and back.
- Bandwidth - Provides the ability to convert between various bandwidth values.
- Banner - Provides the ability to normalize the various banner delimiters.
- BGP ASN - Provides the ability to convert BGP ASN from integer to dot notation.
- Configuration
- Cleaning - Provides the ability to remove or replace lines based on regex matches.
- Compliance - Provides the ability to compare two configurations to sanely understand the differences.
- Conversion - Provides the ability to convert between different syntax's within the same OS.
- Parsing - Provides the ability to parse configuration for the minor differences that are there.
- DNS - Provides the ability to work with DNS, such as validating that a FQDN is resolvable.
- Interface - Provides the ability to work with interface names, expanding, abbreviating, and splitting the names.
- IP Address - Provides the ability to work with IP addresses, primarily exposing Python `ipaddress` functionality.
- Library Helpers - Provides helpers to pull useful information, e.g. NAPALM getters.
- Library Mapper - Provides mappings in expected vendor names between Netmiko, NAPALM, pyntc, ntc-templates, pyats, and scrapli.
- MAC Address - Provides the ability to work with MAC addresses such as validating or converting to integer.
- OS Version - Provides the ability to work with OS version, such as defining an upgrade path.
- Password - Provides the ability to compare and encrypt common password schemas such as type5 and type7 Cisco passwords.
- Ping - Provides the ability to ping, currently only tcp ping.
- Protocol Mapper - Provides a mapping for protocol names to numbers and vice versa.
- Regex - Provide convenience methods for regex to be used in Jinja2.
- Route - Provides the ability to provide a list of routes and an IP Address and return the longest prefix matched route.
- Time -Provides the ability to convert between integer time and string times.
- VLANs - Provide the ability to convert configuration into lists or lists into configuration.
Expand Down
4 changes: 2 additions & 2 deletions docs/user/lib_use_cases_protocol_mappers.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ Take the below example.
|compressnet| 3| tcp| Compression Process |
|compressnet| 3| udp| Compression Process |

As you can see, the service name and port comboniation is not unique. As such, on the second one, a `-secondary` is appended to the name to accomdate. The resulting structure looks something like:
As you can see, the service name and port combination is not unique. As such, on the second one, a `-secondary` is appended to the name to accommodate. The resulting structure looks something like:

```python
"compressnet": {"port_number": 2, "protocols": ["tcp", "udp"]},
"compressnet-secondary": {"port_number": 3, "protocols": ["tcp", "udp"]},
```

This behaviour is to be expected.
This behavior is to be expected.
10 changes: 5 additions & 5 deletions netutils/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ def canonical_interface_name_list(
"""Function to return a list of interface's canonical name (fully expanded name).
Use of explicit matches used to indicate a clear understanding on any potential
match. Regex and other looser matching methods were not implmented to avoid false
positive matches. As an example, it would make sense to do "[P|p][O|o]" which would
match. Regex and other looser matching methods were not implemented to avoid false
positive matches. As an example, it would make sense to do `[P|p][O|o]` which would
incorrectly match PO = POS and Po = Port-channel, leading to a false positive, not
easily troubleshot, found, or known.
Expand Down Expand Up @@ -420,7 +420,7 @@ def _iter_tree(node: t.Dict[CharacterClass, t.Any], parents: t.List[CharacterCla
"""Walk a tree of interface name parts.
Weights are assigned based on domain logic to produce a
'cannonical' ordering of names.
'canonical' ordering of names.
"""
for _, items in itertools.groupby(sorted(node.keys()), lambda t: t.weight):
for item in sorted(items):
Expand All @@ -446,8 +446,8 @@ def sort_interface_list(interfaces: t.List[str]) -> t.List[str]:
Examples:
>>> sort_interface_list(["Gi1/0/1", "Gi1/0/3", "Gi1/0/3.100", "Gi1/0/2", "Gi1/0/2.50", "Gi2/0/2", "Po40", "Po160", "Lo10"])
['Gi1/0/1', 'Gi1/0/2', 'Gi1/0/2.50', 'Gi1/0/3', 'Gi1/0/3.100', 'Gi2/0/2', 'Lo10', 'Po40', 'Po160']
>>> sort_interface_list(['GigabitEthernet1/0/1', 'GigabitEthernet1/0/3', 'GigabitEthernet1/0/2', "GigabitEthernett3/0/5", 'GigabitEthernet3/0/7', 'GigabitEthernet2/0/8.5', 'Port-channel40', 'Vlan20', 'Loopback10'])
['GigabitEthernet1/0/1', 'GigabitEthernet1/0/2', 'GigabitEthernet1/0/3', 'GigabitEthernet2/0/8.5', 'GigabitEthernet3/0/7', 'GigabitEthernett3/0/5', 'Loopback10', 'Port-channel40', 'Vlan20']
>>> sort_interface_list(['GigabitEthernet1/0/1', 'GigabitEthernet1/0/3', 'GigabitEthernet1/0/2', "GigabitEthernet3/0/5", 'GigabitEthernet3/0/7', 'GigabitEthernet2/0/8.5', 'Port-channel40', 'Vlan20', 'Loopback10'])
['GigabitEthernet1/0/1', 'GigabitEthernet1/0/2', 'GigabitEthernet1/0/3', 'GigabitEthernet2/0/8.5', 'GigabitEthernet3/0/5', 'GigabitEthernet3/0/7', 'Loopback10', 'Port-channel40', 'Vlan20']
"""
root: t.Dict[CharacterClass, t.Any] = {}
for ifname in interfaces:
Expand Down
6 changes: 3 additions & 3 deletions netutils/password.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,12 @@ def encrypt_cisco_type5(unencrypted_password: str, salt: t.Optional[str] = None,
if not salt:
salt = "".join(secrets.choice(ALPHABET) for _ in range(salt_len))
elif not set(salt) <= set(ALPHABET):
raise ValueError(f"type5_pw salt used inproper characters, must be one of {ALPHABET}")
raise ValueError(f"type5_pw salt used improper characters, must be one of {ALPHABET}")
return crypt.crypt(unencrypted_password, f"$1${salt}$")


def encrypt_cisco_type7(unencrypted_password: str, salt: t.Optional[int] = None) -> str:
"""Given an unencrypted password of Cisco Type 7 password, encypt it.
"""Given an unencrypted password of Cisco Type 7 password, encrypt it.
Args:
unencrypted_password: A password that has not been encrypted, and will be compared against.
Expand Down Expand Up @@ -397,7 +397,7 @@ def decrypt_juniper_type9(encrypted_password: str) -> str:
nibble = stripped_password_characters[0 : len(decode)] # noqa: E203
stripped_password_characters = stripped_password_characters[len(decode) :] # noqa: E203

# Decode value for nibble and convert to character, append to decryped password
# Decode value for nibble and convert to character, append to decrypted password
value = 0
for index, char in enumerate(nibble):
gap = (
Expand Down
2 changes: 1 addition & 1 deletion netutils/regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def regex_search(pattern: str, string: str) -> t.Union[t.List[str], str, None]:


def regex_split(pattern: str, string: str, maxsplit: int = 0) -> t.List[str]:
"""Given a regex pattern and string, return the split the object based on the patern a single element or single element of original value if there is no match.
"""Given a regex pattern and string, return the split the object based on the pattern a single element or single element of original value if there is no match.
The main purpose of this function is provide a Jinja2 filter as this is simply a wrapper around `re.split`.
Expand Down

0 comments on commit 445f6ae

Please sign in to comment.