mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 04:10:44 -03:30
Derive ad-hoc - inventory source notification templates
This commit is contained in:
parent
fe64b0b478
commit
9bd05abcf3
@ -156,6 +156,25 @@ class AdHocCommand(UnifiedJob):
|
|||||||
h = hmac.new(settings.SECRET_KEY, self.created.isoformat())
|
h = hmac.new(settings.SECRET_KEY, self.created.isoformat())
|
||||||
return '%d-%s' % (self.pk, h.hexdigest())
|
return '%d-%s' % (self.pk, h.hexdigest())
|
||||||
|
|
||||||
|
@property
|
||||||
|
def notification_templates(self):
|
||||||
|
all_inventory_sources = set()
|
||||||
|
for h in self.hosts.all():
|
||||||
|
for invsrc in h.inventory_sources.all():
|
||||||
|
all_inventory_sources.add(invsrc)
|
||||||
|
active_templates = dict(error=set(),
|
||||||
|
success=set(),
|
||||||
|
any=set())
|
||||||
|
for invsrc in all_inventory_sources:
|
||||||
|
notifications_dict = invsrc.notification_templates
|
||||||
|
for notification_type in active_templates.keys():
|
||||||
|
for templ in notifications_dict[notification_type]:
|
||||||
|
active_templates[notification_type].add(templ)
|
||||||
|
active_templates['error'] = list(active_templates['error'])
|
||||||
|
active_templates['any'] = list(active_templates['any'])
|
||||||
|
active_templates['success'] = list(active_templates['success'])
|
||||||
|
return active_templates
|
||||||
|
|
||||||
def get_passwords_needed_to_start(self):
|
def get_passwords_needed_to_start(self):
|
||||||
return self.passwords_needed_to_start
|
return self.passwords_needed_to_start
|
||||||
|
|
||||||
|
|||||||
@ -212,7 +212,7 @@ def handle_work_success(self, result, task_actual):
|
|||||||
elif task_actual['type'] == 'ad_hoc_command':
|
elif task_actual['type'] == 'ad_hoc_command':
|
||||||
instance = AdHocCommand.objects.get(id=task_actual['id'])
|
instance = AdHocCommand.objects.get(id=task_actual['id'])
|
||||||
instance_name = instance.module_name
|
instance_name = instance.module_name
|
||||||
notification_templates = [] # TODO: Ad-hoc commands need to notify someone
|
notification_templates = instance.notification_templates
|
||||||
friendly_name = "AdHoc Command"
|
friendly_name = "AdHoc Command"
|
||||||
elif task_actual['type'] == 'system_job':
|
elif task_actual['type'] == 'system_job':
|
||||||
instance = SystemJob.objects.get(id=task_actual['id'])
|
instance = SystemJob.objects.get(id=task_actual['id'])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user