Network asyncio command runner using Scrapli
Project description
Netrunner
An async network command runner built using Scrapli. You provide and inventory and tasks (functions), and the runner does the rest.
Currently only working with Cisco IOS and NXOS devices, but I will be adding others.
Installation
pip install netrunner
Basic Usage
Here is a basic example. More examples can be found in the examples folder.
import asyncio
from netrunner import Runner
hosts = [
{"hostname": "SW1021", "ip": "10.0.0.9", "platform": "ios"},
{"hostname": "SW1031", "ip": "10.0.0.10", "platform": "ios"},
{"hostname": "NX1001", "ip": "10.0.0.11", "platform": "nxos"},
{"hostname": "NX2001", "ip": "10.0.0.12", "platform": "nxos"},
]
# Here is a task. The first parameter is the host and must be provided.
# Other parameters can also be passed into the tasks/functions.
# Please see the examples in the example folder.
async def first_task(host):
# Commands must be passed in via a list. By default the output is parsed using
# Genie, but parse can be set to False if raw output is required
result = await host.send_command(["show version", "show vlan"])
return result
async def main():
# Hosts can either be passed here to be used globally, or can be passed per task
runner = Runner(username="test_user", password="T3stpass", hosts=hosts)
result = await runner.run(name="Check Version and Vlan", task=first_task)
print(result.run_time)
print(result.result["show version"])
print(result.result["show vlan"])
print(result.failed)
if __name__ == "__main__":
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file netrunner-0.1.6.tar.gz.
File metadata
- Download URL: netrunner-0.1.6.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.8 CPython/3.8.10 Linux/5.4.0-84-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
832c6e4775da2d969c780c18455048db6956ad1d056f47d1afe70657e95bd22b
|
|
| MD5 |
be65e39a594b5ea67195f2c2cceaa6b0
|
|
| BLAKE2b-256 |
113d404afb680a955d4ac09110dcf38705c25f5f9bb0be34fdb0274aed5e529f
|
File details
Details for the file netrunner-0.1.6-py3-none-any.whl.
File metadata
- Download URL: netrunner-0.1.6-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.8 CPython/3.8.10 Linux/5.4.0-84-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8ca3d9cea54520785d6b584d1c912ac84c12fe88b33dcba31a6be23d41133b7
|
|
| MD5 |
c6b0716dc259030efea62fb8258e1c8b
|
|
| BLAKE2b-256 |
cb2b0739545a3555544090dc9c199b21778e1ea5815c47eddf53d136f5b93338
|