Maintain database representations of reports & scripts #8922

Closed
opened 2025-12-29 20:42:52 +01:00 by adam · 1 comment
Owner

Originally created by @jeremystretch on GitHub (Dec 5, 2023).

Originally assigned to: @arthanson on GitHub.

NetBox version

v3.6.6

Feature type

Data model extension

Proposed functionality

Promote the "dummy" models in the extras that currently represent reports and scripts to "real" models corresponding to database tables. Each Report or Script instance will correlate to a Python class belonging to a ReportModule or ScriptModule, respectively. Report and Script objects will be created, updated, and deleted automatically in response to content changes in their assigned module.

Use case

The lack of a concrete database object representing individual reports and scripts limits our ability to efficiently represent relationships with other NetBox objects. Two prime examples are:

  • Bug #14382 - It is not currently possible to associate a specific report or script with a Webhook
  • FR #14132 (v3.7) - Specifying a report or script as the action of an EventRule requires us to store the report/script class name in addition to the ForeignKey relationship to the parent module

Essentially, we reduce the current need for a tuple of (module, class) to a simple ForeignKey relationship.

Database changes

Promoting the Report and Script classes to concrete models will effect the creation of two new PostgreSQL tables:

  • extras_report
  • extras_script

One new database record will be automatically created for each report and script currently installed.

External dependencies

None

Originally created by @jeremystretch on GitHub (Dec 5, 2023). Originally assigned to: @arthanson on GitHub. ### NetBox version v3.6.6 ### Feature type Data model extension ### Proposed functionality Promote the "dummy" models in the `extras` that currently represent reports and scripts to "real" models corresponding to database tables. Each Report or Script instance will correlate to a Python class belonging to a ReportModule or ScriptModule, respectively. Report and Script objects will be created, updated, and deleted automatically in response to content changes in their assigned module. ### Use case The lack of a concrete database object representing individual reports and scripts limits our ability to efficiently represent relationships with other NetBox objects. Two prime examples are: * Bug #14382 - It is not currently possible to associate a specific report or script with a Webhook * FR #14132 (v3.7) - Specifying a report or script as the action of an EventRule requires us to store the report/script class name in addition to the ForeignKey relationship to the parent module Essentially, we reduce the current need for a tuple of (module, class) to a simple ForeignKey relationship. ### Database changes Promoting the Report and Script classes to concrete models will effect the creation of two new PostgreSQL tables: * `extras_report` * `extras_script` One new database record will be automatically created for each report and script currently installed. ### External dependencies None
adam added the status: acceptedtype: feature labels 2025-12-29 20:42:52 +01:00
adam closed this issue 2025-12-29 20:42:52 +01:00
Author
Owner

@eronlloyd commented on GitHub (Jan 28, 2024):

Will this allow scripts to be persistent through replacement? It would be nice not to have to delete them each time a script is updated, although I understand how that could create issues if allowed unchecked.

@eronlloyd commented on GitHub (Jan 28, 2024): Will this allow scripts to be persistent through replacement? It would be nice not to have to delete them each time a script is updated, although I understand how that could create issues if allowed unchecked.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8922