Skip to content

Commit

Permalink
2.0.0 release to implement changes based on pyntc 1.0.0 release (#21)
Browse files Browse the repository at this point in the history
* Add files via upload

* Update repo with proper logo

* Prep2.0 Release (#20)

* prep for 2.0.0 with 1.0.0 of pyntc being release

* prep 2.0 release
  • Loading branch information
jeffkala authored Apr 8, 2023
1 parent b4130b3 commit 5b9725f
Show file tree
Hide file tree
Showing 16 changed files with 47 additions and 117 deletions.
5 changes: 0 additions & 5 deletions CHANGELOG.md

This file was deleted.

File renamed without changes.
16 changes: 16 additions & 0 deletions docs/admin/release_notes/version_2_0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# v2.0.0 Release Notes

## [2.0.0] 04-2023

### Added

- Add `wait_for_reload` kwarg in `pyntc_reboot` task to mirror updated pyntc methods as of `1.0.0` of pyntc.

### Fixed

- `pyntc_config` - Update docstrings and support both list|str inputs.

### Deprecated

- Remove `pyntc_show_list` tasks, as `pyntc_show` now accepts a list or a str argument.
- Remove `timer` argument from `pyntc_reboot` task as it was deprecated in underlying `pyntc` library in `1.0.0`.
Binary file modified docs/images/nornir_pyntc_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions docs/user/lib_getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ The plugin comes with tasks that expose the basic pyntc functionality.
- [pyntc_reboot](https://github.com/networktocode/pyntc#reboot) - Reboot a network device.
- [pyntc_save](https://github.com/networktocode/pyntc#save-configs) - Save the running configuration of a network device.
- [pyntc_show](https://github.com/networktocode/pyntc#sending-show-commands) - Send a single `show` command to a network device.
- [pyntc_show_list](https://github.com/networktocode/pyntc#sending-multiple-commands) - Send multiple `show` commands to a network device.


## Basic Usage

Expand Down
3 changes: 2 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ nav:
- Uninstall: "admin/uninstall.md"
- Release Notes:
- "admin/release_notes/index.md"
- v1.0.0: "admin/release_notes/version_1_0_0.md"
- v1.0.0: "admin/release_notes/version_1_0.md"
- v2.0.0: "admin/release_notes/version_2_0.md"
- Developer Guide:
- Extending the Library: "dev/extending.md"
- Contributing to the Library: "dev/contributing.md"
Expand Down
11 changes: 1 addition & 10 deletions nornir_pyntc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,14 @@
import importlib_metadata as metadata # type: ignore[no-redef]

from nornir_pyntc.connections import CONNECTION_NAME, Pyntc
from nornir_pyntc.tasks import (
pyntc_config,
pyntc_file_copy,
pyntc_install_os,
pyntc_reboot,
pyntc_save,
pyntc_show,
pyntc_show_list,
)
from nornir_pyntc.tasks import pyntc_config, pyntc_file_copy, pyntc_install_os, pyntc_reboot, pyntc_save, pyntc_show

__version__ = metadata.version(__name__)

__all__ = (
"Pyntc",
"CONNECTION_NAME",
"pyntc_show",
"pyntc_show_list",
"pyntc_config",
"pyntc_file_copy",
"pyntc_install_os",
Expand Down
2 changes: 0 additions & 2 deletions nornir_pyntc/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
from nornir_pyntc.tasks.pyntc_reboot import pyntc_reboot
from nornir_pyntc.tasks.pyntc_save import pyntc_save
from nornir_pyntc.tasks.pyntc_show import pyntc_show
from nornir_pyntc.tasks.pyntc_show_list import pyntc_show_list

__all__ = (
"pyntc_show",
"pyntc_show_list",
"pyntc_config",
"pyntc_file_copy",
"pyntc_install_os",
Expand Down
2 changes: 1 addition & 1 deletion nornir_pyntc/tasks/pyntc_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def pyntc_config(task: Task, commands: List[str]) -> Result:
"""Send configuration command or commands.
Args:
command (list): The commands to send to the device.
commands (list): The commands to send to the device.
Returns:
Result object with:
Expand Down
12 changes: 4 additions & 8 deletions nornir_pyntc/tasks/pyntc_reboot.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
"""Reboot device."""
from requests.exceptions import ConnectionError, ReadTimeout # pylint: disable=redefined-builtin

from nornir.core.task import Result, Task
from requests.exceptions import ( # pylint: disable=redefined-builtin
ConnectionError,
ReadTimeout,
)

from nornir_pyntc.connections import CONNECTION_NAME


def pyntc_reboot(task: Task, timer: int = 0) -> Result:
def pyntc_reboot(task: Task, wait_for_reload: bool = False) -> Result:
"""Reboot device. Reload the controller or controller pair.
Args:
timer (int): The time to wait before reloading.
wait_for_reload (bool): Whether pyntc should wait for device to come back online before returning.
Returns:
Result object with:
* (bool) - True if successful.
"""
pyntc_connection = task.host.get_connection(CONNECTION_NAME, task.nornir.config)
try:
result = pyntc_connection.reboot(timer=timer)
result = pyntc_connection.reboot(wait_for_reload=wait_for_reload)
if result:
return Result(host=task.host, result=result, changed=True, failed=False)
return Result(host=task.host, result=result, changed=False, failed=False)
Expand Down
8 changes: 4 additions & 4 deletions nornir_pyntc/tasks/pyntc_show.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
"""Send a non-configuration command."""
from typing import Any
from typing import Any, Union

from nornir.core.task import Result, Task
from nornir_pyntc.connections import CONNECTION_NAME


def pyntc_show(task: Task, command: str, **kwargs: Any) -> Result:
def pyntc_show(task: Task, command: Union[str, list], **kwargs: Any) -> Result:
"""Send a non-configuration command.
Args:
command (str): The command to send to the device.
command (str|list): The command to send to the device.
kwargs (Any): Additional keyword args to send.
Returns:
Result object with:
* (str) - The output of the show command, which could be raw text or structured data.
* (str|list) - The output of the show command, which could be raw text or structured data.
"""
pyntc_connection = task.host.get_connection(CONNECTION_NAME, task.nornir.config)
result = pyntc_connection.show(command, **kwargs)
Expand Down
21 changes: 0 additions & 21 deletions nornir_pyntc/tasks/pyntc_show_list.py

This file was deleted.

23 changes: 12 additions & 11 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nornir-pyntc"
version = "1.0.1"
version = "2.0.0"
description = "pyntc plugin for Nornir"
authors = ["Network to Code, LLC <[email protected]>"]
license = "Apache-2.0"
Expand All @@ -12,7 +12,7 @@ repository = "https://github.com/networktocode-llc/nornir_pyntc"

[tool.poetry.dependencies]
python = "^3.7"
pyntc = "^0.20.1"
pyntc = "^1.0.0"
nornir = "^3.2.0"

[tool.poetry.dev-dependencies]
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/tasks/test_reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def test_pyntc_reboot_nxos(nornir_conn, monkeypatch):
def mock_reboot(cls, timer): # pylint:disable=unused-argument
def mock_reboot(cls, wait_for_reload): # pylint:disable=unused-argument
return True

monkeypatch.setattr(NXOSDevice, "reboot", mock_reboot)
Expand All @@ -22,7 +22,7 @@ def mock_reboot(cls, timer): # pylint:disable=unused-argument


def test_pyntc_reboot_ios(nornir_conn, monkeypatch):
def mock_reboot(cls, timer): # pylint:disable=unused-argument
def mock_reboot(cls, wait_for_reload): # pylint:disable=unused-argument
return False

monkeypatch.setattr(IOSDevice, "reboot", mock_reboot)
Expand All @@ -35,7 +35,7 @@ def mock_reboot(cls, timer): # pylint:disable=unused-argument


def test_pyntc_reboot_reboottimer_exception(nornir_conn, monkeypatch):
def mock_reboot(cls, timer): # pylint:disable=unused-argument
def mock_reboot(cls, wait_for_reload): # pylint:disable=unused-argument
raise RebootTimeoutError(wait_time=10, hostname="router2")

monkeypatch.setattr(IOSDevice, "reboot", mock_reboot)
Expand All @@ -48,7 +48,7 @@ def mock_reboot(cls, timer): # pylint:disable=unused-argument


def test_pyntc_reboot_timeout_exception(nornir_conn, monkeypatch):
def mock_reboot(cls, timer): # pylint:disable=unused-argument
def mock_reboot(cls, wait_for_reload): # pylint:disable=unused-argument
raise ReadTimeout

monkeypatch.setattr(IOSDevice, "reboot", mock_reboot)
Expand All @@ -61,7 +61,7 @@ def mock_reboot(cls, timer): # pylint:disable=unused-argument


def test_pyntc_reboot_other_exception(nornir_conn, monkeypatch):
def mock_reboot(cls, timer): # pylint:disable=unused-argument
def mock_reboot(cls, wait_for_reload): # pylint:disable=unused-argument
raise ValueError

monkeypatch.setattr(IOSDevice, "reboot", mock_reboot)
Expand Down
45 changes: 0 additions & 45 deletions tests/unit/tasks/test_show_list.py

This file was deleted.

0 comments on commit 5b9725f

Please sign in to comment.