Provide the ability to execute custom scripts in response to object changes #7679

Closed
opened 2025-12-29 20:26:55 +01:00 by adam · 2 comments
Owner

Originally created by @jeremystretch on GitHub (Feb 24, 2023).

NetBox version

v3.4.5

Feature type

New functionality

Proposed functionality

Establish a mechanism by which a custom script can "attach" to one or more signals, so that the script automatically runs when the signal is received. This will likely need to be done programmatically as scripts are discovered. It should be possible to associate a script with a particular arbitrary signal and optionally only to certain senders for that signal.

We'll need to devise a way to automatically discover scripts, as scripts are currently only loaded as needed (e.g. in response to UI/API requests). Special consideration must also be paid to the execution workflow, to ensure that a catastrophic script error does not interfere with the triggering behavior.

For registration, it may be sufficient to call get_scripts() upon NetBox initialization, and execute a prescribed class method on each discovered script to handle its signal attachment. We'll also need to devise a convention for declaring receiver methods on each script.

Use case

Often it is desirable to automatically execute a custom script in response to the creation, modification, or deletion of a NetBox object (similar to how webhooks function).

Database changes

No response

External dependencies

No response

Originally created by @jeremystretch on GitHub (Feb 24, 2023). ### NetBox version v3.4.5 ### Feature type New functionality ### Proposed functionality Establish a mechanism by which a custom script can "attach" to one or more [signals](https://docs.djangoproject.com/en/4.1/topics/signals/), so that the script automatically runs when the signal is received. This will likely need to be done programmatically as scripts are discovered. It should be possible to associate a script with a particular arbitrary signal and optionally only to certain senders for that signal. We'll need to devise a way to automatically discover scripts, as scripts are currently only loaded as needed (e.g. in response to UI/API requests). Special consideration must also be paid to the execution workflow, to ensure that a catastrophic script error does not interfere with the triggering behavior. For registration, it may be sufficient to call `get_scripts()` upon NetBox initialization, and execute a prescribed class method on each discovered script to handle its signal attachment. We'll also need to devise a convention for declaring receiver methods on each script. ### Use case Often it is desirable to automatically execute a custom script in response to the creation, modification, or deletion of a NetBox object (similar to how webhooks function). ### Database changes _No response_ ### External dependencies _No response_
adam added the status: acceptedtype: feature labels 2025-12-29 20:26:55 +01:00
adam closed this issue 2025-12-29 20:26:55 +01:00
Author
Owner

@PieterL75 commented on GitHub (Feb 27, 2023):

I use webhooks for this, pointing to itself 😃
But a native way to call a script would be great! (No more apikey issues after migrating db to my dev server)

@PieterL75 commented on GitHub (Feb 27, 2023): I use webhooks for this, pointing to itself 😃 But a native way to call a script would be great! (No more apikey issues after migrating db to my dev server)
Author
Owner

@arthanson commented on GitHub (Oct 27, 2023):

Closing this issue as it is supplanted by the more general-purpose FR #14132

@arthanson commented on GitHub (Oct 27, 2023): Closing this issue as it is supplanted by the more general-purpose FR #14132
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7679