Skip to content

Commit d6b06ae

Browse files
authored
Implementing Dataclasses + simplifying results. Working towards 2.0 (#56)
* Feature/testing fixup (#53) * Feature/drop xmltodict (#52) * test passing, dropped xmltodict + arista ceos * ci * CI * perms? * testing * testing * clab command * clab * RPC Reply changed * EOF L * passing * Various test modifications * Implementing DataClass * netconf lock replying RpcResult * the past is the past * Working through tests * Tests passing * dropped 3.7, pipeline, tests * CI ruff * ruff-poetry * pass linters, before testing * Documentation API updated * test update * Test rebase (#54) * Feature/drop xmltodict (#52) * test passing, dropped xmltodict + arista ceos * ci * CI * perms? * testing * testing * clab command * clab * RPC Reply changed * EOF L * passing * rebased dev
1 parent 5e06567 commit d6b06ae

40 files changed

+622
-1141
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ LICENSE
2222
**/.vscode/
2323
invoke*.yml
2424
tasks.py
25-
clab-files/
2625
clab-files
26+
clab-*

.flake8

Lines changed: 0 additions & 4 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on: # yamllint disable-line rule:truthy rule:comments
66

77
jobs:
88
linters:
9-
name: linters
9+
name: "Code Quality - Linting"
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v2
@@ -20,14 +20,12 @@ jobs:
2020
2121
- name: Lint & Code Format
2222
run: |
23-
echo 'Running Flake8' && \
24-
poetry run flake8 . && \
23+
echo 'Rnning Ruff' && \
24+
poetry run ruff . && \
2525
echo 'Running Black' && \
2626
poetry run black --check --diff . && \
2727
echo 'Running Yamllint' && \
2828
poetry run yamllint . && \
29-
echo 'Running pydocstyle' && \
30-
poetry run pydocstyle . && \
3129
echo 'Running Bandit' && \
3230
poetry run bandit --recursive ./ --configfile .bandit.yml && \
3331
echo 'Running MyPy' && \
@@ -36,9 +34,11 @@ jobs:
3634
test:
3735
name: Testing on Python ${{ matrix.python-version }}
3836
runs-on: ubuntu-latest
37+
needs:
38+
- "linters"
3939
strategy:
4040
matrix:
41-
python-version: ["3.7", "3.8", "3.9", "3.10"]
41+
python-version: ["3.8", "3.9", "3.10", "3.11"]
4242
steps:
4343
- uses: actions/checkout@v2
4444
- name: Setup python
@@ -47,22 +47,19 @@ jobs:
4747
python-version: ${{ matrix.python-version }}
4848
architecture: x64
4949

50-
- name: Start NETCONF Sysrepo container
51-
run: docker-compose up -d sysrepo
52-
53-
- name: "Install Clab"
50+
- name: "Install Containerlab"
5451
run: |
5552
sudo bash -c "$(curl -sL https://get.containerlab.dev)"
5653
57-
- name: Start Arista CEOS
58-
run: sudo containerlab deploy -t clab-files/clab-arista.yml
54+
- name: "Start Arista CEOS"
55+
run: "sudo containerlab deploy -t clab-files/clab-arista.yml"
5956

6057
- name: "Wait for Arista CEOS to be ready"
6158
uses: "jakejarvis/wait-action@master"
6259
with:
6360
time: "10"
6461

65-
- name: "CHOWN CLAB Files"
62+
- name: "Change ownership of Containerlab files"
6663
run: "sudo chown -R $USER clab-arista-testing.yml"
6764

6865
- name: Install dependencies

Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,14 @@ COPY . .
2323
RUN poetry install --no-interaction
2424

2525
# Runs all necessary linting and code checks
26-
RUN echo 'Running Flake8' && \
27-
flake8 . && \
26+
RUN echo 'Rnning Ruff' && \
27+
ruff . && \
2828
echo 'Running Black' && \
2929
black --check --diff . && \
3030
echo 'Running Yamllint' && \
3131
yamllint . && \
3232
echo 'Running Pylint' && \
3333
find . -name '*.py' | xargs pylint && \
34-
echo 'Running pydocstyle' && \
35-
pydocstyle . && \
3634
echo 'Running Bandit' && \
3735
bandit --recursive ./ --configfile .bandit.yml && \
3836
echo 'Running MyPy' && \

README.md

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def example_global_lock(task):
195195
lock = task.run(netconf_lock, datastore="candidate", operation="lock")
196196
# Retrieve the Manager(agent) from lock operation and store for further
197197
# operations.
198-
task.host["manager"] = lock.result["manager"]
198+
task.host["manager"] = lock.result.manager
199199

200200

201201
def example_edit_config(task):
@@ -247,7 +247,6 @@ if __name__ == "__main__":
247247
## Additional Documentation
248248
249249
- [NCClient](https://ncclient.readthedocs.io/en/latest/)
250-
- [Sysrepo](https://www.sysrepo.org/)
251250
252251
## Contributions
253252
@@ -289,12 +288,6 @@ export SKIP_INTEGRATION_TESTS=False
289288
docker-compose up -d
290289
```
291290

292-
If you do not want to run integration tests, only bring up the `netconf_sysrepo` docker service and continue
293-
294-
```bash
295-
docker-compose up netconf_sysrepo -d
296-
```
297-
298291
```bash
299292
poetry install && poetry shell
300293
```
@@ -314,22 +307,6 @@ Devices testing against Always-ON Sandboxes (Cisco DevNet)
314307

315308
- Cisco IOS-XE - Cisco IOS XE Software, Version 17.03.01a These tests are run locally.
316309

317-
### Sysrepo: netopeer2
318-
319-
The majority of integration tests are run against a docker instance of [netopeer2](https://hub.docker.com/r/sysrepo/sysrepo-netopeer2)
320-
321-
From the [Sysrepo](https://www.sysrepo.org/) website:
322-
323-
"Netopeer2 and Sysrepo provide a fully open source and standards compliant implementation of a NETCONF server and YANG configuration data stores."
324-
325310
## Documentation
326311

327312
Documentation is generated with Sphinx and hosted with Github Pages. [Documentation](https://h4ndzdatm0ld.github.io/nornir_netconf/)
328-
329-
To generate the latest documentation locally:
330-
331-
```bash
332-
sphinx-build -vvv -b html ./docs ./docs/public
333-
cd docs/public
334-
python -m http.server
335-
```

clab-files/clab-arista.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ topology:
1111
binds:
1212
- "mymapping.json:/mnt/flash/EosIntfMapping.json:ro"
1313
nodes:
14-
ceos1:
14+
ceos:
1515
kind: "ceos"
1616
mgmt_ipv4: "172.200.101.11"
17-
ceos2:
18-
kind: "ceos"
19-
mgmt_ipv4: "172.200.101.12"
20-
links:
21-
- endpoints: ["ceos1:eth1", "ceos2:eth1"]

docker-compose.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,8 @@ services:
1111
build:
1212
context: "."
1313
target: "test"
14-
depends_on:
15-
- "sysrepo"
1614
volumes:
1715
- "./:/usr/src/app"
18-
sysrepo:
19-
container_name: "sysrepo"
20-
hostname: "netconf_sysrepo"
21-
image: "sysrepo/sysrepo-netopeer2:latest"
22-
ports:
23-
- "1830:830"
24-
environment:
25-
NACM_RECOVERY_UID: "0"
2616
clab:
2717
image: "ghcr.io/srl-labs/clab"
2818
network_mode: "host"

docs/changelog.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2.0.0] - 2022-xx-xx
8+
9+
### Added
10+
11+
- `ruff` linter
12+
13+
### Changed
14+
15+
- `sysrepo` tests all got replaced by a containerized instance of Arista CEOS
16+
17+
### Removed
18+
19+
- Dropped Python3.7 - Only 3.8 and above is supported.
20+
- `sysrepo` container and dependencies. No tests or reliance on this container anymore.
21+
- `xmltodict` library has been removed. The user should parse XML as they please.
22+
- Flake8 (Replaced by Ruff)
23+
- Pydocstyle (Replaced by Ruff)
24+
725
## [1.1.0] - 2022-10-06
826

927
### Added

docs/conf.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
# add these directories to sys.path here. If the directory is relative to the
1313
# documentation root, use os.path.abspath to make it absolute, like shown here.
1414
#
15-
# import os
16-
# import sys
17-
# sys.path.insert(0, os.path.abspath('.'))
1815
from shutil import copyfile
1916

2017
# -- Project information -----------------------------------------------------
@@ -31,7 +28,7 @@
3128
# Add any Sphinx extension module names here, as strings. They can be
3229
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3330
# ones.
34-
extensions = ["autoapi.extension", "myst_parser"] # Document Python Code
31+
extensions = ["autoapi.extension", "myst_parser", "sphinx.ext.napoleon"]
3532
autoapi_type = "python"
3633
autoapi_dirs = ["../nornir_netconf/"]
3734

@@ -48,7 +45,7 @@
4845
# The theme to use for HTML and HTML Help pages. See the documentation for
4946
# a list of builtin themes.
5047
#
51-
html_theme = "sphinx_rtd_theme"
48+
html_theme = "sphinx_pdj_theme"
5249

5350
# Add any paths that contain custom static files (such as style sheets) here,
5451
# relative to this directory. They are copied after the builtin static files,

examples/example-project/nr_edit_config_global_lock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def example_global_lock(task):
2323
lock = task.run(netconf_lock, datastore="candidate", operation="lock")
2424
# Retrieve the Manager(agent) from lock operation and store for further
2525
# operations.
26-
task.host["manager"] = lock.result["manager"]
26+
task.host["manager"] = lock.result.manager
2727

2828

2929
def example_edit_config(task):

0 commit comments

Comments
 (0)