mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-11 21:10:29 +01:00
Introduce support for NetBox plugins #2744
Closed
opened 2025-12-29 18:21:38 +01:00 by adam
·
22 comments
No Branch/Tag Specified
main
update-changelog-comments-docs
feature-removal-issue-type
20911-dropdown
20239-plugin-menu-classes-mutable-state
21097-graphql-id-lookups
feature
fix_module_substitution
20923-dcim-templates
20044-elevation-stuck-lightmode
feature-ip-prefix-link
v4.5-beta1-release
20068-import-moduletype-attrs
20766-fix-german-translation-code-literals
20378-del-script
7604-filter-modifiers-v3
circuit-swap
12318-case-insensitive-uniqueness
20637-improve-device-q-filter
20660-script-load
19724-graphql
20614-update-ruff
14884-script
02496-max-page
19720-macaddress-interface-generic-relation
19408-circuit-terminations-export-templates
20203-openapi-check
fix-19669-api-image-download
7604-filter-modifiers
19275-fixes-interface-bulk-edit
fix-17794-get_field_value_return_list
11507-show-aggregate-and-rir-on-api
9583-add_column_specific_search_field_to_tables
v4.5.0
v4.4.10
v4.4.9
v4.5.0-beta1
v4.4.8
v4.4.7
v4.4.6
v4.4.5
v4.4.4
v4.4.3
v4.4.2
v4.4.1
v4.4.0
v4.3.7
v4.4.0-beta1
v4.3.6
v4.3.5
v4.3.4
v4.3.3
v4.3.2
v4.3.1
v4.3.0
v4.2.9
v4.3.0-beta2
v4.2.8
v4.3.0-beta1
v4.2.7
v4.2.6
v4.2.5
v4.2.4
v4.2.3
v4.2.2
v4.2.1
v4.2.0
v4.1.11
v4.1.10
v4.1.9
v4.1.8
v4.2-beta1
v4.1.7
v4.1.6
v4.1.5
v4.1.4
v4.1.3
v4.1.2
v4.1.1
v4.1.0
v4.0.11
v4.0.10
v4.0.9
v4.1-beta1
v4.0.8
v4.0.7
v4.0.6
v4.0.5
v4.0.3
v4.0.2
v4.0.1
v4.0.0
v3.7.8
v3.7.7
v4.0-beta2
v3.7.6
v3.7.5
v4.0-beta1
v3.7.4
v3.7.3
v3.7.2
v3.7.1
v3.7.0
v3.6.9
v3.6.8
v3.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.3
1.0.0
Labels
Clear labels
beta
breaking change
complexity: high
complexity: low
complexity: medium
needs milestone
netbox
pending closure
plugin candidate
pull-request
severity: high
severity: low
severity: medium
status: accepted
status: backlog
status: blocked
status: duplicate
status: needs owner
status: needs triage
status: revisions needed
status: under review
topic: GraphQL
topic: Internationalization
topic: OpenAPI
topic: UI/UX
topic: cabling
topic: event rules
topic: htmx navigation
topic: industrialization
topic: migrations
topic: plugins
topic: scripts
topic: templating
topic: testing
type: bug
type: deprecation
type: documentation
type: feature
type: housekeeping
type: translation
Mirrored from GitHub Pull Request
No Label
status: accepted
Milestone
No items
No Milestone
Projects
Clear projects
No project
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: starred/netbox#2744
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jeremystretch on GitHub (Jul 17, 2019).
Environment
Proposed Functionality
This feature request proposes modifying NetBox to support the addition of arbitrary third party plugin applications. The plugins can be installed and configured by end users to extend core NetBox functionality to better suit particular use cases. Plugins will allow users to introduce custom models, API endpoints, and additional business logic.
The plugin architecture is envisioned as follows:
/plugins/directory within the NetBox application root.PLUGINSparameter inconfiguration.py.configuration.py./plugins/<plugin>/and/api/plugins/<plugin/, respectively.Obviously, there's a lot to figure out here. @lampwins has already done some work in this area, but I wanted to capture it in a feature request to kick off the community discussion.
Use Case
This feature would introduce several benefits:
However, there are also certain drawbacks which should be considered:
Database Changes
This probably won't require any substantial database schema changes, though more exploration is needed to make a clear determination.
External Dependencies
Probably none
@lampwins commented on GitHub (Jul 17, 2019):
I am happy to see us looking down this path :)
In the name of transparency, here is the PoC I did for a plugin's architecture to which Jeremy alluded. It follows many of the points made above.
https://github.com/lampwins/netbox/tree/plugins
A couple of thoughts:
pip install <plugin>. From a deployment standpoint, it is much easier to deal with this way. As an aside, I would like to explore this same concept for reports at some point.Looking forward to the discussion.
@hellerve commented on GitHub (Jul 18, 2019):
I have another question, since this has been alluded to, but not yet completely formulated: will it be possible to hook into the existing UI (for instance, the navigation menu or homepage widgets) to make any new UI visible to the users?
@lampwins commented on GitHub (Jul 18, 2019):
@hellerve yes, the intent is really to set up plugins to look and feel like every other core app in NetBox by allowing them access to the same base classes, templates, etc, while maintaining a clear delineation that they are in fact 3rd party plugins. As stated above:
In my PoC this was done by optionally registering view names which were dynamically added to the nav menu dropdown under the heading "Plugins" but also grouped by plugin.
@hellerve commented on GitHub (Jul 18, 2019):
That sounds great. In my implementation of plugins I also had a bunch of other places where I could place hooks, but I guess that’s hard to make customizable/generalizable. If that’s at all interesting, though, I’d be happy to help draft and eventually implement something like that. I understand if that is out of scope, though!
@bbock commented on GitHub (Jul 19, 2019):
One use case which I would envision, but I'm not sure is covered by your proposal, would be data validation.
I would love to have a plugin that enforces my naming schema. It would need to be able to reject additions and mondifications of core elements if they do not match. Currently, I'm using a report to find invalid entries, but this is fixing after-the-fact, while I'd love to block inconsistent data in the fist place.
@hellerve commented on GitHub (Jul 22, 2019):
Another question: will plugins be able to introduce middlewares? This might be an interesting feature for a variety of use cases (we’re currently using a custom middleware for change management, for instance). My version of the plugin system (https://github.com/hellerve/netbox/tree/feat/plugin) was able to support this (simply by exposing a list that gets appended to
MIDDLEWARESinsettings.py, so not a huge liability on code).It is also a security concern, however, but I think part of the threat model of a plugin is "it can execute arbitrary code anyway", so it should be trusted; feel free to disagree with me on this!
@LukeDRussell commented on GitHub (Jul 28, 2019):
Glad to see this being discussed openly, Netbox has grown so much that it would be difficult to properly support all use cases.
I'm hoping these plugins would be able to modify data schemes, or at least add tables. Reference our lengthy debate about the definition and implementation of tenancy https://github.com/netbox-community/netbox/issues/2273.
We've implemented this internally as a Django "overlay" that replaces the "tenant" object with another object that allows many to many. It would be outstanding to turn this into a plugin that we could share with others, and I imagine it would reduce our integration testing with ongoing Netbox releases.
@The-Sec commented on GitHub (Aug 2, 2019):
Let me open with that i love Netbox. I think its a great tool! But i disagree with the feature request as this will no doubly split the Netbox user base into smaller groups. If people have custom use cases and they develop a plugin for it, they will drop support as soon as it launches.
People will create how to's to create fancy dashboards with and plugin they can find and go beyond the goal of what Netbox is. Its a "Source of Truth" not to draw fancy things or make them cool. Its a database we should tried it like one. I think it would make development even slower as people will not read how to develop a plugin but will just email and ask how can i do X to create Y for this special use case i have.
If someone really want to add i see no problem in them sending an PR and if and only if it up to par then approve.
@LukeDRussell commented on GitHub (Aug 3, 2019):
The only problem is that Jeremy runs a pretty tight project.
There’s always going to be things that are important to my organisation, but not important to yours or Jeremy’s. There are three options I can see - a public or private fork, custom additions or plugins.
Plugins are the most likely to keep the community on a shared base, so we don’t have to fork when we must have certain features that are inappropriate or not welcome in the core of netbox.
Another use case is to move current core features into supported plugins (tenants and secrets come to mind) to keep the core lean and supportable.
@hellerve commented on GitHub (Oct 11, 2019):
Hey, I see that this issue isn’t in
acceptedstate yet? What is missing? Can the community do anything to move this forward?A roadmap would be extremely helpful as well; I understand that this might be a little much to ask, but if you have anything at hand, that’d be great!
@TheRealBecks commented on GitHub (Nov 15, 2019):
@jeremystretch @lampwins Referencing to @hellerve, what is needed here? Do we need to implement #3408 first?
@jeremystretch commented on GitHub (Nov 15, 2019):
First we need to release v2.7, and then probably v2.8, and then we can start looking into plugins. There's an enormous amount of existing backlog that needs to be addressed. Before we introduce a ton more.
@hellerve commented on GitHub (Nov 15, 2019):
That’s more than understandable. I know that people probably know this, but you can see which issues need to be fixed/help for these versions here!
@steffann commented on GitHub (Dec 20, 2019):
I have used the standard setuptools pkg_resources entry-points for plugins in the past, and that can work really well. Installing plugins using setuptools also helps with dependency management (in case plugins have their own dependencies) etc. One limitation of the proposed implementation is that only the plugin is added to
INSTALLED_APPS. Plugins that depend on other Django apps would be hard to support.There are of course many ways to support plugins, but I personally prefer to use existing solutions like this that are already part of very common libraries.
@steffann commented on GitHub (Dec 30, 2019):
After experimenting a bit I found that the extra complexity of
pkg_resourceswasn't worth it.My current experiment is at https://github.com/steffann/netbox/tree/3351-plugins, with an example plugin at https://github.com/steffann/netbox-example-plugin. It currently supports adding extra INSTALLED_APPS, adding URLs under
/plugins/<plugin-name>/, adding menu items to existing menus and adding new menus, and adding extra panels to the homepage, ip-address page, device page, and all other pages where adding extra panels might make sense.This is meant as a start for further discussion, hopefully leading to the status of this issue being changed from gathering feedback to accepted :)
@steffann commented on GitHub (Dec 30, 2019):
That was quick :)
@lampwins commented on GitHub (Dec 30, 2019):
Yeah, my PoC was also basically just what you implemented.
It is extremely important we get the API for plugins correct the first time. This sort of thing has the potential to generate a ton of development noise for us once in the wild so we need to do it justice. To that end, simplicity and elegance in the API are what I am striving for. Django already has an entrenched methodology and ecosystem for this type of architecture and we would be wise to stick to it closely.
Things that are top of mind for me are avoiding the potential for allowing namespace collisions both within the core and within two plugins, data model augmentation vs manipulation, and cleaning up many of our pseudo-private APIs to ready them for more public use (things like signals based events, custom fields, RQ tasks, caching, etc).
Lots to think about and design, but we are thinking about it, don't worry ;)
@steffann commented on GitHub (Dec 30, 2019):
I did look at your PoC, and used many ideas from that. Some deviations:
PLUGINSandPLUGIN_CONFIGdefault_app_config, https://docs.djangoproject.com/en/2.2/ref/applications/#configuring-applications says "New applications should avoid default_app_config".__init__.pyfrom the package instead for dependencies, version checks etc.packagesfor pip-style compatibility checks. Checkingmax_versionwas a bit awkward usingLooseVersionbecause you can't so something like "compatible with2.6.*". You'd have to setmax_versionto something like2.6.999. Withpackagesthe version spec can be~= 2.6.9to allow>= 2.6.9, < 2.7.APIRootView.I have alternated multiple times between
__init__.py, a separatePluginbase class andAppConfigproperties:AppConfigwould be nice (ignoring thedefault_app_configdeprecation), but only class properties are usable as otherwise we'd be creating multiple instances of the class in multiple places.Pluginclass is possible, but since it's properties already needed insettings.pyit would require instantiating it there, and that's not really the right place to do that. It also invites adding complexity. And where to store the instantiated object? I tried storing it in the plugin settings, but that also feels weird. In the end I decided instantiating an object insettings.pywas wrong.__init__.pywhich can be easily imported and used.I should re-add the required and default settings though. Those are a good idea!
@steffann commented on GitHub (Dec 30, 2019):
I added a whole bunch of documentation at https://github.com/steffann/netbox/tree/3351-plugins/docs/plugins, as reading and writing documentation from the user's perspective usually gives a good view of where the missing/ugly/etc bits are :)
@steffann commented on GitHub (Mar 26, 2020):
Development on this is looking great! One thing I realised when writing some code to export interface configurations to Ansible YAML was that it would be great for plugins to also be able to add extra buttons on de Device page under the interface list:
And I'm sure someone could find a good use for similar functionality for pages like
/ipam/ip-addresses/. Is this something that you'd be interested in? Willing to propose a patch.@jeremystretch commented on GitHub (Mar 26, 2020):
We are not taking any requests for any extensions to the functionality at this point. I understand that people get excited about this sort of thing, but the plugin feature hasn't even been merged into
develop-2.8yet, let alone released. For the sake of productive development, and my own sanity, we are not taking any feedback on the plugin system at this time.@jeremystretch commented on GitHub (Mar 27, 2020):
Marking this as closed since
3351-pluginshas been merged. 🎉