netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Try NetBox Cloud free: https://netboxlabs.com/free-netbox-cloud/
http://netboxlabs.com/oss/netbox/
Apache License 2.0
15.77k stars 2.54k forks source link

Add ability to search for devices/VMs which do not have a given tag #7591

Closed BarbarossaTM closed 2 years ago

BarbarossaTM commented 2 years ago

NetBox version

v3.0.3

Feature type

Change to existing functionality

Proposed functionality

It would be nice to be able to filter for devices or VMs which do not have a given tag applied.

Use case

When migrating parts of the infrastructure to new versions or new tooling we currently use tags to indicate that a device or a VM should get the "new stuff" which works fine. Our automation consumes the tags applied to the device/VM and does the right thing. To see which devices/VMs have to be migrated it would be nice if we could filter for devices/VMs which do not have the tag applied yet.

Database changes

None.

External dependencies

None.

tyler-8 commented 2 years ago

You can do this today on just about any endpoint with a tag filter - there's also the tag__n filter.

If you only want objects that do not contain tag-x you would add tag__n=tag-x to your query parameters. This works in both the GUI and API - although the negation filter isn't visible in the GUI, the URL query does render the proper results.

BarbarossaTM commented 2 years ago

Thanks @tyler-8, that's a nice workaround :)

jeremystretch commented 2 years ago

@BarbarossaTM does the solution @tyler-8 provided meet your needs for this FR?

This works in both the GUI and API - although the negation filter isn't visible in the GUI

Tangential, but I'd like to improve the UI filter forms to support this, somehow. I've opened #7604 to propose an idea.

BarbarossaTM commented 2 years ago

Yes, adding ?tag__n=xxx to the URL works fine for now and provides me the result I want, so I can work. Would be cool to be able to add this filter via the GUI, so if that's the intention for #7604 that would be great :)