forked from wsdoprado/ixforum17
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnornir4.py
32 lines (28 loc) · 1.04 KB
/
nornir4.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
Script: Get Interface - Nornir + Napalm + Filter + Netbox
Author: William Prado
Email: [email protected]
"""
from nornir import InitNornir
from nornir_napalm.plugins.tasks import napalm_get
from nornir_rich.functions import print_result
import os
nr = InitNornir(
runner={"plugin": "threaded", "options": {"num_workers": 20}},
inventory={
"plugin": "NetBoxInventory2",
"options": {
"nb_url": os.getenv("NETBOX_URL"),
"nb_token": os.getenv("NETBOX_TOKEN"),
"filter_parameters": {
"tenant": "production",
"role": "l2",
"region": "mg",
"status": "active",
"platform": "iosxr"},
"ssl_verify": False}
})
nr.inventory.defaults.username = os.getenv("USER")
nr.inventory.defaults.password = os.getenv("PASSWORD")
nr.inventory.defaults.port = os.getenv("SSH_PORT")
print_result(nr.run(task=napalm_get, getters=["get_interfaces"]), vars=["result", "name"])