Automate the registration of plugins #4500

Closed
opened 2025-12-29 18:36:46 +01:00 by adam · 5 comments
Owner

Originally created by @pvinci on GitHub (Jan 26, 2021).

Environment

  • Python version: 3.9
  • NetBox version: 2.10.3

Proposed Functionality

Currently, one needs to install a plugin via pip, edit the settings file and restart django.
I propose netbox support an entrypoint such as 'netbox.plugins' that external plugins can register into, eliminating the second step.
If a the entry netbox.plugins is configured as an entry in PLUGINS in the settings file, netbox will process plugins that have registered to the entrypoint in addition to any static entries.

If the netbox.plugins entry is not present, the current functionality is retained.

Use Case

  1. Integration testing of plugins is simplified if the settings file does not need to be edited.
  2. Deployment within docker is simplified.
  3. A support organization could provide a verified requirements.txt file to deploy a supported configuration.

Database Changes

None.

External Dependencies

There are none to netbox. The necessary functionality is already part of setuptools. Plugins already require setuptools. Plugins wishing to take advantage of the feature would need modify setup.py of the plugin to specify the entry point for the plugin.

Originally created by @pvinci on GitHub (Jan 26, 2021). <!-- 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 start a discussion instead: https://github.com/netbox-community/netbox/discussions 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.9 * NetBox version: 2.10.3 <!-- Describe in detail the new functionality you are proposing. Include any specific changes to work flows, data models, or the user interface. --> ### Proposed Functionality Currently, one needs to install a plugin via pip, edit the settings file and restart django. I propose netbox support an entrypoint such as 'netbox.plugins' that external plugins can register into, eliminating the second step. If a the entry `netbox.plugins` is configured as an entry in `PLUGINS` in the settings file, netbox will process plugins that have registered to the entrypoint in addition to any static entries. If the `netbox.plugins` entry is not present, the current functionality is retained. <!-- 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 1. Integration testing of plugins is simplified if the settings file does not need to be edited. 2. Deployment within docker is simplified. 3. A support organization could provide a verified requirements.txt file to deploy a supported configuration. <!-- 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 None. <!-- 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 There are none to netbox. The necessary functionality is already part of setuptools. Plugins already require setuptools. Plugins wishing to take advantage of the feature would need modify setup.py of the plugin to specify the entry point for the plugin.
adam added the type: featurestatus: under review labels 2025-12-29 18:36:46 +01:00
adam closed this issue 2025-12-29 18:36:47 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jan 26, 2021):

Please specify your NetBox version.

@jeremystretch commented on GitHub (Jan 26, 2021): Please specify your NetBox version.
Author
Owner

@jeremystretch commented on GitHub (Jan 26, 2021):

We considered this early on when first developing plugin support, but there are a number of reasons we opted not to pursue it:

  1. This enables anyone with access to the virtual environment to inject a new plugin without any safeguards or record within NetBox.
  2. This does not allow an administrator to easily enable/disable a plugin.
  3. You would still need to update configuration.py to set any configuration parameters anyway.

I understand the benefit it would be for automate for automated testing and Docker, however those are not our primary interests in developing NetBox. As far as the average user is concerned, I believe this would do more harm than good.

@jeremystretch commented on GitHub (Jan 26, 2021): We considered this early on when first developing plugin support, but there are a number of reasons we opted not to pursue it: 1. This enables anyone with access to the virtual environment to inject a new plugin without any safeguards or record within NetBox. 2. This does not allow an administrator to easily enable/disable a plugin. 3. You would still need to update `configuration.py` to set any configuration parameters anyway. I understand the benefit it would be for automate for automated testing and Docker, however those are not our primary interests in developing NetBox. As far as the average user is concerned, I believe this would do more harm than good.
Author
Owner

@pvinci commented on GitHub (Jan 26, 2021):

Thank you.

I considered those issues as well.
For points 1 and 2, my suggestion was that the functionality be enabled only if PLUGINS contains 'netbox.plugins' as in:

PLUGINS = [
    "netbox_animal_sounds",
    "netbox.plugins", 
]

As for point 3, I thought that the plugin already supports that ability via the plugin config, which could be specified in the plugin's setup.py

    # Default configuration parameters
    default_settings = {}

    # Mandatory configuration parameters
    required_settings = []
@pvinci commented on GitHub (Jan 26, 2021): Thank you. I considered those issues as well. For points 1 and 2, my suggestion was that the functionality be enabled only if `PLUGINS` contains 'netbox.plugins' as in: ``` PLUGINS = [ "netbox_animal_sounds", "netbox.plugins", ] ``` As for point 3, I thought that the plugin already supports that ability via the plugin config, which could be specified in the plugin's setup.py ``` # Default configuration parameters default_settings = {} # Mandatory configuration parameters required_settings = [] ```
Author
Owner

@jeremystretch commented on GitHub (Jan 26, 2021):

For points 1 and 2, my suggestion was that the functionality be enabled only if PLUGINS contains 'netbox.plugins' as in:

That still doesn't allow a user to toggle individual plugins.

I thought that the plugin already supports that ability via the plugin config

The PluginConfig class defines what configuration parameters are available/required. They still need to be set by the user in configuration.py.

@jeremystretch commented on GitHub (Jan 26, 2021): > For points 1 and 2, my suggestion was that the functionality be enabled only if PLUGINS contains 'netbox.plugins' as in: That still doesn't allow a user to toggle individual plugins. > I thought that the plugin already supports that ability via the plugin config The PluginConfig class defines what configuration parameters are available/required. They still need to be set by the user in `configuration.py`.
Author
Owner

@pvinci commented on GitHub (Jan 26, 2021):

That still doesn't allow a user to toggle individual plugins.
The existing functionality would be retained so that someone could do:

PLUGINS = [
    "netbox_animal_sounds",
   # "netbox.plugins", 
   "netbox_plugin1",   # normally registerable via netbox.plugins
   # "netbox_plugin2",   # normally registerable via netbox.plugins
]

And add the dynamic plugins with something similar to:

if "netbox.plugins" in PLUGINS:
   discovered_plugins = {
    entry_point.name: entry_point.load()
    for entry_point
    in pkg_resources.iter_entry_points('netbox.plugins')
}

03e48161a1/netbox/netbox/settings.py (L587)

It does not address configuration parameters.

In looking at this further, it can be as easily implemented by anyone in configuration.py. I am closing this.
Thank you!

@pvinci commented on GitHub (Jan 26, 2021): > That still doesn't allow a user to toggle individual plugins. The existing functionality would be retained so that someone could do: ``` PLUGINS = [ "netbox_animal_sounds", # "netbox.plugins", "netbox_plugin1", # normally registerable via netbox.plugins # "netbox_plugin2", # normally registerable via netbox.plugins ] ``` And add the dynamic plugins with something similar to: ``` if "netbox.plugins" in PLUGINS: discovered_plugins = { entry_point.name: entry_point.load() for entry_point in pkg_resources.iter_entry_points('netbox.plugins') } ``` https://github.com/netbox-community/netbox/blob/03e48161a152ed0c6029b1834a7dc44c55f98fcc/netbox/netbox/settings.py#L587 It does not address configuration parameters. In looking at this further, it can be as easily implemented by anyone in `configuration.py`. I am closing this. Thank you!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4500