Skip to content
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

Add option to filter 'devices' by 'region' #2388

Closed
bdlamprecht opened this issue Aug 22, 2018 · 3 comments
Closed

Add option to filter 'devices' by 'region' #2388

bdlamprecht opened this issue Aug 22, 2018 · 3 comments
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application

Comments

@bdlamprecht
Copy link
Contributor

bdlamprecht commented Aug 22, 2018

Environment

  • Python version: 3.6
  • NetBox version: v2.4.3

Proposed Functionality

Currently, the WebUI does not allow to you filter devices by regions, only by sites.
As mentioned by @john in the NetworkToCode Slack:

You can achieve your desired result in two steps. Just query for all sites in your region, then query for devices in any of those sites.
/api/dcim/devices/?site_id=3&site_id=4&site_id=5&...

This in fact DOES work for someone who is familiar with coding and use of the API, however, for someone who does not (read: management), this is less than ideal.

My request is, if it would be possible to implement that filter in the WebUI?
As @john mentioned also:

Regions only have to do with Sites. The only reason you see Region in the Device form is because it is used to filter the list of Sites. The Region value is not attached to the device.

That being said, in the nbshell you can do something like Device.objects.filter(site__region=region)
In that case you are using Site as a through model to get to Region.

The reason you can't filter on Region in the actual app is because our filters are only setup with fields that are on the model.

I'm not a developer by trade (learning as I have the time 😄 ), so if it is impossible with the way NetBox currently works with primary model and the related fields, then so be it. However, that fact that you can do it in the nbshell makes me wonder.

Use Case

Implementing this feature would allow greater flexibility in the WebUI to search for, as an example, all device_types of Cisco 3850-12S in the region Austin, TX.

Database Changes

Most likely, none.

External Dependencies

None.

@bdlamprecht bdlamprecht changed the title Add option to filter Add option to filter 'devices' by 'region' Aug 22, 2018
@bdlamprecht
Copy link
Contributor Author

Has there been any discussion on this FR yet?
I continue to run into the need for this functionality but don't know if it is going to be implemented at all.

I suppose my question is this...
Do I and need to find another solution for it or does this have the potential for being implemented?

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application labels Nov 6, 2018
@jeremystretch
Copy link
Member

FYI the trick with this was matching on parent regions as well. For example, ?region=europe should match all devices assigned to a region within Europe as well as Europe itself.

@bdlamprecht
Copy link
Contributor Author

Awesome, thank you so much!

@lock lock bot locked as resolved and limited conversation to collaborators Jan 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

2 participants