From 7532bca67ce2f0f62f20e70a97cebbba15a58219 Mon Sep 17 00:00:00 2001 From: Glenn Matthews Date: Mon, 11 May 2020 16:47:06 -0400 Subject: [PATCH] Add support for script and report packaging in plugins (#4573) --- docs/additional-features/reports.md | 2 + docs/development/application-registry.md | 24 +++++++++ docs/plugins/development.md | 59 +++++++++++++++++++++ docs/plugins/index.md | 2 + docs/release-notes/version-2.9.md | 7 +++ mkdocs.yml | 1 + netbox/extras/plugins/__init__.py | 44 +++++++++++++++ netbox/extras/reports.py | 36 ++++++++----- netbox/extras/scripts.py | 18 +++++++ netbox/extras/tests/dummy_plugin/reports.py | 8 +++ netbox/extras/tests/dummy_plugin/scripts.py | 11 ++++ netbox/extras/tests/test_plugins.py | 16 ++++++ netbox/extras/views.py | 6 +-- 13 files changed, 217 insertions(+), 17 deletions(-) create mode 100644 docs/release-notes/version-2.9.md create mode 100644 netbox/extras/tests/dummy_plugin/reports.py create mode 100644 netbox/extras/tests/dummy_plugin/scripts.py diff --git a/docs/additional-features/reports.md b/docs/additional-features/reports.md index 6deddc140..74137ebb8 100644 --- a/docs/additional-features/reports.md +++ b/docs/additional-features/reports.md @@ -37,6 +37,8 @@ from dcim.constants import CONNECTION_STATUS_PLANNED from dcim.models import ConsolePort, Device, PowerPort from extras.reports import Report +name = "Device Connections Report" + class DeviceConnectionsReport(Report): description = "Validate the minimum physical connections for each device" diff --git a/docs/development/application-registry.md b/docs/development/application-registry.md index 67479b6fb..7c64bb513 100644 --- a/docs/development/application-registry.md +++ b/docs/development/application-registry.md @@ -53,3 +53,27 @@ Plugin content that gets embedded into core NetBox templates. The store comprise ], } ``` + +### `plugin_reports` + +[Reports](../additional-features/reports.md) provided by plugins. Each plugin report module is registered as a key with the list of reports it provides as its value. An example: + +```python +{ + 'plugin_a.reports.first': [, ], + 'plugin_a.reports.second': [], + 'plugin_b.reports': [, , ], +} +``` + +### `plugin_scripts` + +[Custom scripts](../additional-features/custom-scripts.md) provided by plugins. Each plugin script module is registered as a key with the list of scripts it provides. An example: + +```python +{ + "plugin_a.scripts": [