mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 13:39:27 -02:30
Fix some invalid assumptions about hosts and jobs where we assume a job
template will always be available
This commit is contained in:
@@ -756,7 +756,11 @@ class HostSerializer(BaseSerializerWithVariables):
|
|||||||
d['last_job']['job_template_name'] = obj.last_job.job_template.name
|
d['last_job']['job_template_name'] = obj.last_job.job_template.name
|
||||||
except (KeyError, AttributeError):
|
except (KeyError, AttributeError):
|
||||||
pass
|
pass
|
||||||
d.update({'recent_jobs': [{'id': j.job.id, 'name': j.job.job_template.name, 'status': j.job.status,
|
if j.job.job_template is not None:
|
||||||
|
job_template_name = j.job.job_template.name
|
||||||
|
else:
|
||||||
|
job_template_name = ""
|
||||||
|
d.update({'recent_jobs': [{'id': j.job.id, 'name': job_template_name, 'status': j.job.status,
|
||||||
'finished': j.job.finished} for j in obj.job_host_summaries.all().order_by('-created')[:5]]})
|
'finished': j.job.finished} for j in obj.job_host_summaries.all().order_by('-created')[:5]]})
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ class Job(UnifiedJob, JobOptions):
|
|||||||
def is_blocked_by(self, obj):
|
def is_blocked_by(self, obj):
|
||||||
from awx.main.models import InventoryUpdate, ProjectUpdate
|
from awx.main.models import InventoryUpdate, ProjectUpdate
|
||||||
if type(obj) == Job:
|
if type(obj) == Job:
|
||||||
if obj.job_template == self.job_template:
|
if obj.job_template is not None and obj.job_template == self.job_template:
|
||||||
if obj.launch_type == 'callback' and self.launch_type == 'callback':
|
if obj.launch_type == 'callback' and self.launch_type == 'callback':
|
||||||
if obj.limit != self.limit:
|
if obj.limit != self.limit:
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user