From 2339fe22ae846ef24c1472ce13435f407b33da41 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 21 Aug 2020 11:06:36 -0400 Subject: [PATCH] Closes #4941: commit argument is now required argument in a custom script's run() method --- docs/release-notes/index.md | 2 +- docs/release-notes/version-2.10.md | 7 +++++++ netbox/extras/scripts.py | 15 +-------------- 3 files changed, 9 insertions(+), 15 deletions(-) create mode 100644 docs/release-notes/version-2.10.md diff --git a/docs/release-notes/index.md b/docs/release-notes/index.md index f314c53717..8990f83e04 120000 --- a/docs/release-notes/index.md +++ b/docs/release-notes/index.md @@ -1 +1 @@ -version-2.9.md \ No newline at end of file +version-2.10.md \ No newline at end of file diff --git a/docs/release-notes/version-2.10.md b/docs/release-notes/version-2.10.md new file mode 100644 index 0000000000..eb25d083bc --- /dev/null +++ b/docs/release-notes/version-2.10.md @@ -0,0 +1,7 @@ +# NetBox v2.10 + +## v2.10-beta1 (FUTURE) + +### Other Changes + +* [#4941](https://github.com/netbox-community/netbox/issues/4941) - `commit` argument is now required argument in a custom script's `run()` method diff --git a/netbox/extras/scripts.py b/netbox/extras/scripts.py index 9d53806557..074cb82c5b 100644 --- a/netbox/extras/scripts.py +++ b/netbox/extras/scripts.py @@ -428,24 +428,11 @@ def run_script(data, request, commit=True, *args, **kwargs): # Add the current request as a property of the script script.request = request - # TODO: Drop backward-compatibility for absent 'commit' argument in v2.10 - # Determine whether the script accepts a 'commit' argument (this was introduced in v2.7.8) - kwargs = { - 'data': data - } - if 'commit' in inspect.signature(script.run).parameters: - kwargs['commit'] = commit - else: - warnings.warn( - f"The run() method of script {script} should support a 'commit' argument. This will be required beginning " - f"with NetBox v2.10." - ) - with change_logging(request): try: with transaction.atomic(): - script.output = script.run(**kwargs) + script.output = script.run(data=data, commit=commit) job_result.set_status(JobResultStatusChoices.STATUS_COMPLETED) if not commit: