mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 02:19:58 -03:30
Merge pull request #4647 from rebeccahhh/devel
Added 'rescued' and 'ignored' fields into all_hosts dictionary update Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
commit
c819a78a4b
@ -666,6 +666,14 @@ class Job(UnifiedJob, JobOptions, SurveyJobMixin, JobNotificationMixin, TaskMana
|
||||
def processed_hosts(self):
|
||||
return self._get_hosts(job_host_summaries__processed__gt=0)
|
||||
|
||||
@property
|
||||
def ignored_hosts(self):
|
||||
return self._get_hosts(job_host_summaries__ignored__gt=0)
|
||||
|
||||
@property
|
||||
def rescued_hosts(self):
|
||||
return self._get_hosts(job_host_summaries__rescued__gt=0)
|
||||
|
||||
def notification_data(self, block=5):
|
||||
data = super(Job, self).notification_data()
|
||||
all_hosts = {}
|
||||
@ -684,7 +692,9 @@ class Job(UnifiedJob, JobOptions, SurveyJobMixin, JobNotificationMixin, TaskMana
|
||||
failures=h.failures,
|
||||
ok=h.ok,
|
||||
processed=h.processed,
|
||||
skipped=h.skipped) # TODO: update with rescued, ignored (see https://github.com/ansible/awx/issues/4394)
|
||||
skipped=h.skipped,
|
||||
rescued=h.rescued,
|
||||
ignored=h.ignored)
|
||||
data.update(dict(inventory=self.inventory.name if self.inventory else None,
|
||||
project=self.project.name if self.project else None,
|
||||
playbook=self.playbook,
|
||||
|
||||
@ -2,7 +2,7 @@ import pytest
|
||||
from unittest import mock
|
||||
import json
|
||||
|
||||
from awx.main.models import Job, Instance
|
||||
from awx.main.models import Job, Instance, JobHostSummary
|
||||
from awx.main.tasks import cluster_node_heartbeat
|
||||
from django.test.utils import override_settings
|
||||
|
||||
@ -47,6 +47,24 @@ def test_job_notification_data(inventory, machine_credential, project):
|
||||
assert json.loads(notification_data['extra_vars'])['SSN'] == encrypted_str
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_job_notification_host_data(inventory, machine_credential, project, job_template, host):
|
||||
job = Job.objects.create(
|
||||
job_template=job_template, inventory=inventory, name='hi world', project=project
|
||||
)
|
||||
JobHostSummary.objects.create(job=job, host=host, changed=1, dark=2, failures=3, ok=4, processed=3, skipped=2, rescued=1, ignored=0)
|
||||
assert job.notification_data()['hosts'] == {'single-host':
|
||||
{'failed': True,
|
||||
'changed': 1,
|
||||
'dark': 2,
|
||||
'failures': 3,
|
||||
'ok': 4,
|
||||
'processed': 3,
|
||||
'skipped': 2,
|
||||
'rescued': 1,
|
||||
'ignored': 0}}
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class TestLaunchConfig:
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user