Skip to content

Commit

Permalink
Merge pull request #75 from h4ndzdatm0ld/release/v2.1.0
Browse files Browse the repository at this point in the history
Release/v2.1.0
  • Loading branch information
h4ndzdatm0ld authored Oct 13, 2024
2 parents d4104b3 + edb3fd2 commit a8bc7de
Show file tree
Hide file tree
Showing 50 changed files with 1,456 additions and 578 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Lint & Code Format
run: |
echo 'Rnning Ruff' && \
poetry run ruff . && \
poetry run ruff check . && \
echo 'Running Black' && \
poetry run black --check --diff . && \
echo 'Running Yamllint' && \
Expand All @@ -38,7 +38,7 @@ jobs:
- "linters"
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v2
- name: Setup python
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: "Documentation"
on:
push:
branches:
- "master"
- "develop"

jobs:
documentation:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,4 @@ clab-clab-topo-netconf.yml/
.clab-arista.yml.bak
clab-arista-testing.yml
test/test_data/schemas
tests/test_data/schema_path/nokia-conf-aaa.yang
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PYTHON_VER=3.8
ARG PYTHON_VER=3.9

FROM python:${PYTHON_VER} AS base

Expand All @@ -21,7 +21,7 @@ COPY . .
RUN poetry install --no-interaction

RUN echo 'Rnning Ruff' && \
ruff . && \
ruff check . && \
echo 'Running Black' && \
black --check --diff . && \
echo 'Running Yamllint' && \
Expand Down
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ 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).

## [2.1.0] - 2024-10-13

- Deprecation of Python 3.8
- Formatting Changes with Black
- Updated CI/CD to use `ruff check`

## [2.0.0] - 2022-03-14

### Added
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Configuration for Documentation."""

# pylint: disable-all
# Configuration file for the Sphinx documentation builder.
#
Expand Down
1 change: 1 addition & 0 deletions nornir_netconf/plugins/connections/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Netconf Connection Plugin."""

from nornir_netconf.plugins.connections.netconf import CONNECTION_NAME, Netconf

__all__ = ("Netconf", "CONNECTION_NAME")
1 change: 1 addition & 0 deletions nornir_netconf/plugins/connections/netconf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Netconf Connection Plugin."""

from typing import Any, Dict, Optional

from ncclient import manager
Expand Down
1 change: 1 addition & 0 deletions nornir_netconf/plugins/helpers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Helper Functions."""

from .general import check_file, create_folder, write_output
from .models import RpcResult, SchemaResult
from .rpc import check_capability
Expand Down
1 change: 1 addition & 0 deletions nornir_netconf/plugins/helpers/general.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""General Helpers."""

import logging
import os.path
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions nornir_netconf/plugins/helpers/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Data Models."""

from dataclasses import dataclass, field
from typing import List, Optional

Expand Down
1 change: 1 addition & 0 deletions nornir_netconf/plugins/helpers/rpc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Helper to extract info from RPC reply."""

from typing import List


Expand Down
3 changes: 3 additions & 0 deletions nornir_netconf/plugins/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Operations are separated into their own categorized folder.
"""

from .capabilities.netconf_capabilities import netconf_capabilities
from .editing.netconf_commit import netconf_commit
from .editing.netconf_edit_config import netconf_edit_config
Expand All @@ -10,6 +11,7 @@
from .retrieval.netconf_get import netconf_get
from .retrieval.netconf_get_config import netconf_get_config
from .retrieval.netconf_get_schemas import netconf_get_schemas
from .rpc.netconf_rpc import netconf_rpc

__all__ = (
"netconf_capabilities",
Expand All @@ -20,4 +22,5 @@
"netconf_lock",
"netconf_get_schemas",
"netconf_validate",
"netconf_rpc",
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""NETCONF capabilities."""

from nornir.core.task import Result, Task

from nornir_netconf.plugins.connections import CONNECTION_NAME
Expand Down
1 change: 1 addition & 0 deletions nornir_netconf/plugins/tasks/editing/netconf_commit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""NETCONF commit."""

from typing import Optional

from ncclient.manager import Manager
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""NETCONF edit config."""

from typing import Optional

from ncclient.manager import Manager
Expand Down
1 change: 1 addition & 0 deletions nornir_netconf/plugins/tasks/editing/netconf_validate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""NETCONF validate config."""

from typing import Optional

from ncclient.manager import Manager
Expand Down
1 change: 1 addition & 0 deletions nornir_netconf/plugins/tasks/locking/netconf_lock.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""NETCONF lock."""

from typing import Optional

from ncclient.manager import Manager
Expand Down
1 change: 1 addition & 0 deletions nornir_netconf/plugins/tasks/retrieval/netconf_get.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""NETCONF get."""

from nornir.core.task import Optional, Result, Task

from nornir_netconf.plugins.connections import CONNECTION_NAME
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""NETCONF get config."""

from typing import Any, Dict, Optional

from nornir.core.task import Result, Task
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""NETCONF Schemas."""

from ncclient.operations.rpc import RPCError
from nornir.core.task import List, Result, Task

Expand Down
48 changes: 48 additions & 0 deletions nornir_netconf/plugins/tasks/rpc/netconf_rpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""NETCONF rpc generic call."""

import re
from typing import Optional

from ncclient import xml_
from ncclient.manager import Manager
from nornir.core.task import Result, Task

from nornir_netconf.plugins.connections import CONNECTION_NAME
from nornir_netconf.plugins.helpers import RpcResult


def netconf_rpc(
task: Task,
payload: str,
manager: Optional[Manager] = None,
) -> Result:
"""This method is a "bare-bones" rpc call which does not apply any
formatting/standardization beyond the outer most rpc tag.
Arguments:
payload (str): Payload snippet to apply
manager (Manager): NETCONF Manager
Examples:
Simple example::
> desired_payload='<save-config xmlns="http://cisco.com/yang/cisco-ia"/>'
> nr.run(task= netconf_rpc, payload=desired_payload)
Returns:
Result object with the following attributes set::
* result (RpcResult): Rpc and Manager
"""
if not manager:
manager = task.host.get_connection(CONNECTION_NAME, task.nornir.config)

# convert payload to element, set namespace (if not set) and send RPC
data = xml_.to_ele(payload)
if not re.match(r"{.*}.*", xml_.parse_root(payload)[0]):
data.set("xmlns", xml_.BASE_NS_1_0)

result = manager.rpc(data)

result = RpcResult(rpc=result, manager=manager)
return Result(host=task.host, result=result)
Loading

0 comments on commit a8bc7de

Please sign in to comment.