mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 22:37:41 -02:30
Updated notifications.py
Fixed the customized notification returning incorrect values for host_status_counts Update notifications.py Removed if condition Added exception handling A nitpick
This commit is contained in:
@@ -383,12 +383,17 @@ class JobNotificationMixin(object):
|
|||||||
and a url to the job run."""
|
and a url to the job run."""
|
||||||
job_context = {'host_status_counts': {}}
|
job_context = {'host_status_counts': {}}
|
||||||
summary = None
|
summary = None
|
||||||
if hasattr(self, 'job_host_summaries'):
|
try:
|
||||||
summary = self.job_host_summaries.first()
|
has_event_property = any([f for f in self.event_class._meta.fields if f.name == 'event'])
|
||||||
if summary:
|
except NotImplementedError:
|
||||||
from awx.api.serializers import JobHostSummarySerializer
|
has_event_property = False
|
||||||
summary_data = JobHostSummarySerializer(summary).to_representation(summary)
|
if has_event_property:
|
||||||
job_context['host_status_counts'] = summary_data
|
qs = self.get_event_queryset()
|
||||||
|
if qs:
|
||||||
|
event = qs.only('event_data').filter(event='playbook_on_stats').first()
|
||||||
|
if event:
|
||||||
|
summary = event.get_host_status_counts()
|
||||||
|
job_context['host_status_counts'] = summary
|
||||||
context = {
|
context = {
|
||||||
'job': job_context,
|
'job': job_context,
|
||||||
'job_friendly_name': self.get_notification_friendly_name(),
|
'job_friendly_name': self.get_notification_friendly_name(),
|
||||||
|
|||||||
Reference in New Issue
Block a user