from nornir import InitNornir
from nornir_napalm.plugins.tasks import napalm_get
from nornir_utils.plugins.functions import print_result
import json
def prettyPrintDictionary(dict):
print(json.dumps(dict, indent=2))
nr = InitNornir(config_file="/home/python/nornir-scripts/config.yaml")
print(nr.inventory.hosts)
prettyPrintDictionary(nr.inventory.get_hosts_dict())
# config.yaml
inventory:
plugin: SimpleInventory
options:
host_file: '/home/python/nornir-scripts/inventory/hosts.yaml'
group_file: '/home/python/nornir-scripts/inventory/groups.yaml'
defaults_file: '/home/python/nornir-scripts/inventory/defaults.yaml'
runner:
plugin: threaded
options:
num_workers: 100
Help please I cant understand how to initialize nornir I try to do it with guide and it also have mistakes. Now I have this mistake...
According to the documentation, the
num_workers
key should be inside therunner.options
key. Add it to theoptions
key and try again: