Make the config template functionality available to plugins #8623

Closed
opened 2025-12-29 20:39:02 +01:00 by adam · 4 comments
Owner

Originally created by @peteeckel on GitHub (Sep 15, 2023).

NetBox version

v3.6.1

Feature type

New functionality

Proposed functionality

AFAIK currently the functionality of defining config templates only applies to Device and VirtualMachine objects. Its use in other models currently is not documented, hence not supported.

I suggest making that functionality available to plugins as well.

Use case

The NetBox DNS plugin provides a way to model DNS nameservers, zones and records within NetBox.

A possible use case is to create a configuration template that creates the configuration of a name server based on the zones that are assigned to it (resulting in a nameserver configuration file) and one that creates a zone file based on the records assigned to that zone using "render configuration". This would be highly useful in automation scenarios.

Generally, all plugins that refer to non-device or -vm entities that can be configured using data from NetBox could benefit from that functionality.

Retrieving the data via the API from an external tool is slower than the internal templating engine, using custom scripts for the purpose is possible, but quite cumbersome, not very user friendly to people not familiar with Python programming and not as elegant as using a custom template.

Database changes

Not sure, but none that I'm aware of. I had a look at the database schema and couldn't find anything in the extras_customtemplate tables that is hard-coded to dcim_device, dcim_devicerole, dcim_platformor virtualization_virtualmachine.

External dependencies

None.

Originally created by @peteeckel on GitHub (Sep 15, 2023). ### NetBox version v3.6.1 ### Feature type New functionality ### Proposed functionality AFAIK currently the functionality of defining config templates only applies to `Device` and `VirtualMachine` objects. Its use in other models currently is not documented, hence not supported. I suggest making that functionality available to plugins as well. ### Use case The NetBox DNS plugin provides a way to model DNS nameservers, zones and records within NetBox. A possible use case is to create a configuration template that creates the configuration of a name server based on the zones that are assigned to it (resulting in a nameserver configuration file) and one that creates a zone file based on the records assigned to that zone using "render configuration". This would be highly useful in automation scenarios. Generally, all plugins that refer to non-device or -vm entities that can be configured using data from NetBox could benefit from that functionality. Retrieving the data via the API from an external tool is slower than the internal templating engine, using custom scripts for the purpose is possible, but quite cumbersome, not very user friendly to people not familiar with Python programming and not as elegant as using a custom template. ### Database changes Not sure, but none that I'm aware of. I had a look at the database schema and couldn't find anything in the `extras_customtemplate` tables that is hard-coded to `dcim_device`, `dcim_devicerole`, `dcim_platform`or `virtualization_virtualmachine`. ### External dependencies None.
adam added the type: feature label 2025-12-29 20:39:02 +01:00
adam closed this issue 2025-12-29 20:39:03 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 15, 2023):

ConfigTemplate is just a model like many others in NetBox: It's documented and there's nothing I can think of that precludes a plugin from utilizing it. What specific change(s) are you looking for?

@jeremystretch commented on GitHub (Sep 15, 2023): ConfigTemplate is just a model like many others in NetBox: It's documented and there's nothing I can think of that precludes a plugin from utilizing it. What specific change(s) are you looking for?
Author
Owner

@peteeckel commented on GitHub (Sep 15, 2023):

Potentially a mis-interpretation on my side, but

Plugin authors are strongly encouraged to develop plugins using only the officially supported components discussed here and those provided by the underlying Django framework to avoid breaking changes in future releases.

and

Please note that only the classes which appear in this documentation are currently supported.

seemed to me to preclude the use of other classes and would at least require some additional documentation - reading it again and your comment here I come to the conclusion that ConfigTemplate is not in scope of these warnings and can be used without concerns, right? That's good news.

@peteeckel commented on GitHub (Sep 15, 2023): Potentially a mis-interpretation on my side, but > Plugin authors are strongly encouraged to develop plugins using only the officially supported components discussed here and those provided by the underlying Django framework to avoid breaking changes in future releases. and > Please note that only the classes which appear in this documentation are currently supported. seemed to me to preclude the use of other classes and would at least require some additional documentation - reading it again and your comment here I come to the conclusion that `ConfigTemplate` is not in scope of these warnings and can be used without concerns, right? That's good news.
Author
Owner

@jeremystretch commented on GitHub (Sep 15, 2023):

The Python classes we document as "supported" for plugins are intended to be subclassed for a plugin's own purposes. Models, however, can be referenced freely. Consider the site or device model, for instance: You can easily create a ForeignKey from a custom plugin model to one of these. ConfigTemplate isn't any different in this respect, except perhaps that includes additional functionality pertaining to config rendering (i.e. the render() method).

Hope that helps!

@jeremystretch commented on GitHub (Sep 15, 2023): The Python classes we document as "supported" for plugins are intended to be subclassed for a plugin's own purposes. Models, however, can be referenced freely. Consider the site or device model, for instance: You can easily create a ForeignKey from a custom plugin model to one of these. ConfigTemplate isn't any different in this respect, except perhaps that includes additional functionality pertaining to config rendering (i.e. the `render()` method). Hope that helps!
Author
Owner

@peteeckel commented on GitHub (Sep 15, 2023):

Hope that helps!

It does. Thanks a lot, I'll go and use it as soon as I can!

@peteeckel commented on GitHub (Sep 15, 2023): > Hope that helps! It does. Thanks a lot, I'll go and use it as soon as I can!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8623