nornir-automation / nornir

Pluggable multi-threaded framework with inventory management to help operate collections of devices
https://nornir.readthedocs.io/
Apache License 2.0
1.38k stars 234 forks source link

use plugin after, how to write Cisco's enable password #827

Closed shijinlong12 closed 1 year ago

shijinlong12 commented 1 year ago

Sorry, my english is not good

my used nornir and relevant plugins version is image

I now encounter a problem,

As you can see, i used a nornir_table_inventory plugin to processed my host data. It works. image image

but when using napalm_get to get get_facts, appear Please ensure you pass the 'secret' argument to ConnectHandler. error image

the picture is detailed host data below, the plugin address is https://github.com/jiujing/nornir_table_inventory image

I checked all the questions containing this error, but no one is in the same situation as me so.

A better answer would be to ask the plug-in author, but the plug-in author has not replied to me, so let's ask

How should I fill in the secret

napalm_options: {'secret': 'my_secret_pass'} is Already tried

thank you very much

jiujing commented 1 year ago

nornir_table_inventory does support netmiko only. It does not support napalm. Maybe It will support in the future.I will upgrade some functions .

shijinlong12 commented 1 year ago

nornir_table_inventory does support netmiko only. It does not support napalm. Maybe It will support in the future.I will upgrade some functions .

OK的 家人 已经用ntpalm实现功能了 感谢

kashyappatel1988 commented 1 year ago

@jiujing You may already have it , I tested below code and it ran perfectly fine


def get_nornir_by_your_func(some_args=None, num_workers=100):
  """Use any way to get some data(such as sql or restful api), and transform them into form as follwing"""
  data = [{'name': 'test1', 'hostname': 'xxxx',
           'platform': 'junos', 'port': 22, 'username': 'xxxx',
           'password': 'xxx', 'city': 'bj'},
          ]
  runner = {
      "plugin": "threaded",
      "options": {
          "num_workers": num_workers,
      },
  }
  inventory = {
      "plugin": "FlatDataInventory",
      "options": {
          "data": data,
      },
  }
  nr = InitNornir(runner=runner, inventory=inventory)
  return nr

if __name__ == '__main__':

  nr = get_nornir_by_your_func()
  bj_devs = nr.filter(city='bj')
  r = bj_devs.run(task=napalm_get, getters=['facts'])
  print_result(r)
jiujing commented 1 year ago

@jiujing You may already have it , I tested below code and it ran perfectly fine


def get_nornir_by_your_func(some_args=None, num_workers=100):
  """Use any way to get some data(such as sql or restful api), and transform them into form as follwing"""
  data = [{'name': 'test1', 'hostname': 'xxxx',
           'platform': 'junos', 'port': 22, 'username': 'xxxx',
           'password': 'xxx', 'city': 'bj'},
          ]
  runner = {
      "plugin": "threaded",
      "options": {
          "num_workers": num_workers,
      },
  }
  inventory = {
      "plugin": "FlatDataInventory",
      "options": {
          "data": data,
      },
  }
  nr = InitNornir(runner=runner, inventory=inventory)
  return nr

if __name__ == '__main__':

  nr = get_nornir_by_your_func()
  bj_devs = nr.filter(city='bj')
  r = bj_devs.run(task=napalm_get, getters=['facts'])
  print_result(r)

It does work, if you do not want some connection options such as enable password . I did not support napalm especially. Some common arguments are same,such as username or password,So it does work ,when you use nornir_tableinventory with no sepical arguments.But some arguments are especial such as Connection Arguments Options. Nornir-table-inventory can parse data with "netmiko" prefix to netmiko connection options.

dbarrosop commented 1 year ago

I am closing this issue as I don't think this is related to nornir itself. Otherwise, feel free to reopen. If the issue is related to a plugin, it might be worth moving the conversation there.

Thanks!