1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Change PLUGINS_ENABLED to a list of specific plugins (PLUGINS)

This commit is contained in:
Jeremy Stretch
2020-04-01 10:02:18 -04:00
parent 06116cdde7
commit f469c794ce
4 changed files with 83 additions and 71 deletions

View File

@@ -299,6 +299,17 @@ Determine how many objects to display per page within each list of objects.
---
## PLUGINS
Default: Empty
A list of installed [NetBox plugins](../../plugins/) to enable. Plugins will not take effect unless they are listed here.
!!! warning
Plugins extend NetBox by allowing external code to run with the same access and privileges as NetBox itself. Only install plugins from trusted sources. The NetBox maintainers make absolutely no guarantees about the integrity or security of your installation with plugins enabled.
---
## PLUGINS_CONFIG
Default: Empty
@@ -317,18 +328,7 @@ PLUGINS_CONFIG = {
}
```
Note that `PLUGINS_ENABLED` must be set to True for this to take effect.
---
## PLUGINS_ENABLED
Default: `False`
Enable [NetBox plugins](../../plugins/).
!!! warning
Plugins extend NetBox by allowing external code to run with the same access and privileges as NetBox itself. Only install plugins from trusted sources. The NetBox maintainers make absolutely no guarantees about the integrity or security of your installation with plugins enabled.
Note that a plugin must be listed in `PLUGINS` for its configuration to take effect.
---

View File

@@ -61,13 +61,10 @@ setup(
install_requires=[],
packages=find_packages(),
include_package_data=True,
entry_points={
'netbox_plugins': 'netbox_animal_sounds=netbox_animal_sounds:AnimalSoundsConfig'
}
)
```
Many of these are self-explanatory, but for more information, see the [setuptools documentation](https://setuptools.readthedocs.io/en/latest/setuptools.html). The key requirement for a NetBox plugin is the presence of an entry point for `netbox_plugins` pointing to the `PluginConfig` subclass, which we'll create next.
Many of these are self-explanatory, but for more information, see the [setuptools documentation](https://setuptools.readthedocs.io/en/latest/setuptools.html).
### Define a PluginConfig
@@ -87,8 +84,12 @@ class AnimalSoundsConfig(PluginConfig):
default_settings = {
'loud': False
}
config = AnimalSoundsConfig
```
NetBox looks for the `config` variable within a plugin's `__init__.py` to load its configuration. Typically, this will be set to the PluginConfig subclass, but you may wish to dynamically generate a PluginConfig class based on environment variables or other factors.
#### PluginConfig Attributes
| Name | Description |

View File

@@ -41,12 +41,14 @@ $ source /opt/netbox/venv/bin/activate
Alternatively, you may wish to install the plugin manually by running `python setup.py install`. If you are developing a plugin and want to install it only temporarily, run `python setup.py develop` instead.
### Enable Plugins
### Enable the Plugin
In `configuration.py`, ensure the `PLUGINS_ENABLED` parameter is set to True:
In `configuration.py`, add the plugin's name to the `PLUGINS` list:
```python
PLUGINS_ENABLED = True
PLUGINS = [
'plugin_name',
]
```
### Configure Plugin