Skip to content

Commit

Permalink
Merge pull request #40 from ktbyers/develop
Browse files Browse the repository at this point in the history
Release 0.2.0
  • Loading branch information
ktbyers authored Jul 14, 2022
2 parents 8dad209 + c47c346 commit 910cf92
Show file tree
Hide file tree
Showing 6 changed files with 252 additions and 414 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: 3.10.4

- name: Install Poetry
uses: snok/[email protected]
with:
version: 1.1.8
version: 1.1.13
virtualenvs-create: true
virtualenvs-in-project: true

Expand Down
2 changes: 2 additions & 0 deletions nornir_netmiko/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from nornir_netmiko.tasks import netmiko_save_config
from nornir_netmiko.tasks import netmiko_send_command
from nornir_netmiko.tasks import netmiko_send_config
from nornir_netmiko.tasks import netmiko_multiline


__all__ = (
Expand All @@ -14,5 +15,6 @@
"netmiko_file_transfer",
"netmiko_save_config",
"netmiko_send_command",
"netmiko_multiline",
"netmiko_send_config",
)
2 changes: 2 additions & 0 deletions nornir_netmiko/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from nornir_netmiko.tasks.netmiko_save_config import netmiko_save_config
from nornir_netmiko.tasks.netmiko_send_command import netmiko_send_command
from nornir_netmiko.tasks.netmiko_send_config import netmiko_send_config
from nornir_netmiko.tasks.netmiko_multiline import netmiko_multiline


__all__ = (
Expand All @@ -11,4 +12,5 @@
"netmiko_save_config",
"netmiko_send_command",
"netmiko_send_config",
"netmiko_multiline",
)
33 changes: 33 additions & 0 deletions nornir_netmiko/tasks/netmiko_multiline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from typing import Sequence, Union, List, Any
from nornir.core.task import Result, Task
from nornir_netmiko.connections import CONNECTION_NAME


def netmiko_multiline(
task: Task,
commands: Sequence[Union[str, List[str]]],
use_timing: bool = False,
enable: bool = False,
**kwargs: Any
) -> Result:
"""
Execute Netmiko send_multiline method (or send_multiline_timing)
Arguments:
commands: List or list of lists (see Netmiko send_multiline)
use_timing: Set to True to switch to send_multiline_timing method.
enable: Set to True to force Netmiko .enable() call.
kwargs: Additional arguments to pass to send_multiline method.
Returns:
Result object with the following attributes set:
* result: String result showing you the output from commands
"""
net_connect = task.host.get_connection(CONNECTION_NAME, task.nornir.config)
if enable:
net_connect.enable()
if use_timing:
result = net_connect.send_multiline_timing(commands, **kwargs)
else:
result = net_connect.send_multiline(commands, **kwargs)
return Result(host=task.host, result=result)
Loading

0 comments on commit 910cf92

Please sign in to comment.