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.4k stars 237 forks source link

Feature Request: Inventory Defaults Loading #723

Open jvanderaa opened 3 years ago

jvanderaa commented 3 years ago

It looks like there is some common code being implemented on Nornir NetBox and Nornir Ansible inventories. Which is something that will also be implemented into the Nornir Nautobot inventory as well. This should likely become a method that is common in the Nornir library.

jvanderaa commented 3 years ago

I can submit the request in if this would be good to go.

dbarrosop commented 3 years ago

Which code are you referring to? Note that how to load inventory defaults is specific to the inventory plugin, we don't expect plugins to implement a specific mechanism. However, if people are trying to replicate what the SimpleInventory does, I am ok cleaning that driver and turning it into a public API that can be leveraged by other drivers.

jvanderaa commented 3 years ago

I would look at having this as a method within Nornir inventory - https://github.com/wvandeun/nornir_netbox/blob/develop/nornir_netbox/plugins/inventory/netbox.py#L39-L48, it appears there on the NetBox inventory and again on the Ansible inventory - https://github.com/carlmontanari/nornir_ansible/blob/master/nornir_ansible/plugins/inventory/ansible.py#L456-L472

dbarrosop commented 3 years ago

Ok, makes sense, we could have a from_dict static method on all of the public facing objects to do this magic.