Identify devices/VMs with local config context set #5260

Closed
opened 2025-12-29 19:26:01 +01:00 by adam · 3 comments
Owner

Originally created by @candlerb on GitHub (Aug 31, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v2.11.12

Feature type

Change to existing functionality

Proposed functionality

A way to identify those devices and VMs which have local config context data set. Options I can think of:

  1. In the device/VM listing, add "local_context_data" as a selectable column. However that's not great because it could contain a lot of data, although it could be truncated to the first N characters.
  2. In the device/VM listing, add a checkbox column which indicates if "local_context_data" is not empty, similar to "Assigned" on IP addresses; and/or
  3. In the device/VM listing, add a filter for devices with local_context_data set or not set

My preferred choice would be 3, or 2+3.

Use case

I needed to find which devices had local config context data set, and was unable to do so. They are not shown under /extras/config-contexts/ as those are only the configs which are assigned to groups.

I did wonder whether it would be possible to create a query by hand like /dcim/devices/?local_context_data__empty=0 but that doesn't appear to work, in either the GUI or the API.

In the end I was forced to do this via SQL queries:

select id,name,local_context_data from dcim_device where local_context_data is not null;
select id,name,local_context_data from virtualization_virtualmachine where local_context_data is not null;

(Aside: I also needed to remove the local_context_data from those devices, and ended up doing it one by one in the GUI as there's no option to do this on a selected subset using "Edit...". However this is a sufficiently rare requirement that this is reasonable)

Database changes

None

External dependencies

None

Originally created by @candlerb on GitHub (Aug 31, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v2.11.12 ### Feature type Change to existing functionality ### Proposed functionality A way to identify those devices and VMs which have local config context data set. Options I can think of: 1. In the device/VM listing, add "local_context_data" as a selectable column. However that's not great because it could contain a lot of data, although it could be truncated to the first N characters. 2. In the device/VM listing, add a checkbox column which indicates if "local_context_data" is not empty, similar to "Assigned" on IP addresses; and/or 3. In the device/VM listing, add a filter for devices with local_context_data set or not set My preferred choice would be 3, or 2+3. ### Use case I needed to find which devices had local config context data set, and was unable to do so. They are not shown under `/extras/config-contexts/` as those are only the configs which are assigned to groups. I did wonder whether it would be possible to create a query by hand like `/dcim/devices/?local_context_data__empty=0` but that doesn't appear to work, in either the GUI or the API. In the end I was forced to do this via SQL queries: ``` select id,name,local_context_data from dcim_device where local_context_data is not null; select id,name,local_context_data from virtualization_virtualmachine where local_context_data is not null; ``` (Aside: I also needed to remove the local_context_data from those devices, and ended up doing it one by one in the GUI as there's no option to do this on a selected subset using "Edit...". However this is a sufficiently rare requirement that this is reasonable) ### Database changes None ### External dependencies None
adam added the status: acceptedtype: feature labels 2025-12-29 19:26:01 +01:00
adam closed this issue 2025-12-29 19:26:01 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 16, 2021):

There's currently (as of v3.0.2) a filter for this in the device filter form; it may have been added as part of the UI overhaul in v3.0. However, it's missing for virtual machines.

@jeremystretch commented on GitHub (Sep 16, 2021): There's currently (as of v3.0.2) a filter for this in the device filter form; it may have been added as part of the UI overhaul in v3.0. However, it's missing for virtual machines.
Author
Owner

@candlerb commented on GitHub (Sep 16, 2021):

I just checked, and v2.11.12 did have the filter already (I hadn't spotted it). But it's still needed for VMs.

For reference, the query it adds is local_context_data={True|False}

@candlerb commented on GitHub (Sep 16, 2021): I just checked, and v2.11.12 did have the filter already (I hadn't spotted it). But it's still needed for VMs. For reference, the query it adds is `local_context_data={True|False}`
Author
Owner

@jeremystretch commented on GitHub (Sep 16, 2021):

Whoops, cited the wrong issue in the commit.

@jeremystretch commented on GitHub (Sep 16, 2021): Whoops, cited the wrong issue in the commit.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5260