Allow ConfigContext mapping to DeviceType #4176

Closed
opened 2025-12-29 18:33:38 +01:00 by adam · 4 comments
Owner

Originally created by @vista- on GitHub (Oct 8, 2020).

Environment

  • Python version: 3.8.2
  • NetBox version: 2.9.4 / develop

Proposed Functionality

Config Contexts can be currently applied to specific Platforms (e.g. IOS/Junos), however, they currently do not allow between the distinction of different device models/types that use the same NOS.

It'd be nice if it was possible to apply configuration contexts to devices in the same role with the differences between models in mind.

Use Case

To give you an idea of what device-specific configuration contexts could be used for: devices of the same role might have a single RE or dual REs, might be old equipment that's not able to use specific features, or simply might have a quirk or two that should needs a different handling.

This feature would be the most useful for those (including yours truly) whose configuration management templates are full of {% if device.model == 'something_or_other' %} conditionals (and for the tidier types as well, who have group variables for specific types :)).

Database Changes

A new field (device_types) needs to be added to the ConfigContext model.

External Dependencies

None.

Additional note

There is an implementation of this addition in my fork's 'config-context-device-type' branch. The addition of the device_type field was fairly straightforward and I'd expect more seasoned NetBox developers to implement it similarly. :)

Originally created by @vista- on GitHub (Oct 8, 2020). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for proposing specific new features or enhancements. If you have a general idea or question, please post to our mailing list instead of opening an issue: https://groups.google.com/g/netbox-discuss NOTE: Due to an excessive backlog of feature requests, we are not currently accepting any proposals which significantly extend NetBox's feature scope. Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.8.2 * NetBox version: 2.9.4 / develop <!-- Describe in detail the new functionality you are proposing. Include any specific changes to work flows, data models, or the user interface. --> ### Proposed Functionality Config Contexts can be currently applied to specific Platforms (e.g. IOS/Junos), however, they currently do not allow between the distinction of different device models/types that use the same NOS. It'd be nice if it was possible to apply configuration contexts to devices in the same role with the differences between models in mind. <!-- Convey an example use case for your proposed feature. Write from the perspective of a NetBox user who would benefit from the proposed functionality and describe how. ---> ### Use Case To give you an idea of what device-specific configuration contexts could be used for: devices of the same role might have a single RE or dual REs, might be old equipment that's not able to use specific features, or simply might have a quirk or two that should needs a different handling. This feature would be the most useful for those (including yours truly) whose configuration management templates are full of `{% if device.model == 'something_or_other' %}` conditionals (and for the tidier types as well, who have group variables for specific types :)). <!-- Note any changes to the database schema necessary to support the new feature. For example, does the proposal require adding a new model or field? (Not all new features require database changes.) ---> ### Database Changes A new field (device_types) needs to be added to the ConfigContext model. <!-- List any new dependencies on external libraries or services that this new feature would introduce. For example, does the proposal require the installation of a new Python package? (Not all new features introduce new dependencies.) --> ### External Dependencies None. ### Additional note There is an implementation of this addition in [my fork's 'config-context-device-type' branch](https://github.com/vista-/netbox/tree/config-context-device-type). The addition of the device_type field was fairly straightforward and I'd expect more seasoned NetBox developers to implement it similarly. :)
adam added the status: duplicate label 2025-12-29 18:33:38 +01:00
adam closed this issue 2025-12-29 18:33:38 +01:00
Author
Owner

@jeremystretch commented on GitHub (Oct 8, 2020):

Thank you for submitting this issue, however it appears that this topic has already been raised. Please see issue #3305 for further discussion.

@jeremystretch commented on GitHub (Oct 8, 2020): Thank you for submitting this issue, however it appears that this topic has already been raised. Please see issue #3305 for further discussion.
Author
Owner

@vista- commented on GitHub (Oct 8, 2020):

I'd like to digress on that config contexts and physical hardware have no relation; NetBox is frequently used as an inventory / source of truth for configuration management of network devices, and it seems to me that the main use of configuration contexts is to automate configuration generation.

Sadly, we don't live in an ideal world where each device acts the same way, and might require some additional quirks to properly configure. I'd love to be able to store toggles / additional configuration to work with the limitations (or additional capabilities) of different device types in my singular source of truth.

In my eyes, being able to distinguish between device types from a configuration perspective via NetBox would be useful, and would make me less dependent on non-NetBox-sourced configuration toggles, and given that my goal is to make NetBox the source of truth in my network, it'd enable me (and not just me, I figure) to work towards that goal.

@vista- commented on GitHub (Oct 8, 2020): I'd like to digress on that config contexts and physical hardware have no relation; NetBox is frequently used as an inventory / source of truth for configuration management of network devices, and it seems to me that the main use of configuration contexts is to automate configuration generation. Sadly, we don't live in an ideal world where each device acts the same way, and might require some additional quirks to properly configure. I'd love to be able to store toggles / additional configuration to work with the limitations (or additional capabilities) of different device types in my singular source of truth. In my eyes, being able to distinguish between device types from a configuration perspective via NetBox would be useful, and would make me less dependent on non-NetBox-sourced configuration toggles, and given that my goal is to make NetBox _the_ source of truth in my network, it'd enable me (and not just me, I figure) to work towards that goal.
Author
Owner

@jeremystretch commented on GitHub (Oct 8, 2020):

This wouldn't be as useful as you're assuming.

devices of the same role might have a single RE or dual REs

Plenty of devices of the same model may have single or dual REs. This cannot be inferred from the device model.

might be old equipment that's not able to use specific features

Sounds like a good use for platform assignment.

or simply might have a quirk or two that should needs a different handling

Tags work wonderfully for addressing such corner cases.

@jeremystretch commented on GitHub (Oct 8, 2020): This wouldn't be as useful as you're assuming. > devices of the same role might have a single RE or dual REs Plenty of devices of the same model may have single or dual REs. This cannot be inferred from the device model. > might be old equipment that's not able to use specific features Sounds like a good use for platform assignment. > or simply might have a quirk or two that should needs a different handling Tags work wonderfully for addressing such corner cases.
Author
Owner

@jeremystretch commented on GitHub (Oct 14, 2020):

Looks like this is actually a duplicate of #4833.

@jeremystretch commented on GitHub (Oct 14, 2020): Looks like this is actually a duplicate of #4833.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4176