简体   繁体   中英

Why got an unexpected keyword argument 'num_workers' with TypeError: __init__()?

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 the runner.options key. Add it to the options key and try again:

inventory:
  plugin: nornir.plugins.inventory.simple.SimpleInventory
  options:
    host_file: 'inventory/hosts.yaml'
    group_file: 'inventory/groups.yaml'
    defaults_file: 'inventory/defaults.yaml'
runner:
   plugin: threaded
   options:
     num_workers: 100

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM