mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fixes #5316: Dry running scripts should not trigger webhooks
This commit is contained in:
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
* [#5271](https://github.com/netbox-community/netbox/issues/5271) - Fix auto-population of region field when editing a device
|
* [#5271](https://github.com/netbox-community/netbox/issues/5271) - Fix auto-population of region field when editing a device
|
||||||
* [#5314](https://github.com/netbox-community/netbox/issues/5314) - Fix config context rendering when multiple tags are assigned to an object
|
* [#5314](https://github.com/netbox-community/netbox/issues/5314) - Fix config context rendering when multiple tags are assigned to an object
|
||||||
|
* [#5316](https://github.com/netbox-community/netbox/issues/5316) - Dry running scripts should not trigger webhooks
|
||||||
* [#5324](https://github.com/netbox-community/netbox/issues/5324) - Add missing template extension tags for plugins for VM interface view
|
* [#5324](https://github.com/netbox-community/netbox/issues/5324) - Add missing template extension tags for plugins for VM interface view
|
||||||
* [#5328](https://github.com/netbox-community/netbox/issues/5328) - Fix CreatedUpdatedFilterTest when running in non-UTC timezone
|
* [#5328](https://github.com/netbox-community/netbox/issues/5328) - Fix CreatedUpdatedFilterTest when running in non-UTC timezone
|
||||||
* [#5331](https://github.com/netbox-community/netbox/issues/5331) - Fix filtering of sites by null region
|
* [#5331](https://github.com/netbox-community/netbox/issues/5331) - Fix filtering of sites by null region
|
||||||
|
@ -441,8 +441,11 @@ def run_script(data, request, commit=True, *args, **kwargs):
|
|||||||
f"with NetBox v2.10."
|
f"with NetBox v2.10."
|
||||||
)
|
)
|
||||||
|
|
||||||
with change_logging(request):
|
def _run_script():
|
||||||
|
"""
|
||||||
|
Core script execution task. We capture this within a subfunction to allow for conditionally wrapping it with
|
||||||
|
the change_logging context manager (which is bypassed if commit == False).
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
script.output = script.run(**kwargs)
|
script.output = script.run(**kwargs)
|
||||||
@ -469,6 +472,14 @@ def run_script(data, request, commit=True, *args, **kwargs):
|
|||||||
|
|
||||||
logger.info(f"Script completed in {job_result.duration}")
|
logger.info(f"Script completed in {job_result.duration}")
|
||||||
|
|
||||||
|
# Execute the script. If commit is True, wrap it with the change_logging context manager to ensure we process
|
||||||
|
# change logging, webhooks, etc.
|
||||||
|
if commit:
|
||||||
|
with change_logging(request):
|
||||||
|
_run_script()
|
||||||
|
else:
|
||||||
|
_run_script()
|
||||||
|
|
||||||
# Delete any previous terminal state results
|
# Delete any previous terminal state results
|
||||||
JobResult.objects.filter(
|
JobResult.objects.filter(
|
||||||
obj_type=job_result.obj_type,
|
obj_type=job_result.obj_type,
|
||||||
|
Reference in New Issue
Block a user