Closed shijinlong12 closed 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 .
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实现功能了 感谢
@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 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.
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!
Sorry, my english is not good
my used nornir and relevant plugins version is
I now encounter a problem,
As you can see, i used a nornir_table_inventory plugin to processed my host data. It works.
but when using napalm_get to get get_facts, appear Please ensure you pass the 'secret' argument to ConnectHandler. error
the picture is detailed host data below, the plugin address is https://github.com/jiujing/nornir_table_inventory
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