-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optionally include configuration context when retrieving by name. #2350
Comments
So, a little background on this. Currently, config context is rendered only when retrieving a single device (or VM). This is because retrieving all of the applicable ConfigContext objects and rendering a context for the specific device is a fairly expensive operation, and doing so for an entire list of devices would add a huge amount of overhead. The REST API is structured such that retrieving any particular object must be done using its integer primary key (e.g. So, I see two options for implementing this:
|
I'm not sure if it is easier, but a third option may be to expose a route which only returns the configuration context for the given device or VM. This would eliminate the database operations that occur when retrieving the entire host record. |
Maybe adding a seperate route (or an argument to the existing routes) could make a 'rendered-config-context' available on other objects as well. |
IMO this introduces unpredictable behavior. Simplest case against is that if anyone adds a second device with (partially) the same name (e.g. |
I think option one is the way to go, but what about also including a query parameter on the list view (e.g. This could also be extended to the detail view in the form of |
The client could simply limit the number of results he would like to receive to a low number, e.g. 5, for these specific requests. Thereby the client is in full control of the 'additional cost'. |
The cleanest way to approach this might be to check for an
We should be able to hotwire the view to strip these fields before the serializer is rendered. This won't have any effect on the actual queryset used for the view, but it should help in cases like this, where The caveat with the approach (if proven feasible) would be that |
Jeremy's solution has been implemented in the develop-2.6 branch. |
Environment
Proposed Functionality
When using the API to retrieve a device or virtual machine by name, NetBox should support an optional query parameter to indicate that the configuration context will be included. This eliminates the double GET required when only the name is known, but not the ID.
Use Case
The Salt external pillar, as well as any other configuration management system that only has the hostname as a starting point.
Database Changes
None.
External Dependencies
None.
The text was updated successfully, but these errors were encountered: