Config Context for hardware devices interferes with virtual machines in confusing way #5578

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

Originally created by @mburggraf on GitHub (Oct 28, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.0.8

Python version

3.8

Steps to Reproduce

The following issue was completely reproduced in the netbox test environment (https://demo.netbox.dev/).

  1. Create a config context with some settings and assign it to any Site.
    For example: { "category": { "value 1": 10, "value 2": 20 } }
  2. Look for a virtual machine, with a cluster matching the assigned Site and verify, that the config context gets correctly applied.
  3. Create an additional config context, with overlapping contents and apply it to any device type only.
    For example: { "category": { "value 2": 200, "value 3": 300, "value 4": 400 } }
  4. Go back to the virtual machine you checked before and see, how the Rendered config context shows data which doesn't match the source contents.

Expected Behavior

The rendered config context should only contain the combined source contents, which match the given context. Especially a context, which is set to apply to a specific device type only should never appear in a virtual machine.

Observed Behavior

Values from the device type config context gets mixed into the rendered context, without even appearing in source context, and without matching:
grafik


There is an additional thing; I don't know if it is the same Bug, or another issue.

What happens: The export, which is called without /api/ shows the values how they should be. When calling it via the /api/-Link, the same problem happens as above.
I would expect the export to always be the same, regardless of the way it is called.

Originally created by @mburggraf on GitHub (Oct 28, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.0.8 ### Python version 3.8 ### Steps to Reproduce The following issue was completely reproduced in the netbox test environment (https://demo.netbox.dev/). 1. Create a config context with some settings and assign it to any Site. For example: `{ "category": { "value 1": 10, "value 2": 20 } }` 2. Look for a virtual machine, with a cluster matching the assigned Site and verify, that the config context gets correctly applied. 3. Create an additional config context, with overlapping contents and apply it to any device type only. For example: `{ "category": { "value 2": 200, "value 3": 300, "value 4": 400 } }` 4. Go back to the virtual machine you checked before and see, how the Rendered config context shows data which doesn't match the source contents. ### Expected Behavior The rendered config context should only contain the combined source contents, which match the given context. Especially a context, which is set to apply to a specific _device type_ only should never appear in a _virtual machine_. ### Observed Behavior Values from the device type config context gets mixed into the rendered context, without even appearing in source context, and without matching: ![grafik](https://user-images.githubusercontent.com/15525831/139313334-39ba0aeb-5ce5-4776-a6a1-9d310ae8f530.png) --- There is an additional thing; I don't know if it is the same Bug, or another issue. - Create an plain-text export template, which makes use of above config context: - `{% for vm in queryset %}` `NAME {{ vm.name }}` `{% set data = vm.get_config_context().get("category",{}) %}` `{% for key, value in data.items() %}` `{{ key }} {{ value }}` `{% endfor %}` `{% endfor %}` - Call this export (i.e.: https://demo.netbox.dev/virtualization/virtual-machines/?export=test ) - Call the export via api (i.e.: https://demo.netbox.dev/api/virtualization/virtual-machines/?export=test ) - Compare the two exports What happens: The export, which is called without /api/ shows the values how they should be. When calling it via the /api/-Link, the same problem happens as above. I would expect the export to always be the same, regardless of the way it is called.
adam added the type: bugstatus: accepted labels 2025-12-29 19:29:43 +01:00
adam closed this issue 2025-12-29 19:29:43 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5578