mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 17:26:10 -06:00
start() and terminate() methods on Job should call save()
This commit is contained in:
parent
177668dca5
commit
48ee8a94b4
@ -140,7 +140,7 @@ class Job(models.Model):
|
||||
# Start the job
|
||||
self.started = timezone.now()
|
||||
self.status = JobStatusChoices.STATUS_RUNNING
|
||||
Job.objects.filter(pk=self.pk).update(started=self.started, status=self.status)
|
||||
self.save()
|
||||
|
||||
# Handle webhooks
|
||||
self.trigger_webhooks(event=EVENT_JOB_START)
|
||||
@ -156,7 +156,7 @@ class Job(models.Model):
|
||||
# Mark the job as completed
|
||||
self.status = status
|
||||
self.completed = timezone.now()
|
||||
Job.objects.filter(pk=self.pk).update(status=self.status, completed=self.completed)
|
||||
self.save()
|
||||
|
||||
# Handle webhooks
|
||||
self.trigger_webhooks(event=EVENT_JOB_END)
|
||||
|
@ -195,8 +195,6 @@ class Report(object):
|
||||
Run the report and save its results. Each test method will be executed in order.
|
||||
"""
|
||||
self.logger.info(f"Running report")
|
||||
job.status = JobStatusChoices.STATUS_RUNNING
|
||||
job.save()
|
||||
|
||||
# Perform any post-run tasks
|
||||
self.pre_run()
|
||||
@ -218,6 +216,7 @@ class Report(object):
|
||||
logger.error(f"Exception raised during report execution: {e}")
|
||||
job.terminate(status=JobStatusChoices.STATUS_ERRORED)
|
||||
finally:
|
||||
job.data = self._results
|
||||
job.terminate()
|
||||
|
||||
# Perform any post-run tasks
|
||||
|
Loading…
Reference in New Issue
Block a user