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.36k stars 228 forks source link

Add config-context option to Netbox Inventory Plugin #300

Closed FragmentedPacket closed 4 years ago

FragmentedPacket commented 5 years ago

There was a new feature added in Netbox v2.4 called Config context which allows additional variables to be tied to devices. This does require an additional call per device to obtain the config_context for each device due to requiring the device ID.

The API endpoint is found at http://netbox-url/api/dcim/devices/<id>/

I'm just looking for a quick discussion on where we should set the option and the default value.

Should we add it as a positional argument or just have it part of the **kwargs? And I'm thinking the default value should be set to false if we go the positional argument method as it can be a massive speed sink if there are thousands of devices within someone's Netbox inventory (we're seeing this behavior on the Ansible Netbox dynamic inventory).

My vote would be on the positional argument method so that it's clearly documented as an option, but wanted to get some feedback before I submit the PR to implement this.

dbarrosop commented 5 years ago

Yes, I think your proposal makes sense.

wvandeun commented 5 years ago

Not sure if you have put any effort into this already, but it looks like from v2.6 (now in beta) config-context will be included by default for all API results. A parameter is added to exclude config-context if you don't want it (or if the query becomes to slow).

https://github.com/digitalocean/netbox/commit/bd573fd5cf3273456d1ac5faabbde85509cb8387

FragmentedPacket commented 5 years ago

@wvandeun Thanks for that! That's why there hasn't been a PR opened. I will have to add the option disable it within the inventory which I should be able to get to soon as it may cause performance issues moving forward with fetching large inventories.

clay584 commented 4 years ago

@FragmentedPacket there is another work stream occurring with @wvandeun and myself. We are developing a version 2 of the netbox plugin that will have this feature, netbox secrets, and more.

https://github.com/nornir-automation/nornir/pull/479

Hopefully we can release soon and make the next nornir release.

FragmentedPacket commented 4 years ago

Sounds good! I will go ahead and close this issue since it's being taken care of in the PR you mentioned. Thanks for the heads up!