From a19bdd0c9fb9cb3b6a7a3961b726f1e008313dc7 Mon Sep 17 00:00:00 2001 From: Alexander Haase Date: Mon, 4 Nov 2024 21:41:57 +0100 Subject: [PATCH 1/2] Fix non-null constraint for script execution With c34a0e2, validation of job object fields is enabled, so ScriptJob must not set required fields to empty strings. This commit reverts b18f193 and (hopefully) fixes this issue not only for UI views, but for all interactions with scripts. Fixes: #17923 --- netbox/extras/jobs.py | 4 +--- netbox/extras/views.py | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/netbox/extras/jobs.py b/netbox/extras/jobs.py index a913fe456e0..190166b5be0 100644 --- a/netbox/extras/jobs.py +++ b/netbox/extras/jobs.py @@ -22,9 +22,7 @@ class ScriptJob(JobRunner): """ class Meta: - # An explicit job name is not set because it doesn't make sense in this context. Currently, there's no scenario - # where jobs other than this one are used. Therefore, it is hidden, resulting in a cleaner job table overview. - name = '' + name = 'Run Script' def run_script(self, script, request, data, commit): """ diff --git a/netbox/extras/views.py b/netbox/extras/views.py index 0d98b132467..a87758adcc7 100644 --- a/netbox/extras/views.py +++ b/netbox/extras/views.py @@ -1181,7 +1181,6 @@ def post(self, request, **kwargs): request=copy_safe_request(request), job_timeout=script.python_class.job_timeout, commit=form.cleaned_data.pop('_commit'), - name=script.name ) return redirect('extras:script_result', job_pk=job.pk) From d0ee68968c5858468e9f68a8b5f75c20465c71de Mon Sep 17 00:00:00 2001 From: Alexander Haase Date: Thu, 14 Nov 2024 22:36:17 +0100 Subject: [PATCH 2/2] Fix name of recurring jobs For recurring jobs, the name must be passed to the next job object when the job is rescheduled. --- netbox/netbox/jobs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/netbox/netbox/jobs.py b/netbox/netbox/jobs.py index ae8f2f10983..8c3e2373062 100644 --- a/netbox/netbox/jobs.py +++ b/netbox/netbox/jobs.py @@ -72,6 +72,7 @@ def handle(cls, job, *args, **kwargs): kwargs["job_timeout"] = job.object.python_class.job_timeout cls.enqueue( instance=job.object, + name=job.name, user=job.user, schedule_at=new_scheduled_time, interval=job.interval,