-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from ktbyers/develop
Release 0.2.0
- Loading branch information
Showing
6 changed files
with
252 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.