Skip to content

Commit

Permalink
Merge pull request #28 from h4ndzdatm0ld/release-v1.0.0
Browse files Browse the repository at this point in the history
Release v1.0.0
  • Loading branch information
h4ndzdatm0ld authored Jan 18, 2022
2 parents 9311374 + 74986ac commit d60c5e8
Show file tree
Hide file tree
Showing 22 changed files with 1,306 additions and 673 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: nornir_netconf
name: "Nornir NETCONF"

on:
push:
Expand Down Expand Up @@ -41,7 +41,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.6.14', '3.7', '3.8' ]
python-version: [ '3.7', '3.8', '3.9', '3.10' ]
steps:
- uses: actions/checkout@v2
- name: Setup python
Expand All @@ -58,13 +58,11 @@ jobs:
pip install poetry
poetry install --no-interaction
- name: Test with pytest
- name: Pytest
run: |
poetry run pytest --cov=nornir_netconf --cov-report=xml -vv
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}

needs: [ linters ]
27 changes: 27 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: "Documentation"

on:
push:
branches:
- "develop"
pull_request:
branches:
- "develop"

jobs:
documentation:
name: "Documentation"
runs-on: "ubuntu-latest"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v1"
- name: "Sphinx Build"
run: "poetry run sphinx-build -vvv -b html ./docs ./docs/public"
- name: "Deploy auto generated documentation to GH-Pages"
uses: "peaceiris/actions-gh-pages@v3"
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: "./docs/public"
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,7 @@ pip-wheel-metadata/

## Type hints
tests/stubs/*.pyi
*sql*
*sql*

# Docs
docs/README.md
14 changes: 6 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ FROM python:${PYTHON_VER} AS base
WORKDIR /usr/src/app

# Install poetry for dep management
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
ENV PATH="$PATH:/root/.poetry/bin"

# Enable this for testing with ^3.10.1
# RUN pip install cleo tomlkit poetry.core requests cachecontrol cachy html5lib pkginfo virtualenv lockfile

RUN poetry config virtualenvs.create false

# Install project manifest
Expand Down Expand Up @@ -38,14 +42,8 @@ RUN echo 'Running Flake8' && \
echo 'Running MyPy' && \
mypy .

# RUN monkeytype run -m pytest --cov=nornir_netconf --color=yes --disable-pytest-warnings -vvv

# RUN monkeytype list-modules | xargs -n1 -I{} sh -c 'monkeytype stub {} > tests/stubs/{}.pyi'

# RUN pytest --cov nornir_netconf --color yes -vvv tests

# Run full test suite including integration
ENTRYPOINT ["pytest"]

CMD ["--cov=nornir_netconf", "--color=yes", "--disable-pytest-warnings", "-vvv"]
CMD ["--cov=nornir_netconf", "--color=yes", "--disable-pytest-warnings", "--cov-report=xml", "-vvv"]

12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@

Collection of NETCONF tasks and connection plugin for [Nornir](https://github.com/nornir-automation/nornir)

## Documentation

Documentation is generated with Sphinx and hosted with Github Pages. [Documentation](https://h4ndzdatm0ld.github.io/nornir_netconf/)

To generate the latest documentation locally:

```bash
sphinx-build -vvv -b html ./docs ./docs/public
cd docs/public
python -m http.server
```

## Installation

------------
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ services:
target: "test"
depends_on:
- "netconf1"
# volumes:
# - "./:/usr/src/app"
Empty file added docs/.nojekyll
Empty file.
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
9 changes: 8 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ All notable changes to this project will be documented in this file.
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).

## [Unreleased]
## [1.0.0] - 2021-01-17

### Changed

- Removed dependencies locking python version between a range.
- Removed unused dev env dependencies
- Removed version pinning on dev dependencies
- Dropped support for python3.6

## [0.1.0] - 2020-09-10

Expand Down
69 changes: 69 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
"""Configuration for Documentation."""
# pylint: disable-all
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
from shutil import copyfile

# -- Project information -----------------------------------------------------

project = "Nornir NETCONF"
copyright = "2021, Hugo Tinoco"
author = "Hugo Tinoco"

# The full version, including alpha/beta/rc tags
release = "0.1.0"

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ["autoapi.extension", "myst_parser"] # Document Python Code
autoapi_type = "python"
autoapi_dirs = ["../nornir_netconf/"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]

# The suffix of source filenames.
# source_suffix = [".rst", ".md"]
source_suffix = {
".rst": "restructuredtext",
".txt": "markdown",
".md": "markdown",
}

# Copy README every time we build
src = "../README.md"
dst = "./README.md"
copyfile(src, dst)
1 change: 1 addition & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<meta http-equiv="refresh" content="0; url=./public/index.html"/>
40 changes: 40 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.. Nornir NETCONF documentation master file, created by
sphinx-quickstart on Fri Oct 15 08:36:34 2021.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Nornir NETCONF's documentation!
==========================================

Overview
========

Nornir NETCONF is a Nornir plugin to handle NETCONF operations using the ncclient library.

Contents
========

.. toctree::
:maxdepth: 4

Home <self>
Readme <README>

Changelog
=========
.. toctree::
:maxdepth: 1

Changelog <changelog>

API Reference
=============
.. toctree::
:maxdepth: 2

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
Empty file added docs/public/.gitkeep
Empty file.
14 changes: 14 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
site_name: "Nornir NETCONF Documentation"
site_url: "https://h4ndzdatm0ld.github.io/nornir_netconf/"
repo_url: "https://github.com/h4ndzdatm0ld/nornir_netconf"
theme:
name: "readthedocs"
navigation_depth: 3
hljs_languages:
- "yaml"
plugins:
- "search"
- "mkdocstrings"
nav:
- Home: "index.md"
4 changes: 2 additions & 2 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ignore_missing_imports = True
strict_optional = True
warn_unused_ignores = True
warn_return_any = True
python_version = 3.6
python_version = 3.8
warn_unused_configs = True
warn_redundant_casts = True
disallow_subclassing_any = True
Expand All @@ -23,4 +23,4 @@ show_error_codes = True

[mypy-nornir_netconf.plugins.connections]
ignore_errors = False
warn_return_any = True
warn_return_any = True
10 changes: 9 additions & 1 deletion nornir_netconf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
# type: ignore
"""Nornir NETCONF Plugin."""
__version__ = "0.1.0"
try:
from importlib import metadata
except ImportError:
# Python version < 3.8
import importlib_metadata as metadata

# This will read version from pyproject.toml
__version__ = metadata.version("nornir_netconf")
26 changes: 13 additions & 13 deletions nornir_netconf/plugins/connections/netconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ class Netconf:
"""This plugin connects to the device via NETCONF using ncclient library.
Inventory:
extras: See
`here <https://ncclient.readthedocs.io/en/latest/transport.html#ncclient.transport.SSHSession.connect>`_
<https://ncclient.readthedocs.io/en/latest/transport.html#ncclient.transport.SSHSession.connect>`_
Example on how to configure a device to use netconfig without using an ssh agent and without verifying the keys::
---
nc_device:
hostname: 192.168.16.20
username: admin
password: admin
port: 2022
connection_options:
netconf:
extras:
allow_agent: False
hostkey_verify: False
---
nc_device:
hostname: 192.168.16.20
username: admin
password: admin
port: 2022
connection_options:
netconf:
extras:
allow_agent: False
hostkey_verify: False
Then it can be used like::
>>> from nornir import InitNornir
>>> from nornir.core.task import Result, Task
Expand Down
Loading

0 comments on commit d60c5e8

Please sign in to comment.