Skip to content

Commit

Permalink
Merge pull request #1592 from napalm-automation/develop
Browse files Browse the repository at this point in the history
NAPALM Release 4.0.0
  • Loading branch information
mirceaulinic committed Jun 3, 2022
2 parents fe35c90 + dde6a59 commit bfe9778
Show file tree
Hide file tree
Showing 82 changed files with 3,442 additions and 1,509 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
---
---
name: build
on: [push, pull_request]
permissions:
contents: read

jobs:
std_tests:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9, 3.10.0]

steps:
- name: Checkout repository
Expand All @@ -33,10 +36,14 @@ jobs:
run: |
pylama .
- name: Run type checker
run: |
mypy -p napalm --config-file mypy.ini
- name: Run Tests
run: |
py.test --cov=napalm --cov-report term-missing -vs --pylama
build_docs:
needs: std_tests
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
tags:
- '*'

permissions:
contents: read

jobs:
deploy:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ Install
pip install napalm
```

*Note*: Beginning with release 4.0.0 and later, NAPALM offers support for
Python 3.7+ only.

*Note*: Beginning with release 3.0.0 and later, NAPALM offers support for
Python 3.6+ only.

Expand Down
5 changes: 5 additions & 0 deletions docs/installation/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ You can install napalm with pip:
That will install all the core drivers currently available.

.. note::

Beginning with release 4.0.0 and later, NAPALM offers support for Python
3.7+ only.

.. note::

Beginning with release 3.0.0 and later, NAPALM offers support for Python
Expand Down
2 changes: 2 additions & 0 deletions docs/support/eos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Minimum Version

To be able to support the ``compare_config``, ``load_merge_candidate`` or ``load_replace_candidate`` methods you will require to run at least EOS version `4.15.0F`.

The ssh driver for the config session timers requires you to run at least EOS 4.18.0F.

Multi-line/HEREDOC
~~~~~~~~~~~~~~~~~~
EOS configuration is loaded via ``pyeapi.eapilib.Node.run_commands()``, which by itself cannot handle multi-line commands
Expand Down
14 changes: 7 additions & 7 deletions docs/support/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ ____________________________________
* :code:`use_keys` (ios, iosxr, nxos_ssh) - Paramiko argument, enable searching for discoverable private key files in ``~/.ssh/`` (default: ``False``).
* :code:`eos_autoComplete` (eos) - Allows to set `autoComplete` when running commands. (default: ``None`` equivalent to ``False``)
* :code:`config_encoding` (iosxr_netconf) - Set encoding to either ``"xml"`` or ``"cli"`` for configuration load methods. (default: ``"cli"``)
* :code:`eos_fn0039_config` (eos) - Transform old style configuration to the new style, available beginning with EOS release 4.23.0, as per FN 0039. Beware
* :code:`eos_fn0039_config` (eos) - Transform old style configuration to the new style, available beginning with EOS release 4.23.0, as per FN 0039. Beware
that enabling this option will change the configuration you're loading through NAPALM. Default: ``False`` (won't change your configuration commands).
.. versionadded:: 3.0.1

Expand All @@ -147,9 +147,9 @@ ______________________

Certain drivers support providing an alternate transport in the :code:`optional_args`, overriding the default protocol to connect with. Allowed transports are therefore device/library dependant:

=============== ==================== ==================== ===================
_ EOS NXOS IOS
=============== ==================== ==================== ===================
**Default** ``https`` ``https`` ``ssh``
**Supported** ``http``, ``https`` ``http``, ``https`` ``telnet``, ``ssh``
=============== ==================== ==================== ===================
=============== ============================ ==================== ===================
_ EOS NXOS IOS
=============== ============================ ==================== ===================
**Default** ``https`` ``https`` ``ssh``
**Supported** ``http``, ``https``, ``ssh`` ``http``, ``https`` ``telnet``, ``ssh``
=============== ============================ ==================== ===================
27 changes: 26 additions & 1 deletion docs/support/nxos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,29 @@ As a result, merges are **not atomic**.
Diffs
_____

Diffs for merges are simply the lines in the merge candidate config.
Diffs for merges are simply the lines in the merge candidate config. `Netutils <https://netutils.readthedocs.io/en/latest/>`__ is used for creating the merge diff between the candidate and running configurations.
One caveat of using netutils diff of configurations is that the diff is performed offline and not online in the device.

Example assuming that the device config contains:

.. code-block::
interface loopback0
ip address 10.1.4.4/32
ip router ospf 100 area 0.0.0.1
Then what you will get with the diff:

.. code-block:: python
candidate_cfg = """
interface loopback0
ip address 10.1.4.5/32
ip router ospf 100 area 0.0.0.1
"""
nxos1.load_merge_candidate(config=candidate_cfg)
print(nxos1.compare_config())
interface loopback0
ip address 10.1.4.5/32
23 changes: 22 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ allow_redefinition = True
[mypy-napalm.base.*]
disallow_untyped_defs = True

[mypy-napalm.nxos.*]
disallow_untyped_defs = True

[mypy-napalm.eos.*]
ignore_errors = True

[mypy-napalm.ios.*]
ignore_errors = True

[mypy-napalm.iosxr_netconf.*]
ignore_errors = True

[mypy-napalm.nxapi_plumbing.*]
disallow_untyped_defs = True

[mypy-napalm.base.clitools.*]
ignore_errors = True

[mypy-napalm.base.test.*]
ignore_errors = True

Expand All @@ -23,11 +41,14 @@ ignore_missing_imports = True
[mypy-lxml.*]
ignore_missing_imports = True

[mypy-ciscoconfparse]
[mypy-netutils.*]
ignore_missing_imports = True

[mypy-textfsm]
ignore_missing_imports = True

[mypy-ttp]
ignore_missing_imports = True

[mypy-pytest]
ignore_missing_imports = True
6 changes: 3 additions & 3 deletions napalm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

# Verify Python Version that is running
try:
if not (sys.version_info.major == 3 and sys.version_info.minor >= 6):
raise RuntimeError("NAPALM requires Python 3.6 or greater")
if not (sys.version_info.major == 3 and sys.version_info.minor >= 7):
raise RuntimeError("NAPALM requires Python 3.7 or greater")
except AttributeError:
raise RuntimeError("NAPALM requires Python 3.6 or greater")
raise RuntimeError("NAPALM requires Python 3.7 or greater")

try:
__version__ = pkg_resources.get_distribution("napalm").version
Expand Down
4 changes: 3 additions & 1 deletion napalm/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import importlib

# NAPALM base
from typing import Type

from napalm.base.base import NetworkDriver
from napalm.base.exceptions import ModuleImportError
from napalm.base.mock import MockDriver
Expand All @@ -29,7 +31,7 @@
]


def get_network_driver(name, prepend=True):
def get_network_driver(name: str, prepend: bool = True) -> Type[NetworkDriver]:
"""
Searches for a class derived form the base NAPALM class NetworkDriver in a specific library.
The library name must repect the following pattern: napalm_[DEVICE_OS].
Expand Down

0 comments on commit bfe9778

Please sign in to comment.