Skip to content

Commit 0f30e72

Browse files
jeffkalaqdukfabaffitdependsnetworksDr. X
authored
1.2.0 release (#144)
* Updated lib mapping docs (#113) * Updated lib mapping docs * Updated per review suggestions * Pinned mistune for m2r2 (#114) * Switch to poetry-core * Update banner parsing for EOS (#121) Update banner parsing for EOS * Fixes encrypt type7 (#122) * fixes encrypt type7 * Document support on duplicate lines (#128) * Few updates to PR of 125 (#129) * initial pass at type hinting and getting mypy to run * update tasks and ci to do mypy as well * rm unused import * fix contributing end-line number * fix contributing end-line number * Add py.typed file to signify availability of type hints to third parties. * Updates to type hinting. * Add EOS _build_banner type hints. * Address feedback. * Linting. * Remove .idea from commit and ignore in .gitignore. * Remove remnants of merge conflict. * PR feedback. * PR comments. * Ignore pylint errors for abstract-method. * Black. * add examples and better exception messaging Co-authored-by: Leo Kirchner <[email protected]> * Adding nxos_ssh to Napalm mapper (#138) * Update CODEOWNERS (#134) adding codeowner * prep for 1.2.0 release (#143) * prep for 1.2.0 release * Update CHANGELOG.md Co-authored-by: Jeff Kala <[email protected]> Co-authored-by: Jeff Kala <[email protected]> Co-authored-by: Adam Byczkowski <[email protected]> Co-authored-by: Fabian Affolter <[email protected]> Co-authored-by: Ken Celenza <[email protected]> Co-authored-by: Dr. X <[email protected]> Co-authored-by: Leo Kirchner <[email protected]> Co-authored-by: Joe Wesch <[email protected]> Co-authored-by: Andrew Bates <[email protected]>
1 parent 081d226 commit 0f30e72

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2080
-682
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Default owner(s) of all files in this repository
2-
* @itdependsnetworks @jeffkala @qduk
2+
* @itdependsnetworks @jeffkala @qduk @abates

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ jobs:
3232
run: "poetry run invoke bandit"
3333
needs:
3434
- "black"
35+
mypy:
36+
runs-on: "ubuntu-20.04"
37+
env:
38+
INVOKE_LOCAL: "True"
39+
steps:
40+
- name: "Check out repository code"
41+
uses: "actions/checkout@v2"
42+
- name: "Setup environment"
43+
uses: "networktocode/gh-action-setup-poetry-environment@v2"
44+
- name: "Type-Hints: mypy"
45+
run: "poetry run invoke mypy"
46+
needs:
47+
- "black"
3548
pydocstyle:
3649
runs-on: "ubuntu-20.04"
3750
env:
@@ -103,6 +116,7 @@ jobs:
103116
PYTHON_VER=${{ env.PYTHON_VER }}
104117
needs:
105118
- "bandit"
119+
- "mypy"
106120
- "pydocstyle"
107121
- "flake8"
108122
- "yamllint"

.gitignore

Lines changed: 1 addition & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -192,48 +192,11 @@ $RECYCLE.BIN/
192192
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
193193
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
194194

195-
# User-specific stuff
196-
.idea/**/workspace.xml
197-
.idea/**/tasks.xml
198-
.idea/**/usage.statistics.xml
199-
.idea/**/dictionaries
200-
.idea/**/shelf
201-
202-
# Generated files
203-
.idea/**/contentModel.xml
204-
205-
# Sensitive or high-churn files
206-
.idea/**/dataSources/
207-
.idea/**/dataSources.ids
208-
.idea/**/dataSources.local.xml
209-
.idea/**/sqlDataSources.xml
210-
.idea/**/dynamic.xml
211-
.idea/**/uiDesigner.xml
212-
.idea/**/dbnavigator.xml
213-
214-
# Gradle
215-
.idea/**/gradle.xml
216-
.idea/**/libraries
217-
218-
# Gradle and Maven with auto-import
219-
# When using Gradle or Maven with auto-import, you should exclude module files,
220-
# since they will be recreated, and may cause churn. Uncomment if using
221-
# auto-import.
222-
# .idea/artifacts
223-
# .idea/compiler.xml
224-
# .idea/jarRepositories.xml
225-
# .idea/modules.xml
226-
# .idea/*.iml
227-
# .idea/modules
228-
# *.iml
229-
# *.ipr
195+
.idea/
230196

231197
# CMake
232198
cmake-build-*/
233199

234-
# Mongo Explorer plugin
235-
.idea/**/mongoSettings.xml
236-
237200
# File-based project format
238201
*.iws
239202

@@ -246,51 +209,12 @@ out/
246209
# JIRA plugin
247210
atlassian-ide-plugin.xml
248211

249-
# Cursive Clojure plugin
250-
.idea/replstate.xml
251-
252212
# Crashlytics plugin (for Android Studio and IntelliJ)
253213
com_crashlytics_export_strings.xml
254214
crashlytics.properties
255215
crashlytics-build.properties
256216
fabric.properties
257217

258-
# Editor-based Rest Client
259-
.idea/httpRequests
260-
261-
# Android studio 3.1+ serialized cache file
262-
.idea/caches/build_file_checksums.ser
263-
264-
### PyCharm Patch ###
265-
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
266-
267-
# *.iml
268-
# modules.xml
269-
# .idea/misc.xml
270-
# *.ipr
271-
272-
# Sonarlint plugin
273-
# https://plugins.jetbrains.com/plugin/7973-sonarlint
274-
.idea/**/sonarlint/
275-
276-
# SonarQube Plugin
277-
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
278-
.idea/**/sonarIssues.xml
279-
280-
# Markdown Navigator plugin
281-
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
282-
.idea/**/markdown-navigator.xml
283-
.idea/**/markdown-navigator-enh.xml
284-
.idea/**/markdown-navigator/
285-
286-
# Cache file creation bug
287-
# See https://youtrack.jetbrains.com/issue/JBR-2257
288-
.idea/$CACHE_FILE$
289-
290-
# CodeStream plugin
291-
# https://plugins.jetbrains.com/plugin/12206-codestream
292-
.idea/codestream.xml
293-
294218
### vscode ###
295219
.vscode/*
296220
*.code-workspace

CHANGELOG.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Changelog
22

3+
## v1.2.0 - 2022-08
4+
5+
### Added
6+
7+
- #128 Documentation for Nokia SROS duplicate lines/duplicate line detection
8+
- #138 Added nxos_ssh to Napalm mapper
9+
10+
### Changed
11+
12+
- #113 Updated lib mapping docs
13+
- #115 Switched build backend to poetry-core
14+
- #121 Update banner parsing for EOS
15+
- #129 Add type hints to the whole project and mypy testing setup and CI
16+
- #134 Updated CODEOWNERS
17+
18+
### Fixed
19+
20+
- #122 Fixed encrypt type7
21+
322
## v1.1.0 - 2022-04
423

524
### Added
@@ -23,7 +42,7 @@
2342

2443
### Added
2544

26-
- #69 Normalise banner demiliter for IOS to ^C & support parsing delimiter ^
45+
- #69 Normalise banner delimiter for IOS to ^C & support parsing delimiter ^
2746

2847
### Fixed
2948

@@ -113,7 +132,7 @@
113132

114133
### Fixed
115134

116-
- Enable docsting tests
135+
- Enable docstring tests
117136
- Fix docstring tests
118137
- Fix wording and links on README
119138

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Functions are grouped with like functions, such as IP or MAC address based funct
2424
* Compliance - Provides the ability to compare two configurations to sanely understand the differences.
2525
* Parsing - Provides the ability to parse configuration for the minor differences that are there.
2626
* DNS - Provides the ability to work with DNS, such as validating that a FQDN is resolvable.
27-
* Interface - Provides the ability to work with interface names, expanding, abbreviating, and spliting the names.
27+
* Interface - Provides the ability to work with interface names, expanding, abbreviating, and splitting the names.
2828
* IP Address - Provides the ability to work with IP addresses, primarily exposing Python `ipaddress` functionality.
2929
* Library Mapper - Provides mappings in expected vendor names between Netmiko, NAPALM, pyntc, ntc-templates, pyats, and scrapli.
3030
* MAC Address - Provides the ability to work with MAC addresses such as validating or converting to integer.
@@ -152,15 +152,15 @@ Except for unit tests, testing is only supported on Python 3.7.
152152
The project is packaged with a light development environment based on `docker-compose` to help with the local development of the project and to run tests within TravisCI.
153153

154154
The project is following Network to Code software development guidelines and are leveraging the following:
155-
- Black, Pylint, Bandit, flake8, and pydocstyle for Python linting and formatting.
155+
- Black, Pylint, Bandit, Mypy, flake8, and pydocstyle for Python linting and formatting.
156156
- pytest, coverage, and unittest for unit tests.
157157

158158
There are a number of things that are required in order to have a successful PR.
159159

160160
- All new functions must contain at least 1 example in their docstrings.
161161
- Docstrings must conform to the google docstring [convention](https://google.github.io/styleguide/pyguide.html#381-docstrings).
162162
- Unit test for newly added functions are required.
163-
- If applicable, tests related to config parsing and compliuance must be added.
163+
- If applicable, tests related to config parsing and compliance must be added.
164164
- Update the jinja2 filter (netutils.utils.jinja2_convenience_function) for any new functions (see below for details).
165165
- If you create a new file in the `netutils` folder, you must create a new folder and `index.rst` in the docs folder (see below for details).
166166
- Your PR must not introduce any required dependencies. You can introduce optional or development dependencies.
@@ -219,6 +219,7 @@ Each command can be executed with `invoke <command>`. Each command also has its
219219
black Run black to check that Python files adhere to its style standards.
220220
coverage Run the coverage report against pytest.
221221
flake8 Run flake8 to check that Python files adhere to its style standards.
222+
mypy Run mypy to validate typing-hints.
222223
pylint Run pylint code analysis.
223224
pydocstyle Run pydocstyle to validate docstring formatting adheres to NTC defined standards.
224225
pytest Run pytest for the specified name and Python version.

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
m2r2==0.2.7
2+
mistune==0.8.4
23
Sphinx
34
toml
45
sphinx-rtd-theme

docs/source/conf.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@
1313
import os
1414
import sys
1515
import toml
16+
from jinja2 import Environment, FileSystemLoader
17+
1618

1719
sys.path.insert(0, os.path.abspath("../.."))
20+
from netutils import lib_mapper # noqa: E402
21+
22+
DIR_PATH = os.path.dirname(os.path.realpath(__file__))
1823
sys.path.append(os.path.abspath("sphinxext"))
1924
toml_dict = toml.load("../../pyproject.toml")
2025

21-
2226
# -- Project information -----------------------------------------------------
2327

2428
project = toml_dict["tool"]["poetry"]["name"]
@@ -63,3 +67,29 @@
6367
# relative to this directory. They are copied after the builtin static files,
6468
# so a file named "default.css" will overwrite the builtin "default.css".
6569
html_static_path = ["_static"]
70+
71+
72+
def build_mapping_tables(app):
73+
"""Build the library mappings tables."""
74+
env = Environment(loader=FileSystemLoader(f"{DIR_PATH}"))
75+
template_file = env.get_template("table_template.j2")
76+
77+
LIST_OF_MAP_DICTS = []
78+
for attr in dir(lib_mapper):
79+
if (attr.endswith("MAPPER_REVERSE") or attr.endswith("_MAPPER")) and not (
80+
attr.startswith("_") or attr.startswith("NETMIKO") or attr.startswith("MAIN")
81+
):
82+
LIST_OF_MAP_DICTS.append(attr)
83+
84+
for dict_name in LIST_OF_MAP_DICTS:
85+
lib_name = dict_name.split("_")[0]
86+
filename = f"{lib_name}_reverse" if "REVERSE" in dict_name else lib_name
87+
headers = ["NORMALIZED", lib_name] if "REVERSE" in dict_name else [lib_name, "NORMALIZED"]
88+
rendered_template = template_file.render(lib_names=headers, mappings=getattr(lib_mapper, dict_name))
89+
with open(f"{DIR_PATH}/netutils/lib_mapping/{filename}_table.rst", "w") as table_file:
90+
table_file.write(rendered_template)
91+
92+
93+
def setup(app):
94+
"""Call methods during builder initiated."""
95+
app.connect("builder-inited", build_mapping_tables)

docs/source/contributing/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ Contributing
44

55
.. mdinclude:: ../../../README.md
66
:start-line: 148
7-
:end-line: 233
7+
:end-line: 234
88

docs/source/netutils/configs/index.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,25 @@ F5 Parser
2525
Nokia SROS Parser
2626
-----------------
2727
- The section banners have been simplified to extract the section header itself. This means that `echo "System Configuration"` will be converted to just "System Configuration".
28+
29+
Duplicate Line Detection
30+
--------------------------
31+
In some circumstances replacing lines, such as secrets without uniqueness in the replacement, will result in duplicated lines that are invalid configuration, such as::
32+
33+
snmp-server community <<REPLACED>> RO SNMP_ACL_RO
34+
snmp-server community <<REPLACED>> RO SNMP_ACL_RO
35+
36+
There are some known use cases, such as the below that are considered::
37+
38+
router bgp 6500
39+
bgp router-id 10.0.0.11
40+
!
41+
address-family ipv4 unicast
42+
redistribute connected
43+
exit-address-family <--- duplicated hierarchy
44+
!
45+
address-family l2vpn evpn
46+
neighbor underlay activate
47+
exit-address-family <--- duplicated hierarchy
48+
49+
Documented use cases that are actual configuration on a network device are considered valid and should be opened for bug fixes. However, configuration that does not actually exist on the running config of network devices are out of scope for the parser.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
.. raw:: html
2+
3+
<table border="1" class="docutils">
4+
<th>NORMALIZED</th><th>ANSIBLE</th>
5+
6+
<tr>
7+
<td>arista_eos</td><td>arista.eos.eos</td>
8+
</tr>
9+
<tr>
10+
<td>ciena_saos</td><td>ciena.saos6.saos6</td>
11+
</tr>
12+
<tr>
13+
<td>cisco_asa</td><td>cisco.asa.asa</td>
14+
</tr>
15+
<tr>
16+
<td>cisco_ios</td><td>cisco.ios.ios</td>
17+
</tr>
18+
<tr>
19+
<td>cisco_xr</td><td>cisco.iosxr.iosxr</td>
20+
</tr>
21+
<tr>
22+
<td>cisco_nxos</td><td>cisco.nxos.nxos</td>
23+
</tr>
24+
<tr>
25+
<td>huawei</td><td>community.network.ce</td>
26+
</tr>
27+
<tr>
28+
<td>dell_os6</td><td>dellemc.os6.os6</td>
29+
</tr>
30+
<tr>
31+
<td>dell_os9</td><td>dellemc.os9.os9</td>
32+
</tr>
33+
<tr>
34+
<td>dell_os10</td><td>dellemc.os10.0s10</td>
35+
</tr>
36+
<tr>
37+
<td>ericsson_ipos</td><td>community.network.eric_eccli</td>
38+
</tr>
39+
<tr>
40+
<td>extreme_exos</td><td>community.network.exos</td>
41+
</tr>
42+
<tr>
43+
<td>extreme_netiron</td><td>community.network.ironware</td>
44+
</tr>
45+
<tr>
46+
<td>extreme_nos</td><td>community.network.nos</td>
47+
</tr>
48+
<tr>
49+
<td>extreme_slx</td><td>community.network.slxos</td>
50+
</tr>
51+
<tr>
52+
<td>extreme_vsp</td><td>community.network.voss</td>
53+
</tr>
54+
<tr>
55+
<td>juniper_junos</td><td>junipernetworks.junos.junos</td>
56+
</tr>
57+
<tr>
58+
<td>lenovo_cnos</td><td>community.network.cnos</td>
59+
</tr>
60+
<tr>
61+
<td>lenovo_enos</td><td>community.network.enos</td>
62+
</tr>
63+
<tr>
64+
<td>mikrotik_routeros</td><td>community.network.routeros</td>
65+
</tr>
66+
<tr>
67+
<td>nokia_sros</td><td>community.network.sros</td>
68+
</tr>
69+
<tr>
70+
<td>pluribus</td><td>community.network.netvisor</td>
71+
</tr>
72+
<tr>
73+
<td>ruckus_icx</td><td>community.network.icx</td>
74+
</tr>
75+
<tr>
76+
<td>vyos</td><td>vyos.vyos.vyos</td>
77+
</tr>
78+
</table>

0 commit comments

Comments
 (0)