Improve update computed field signaling so that we only emit signals when a host is added or deleted, or if it is associated or disassociated, or if a job runs

Conflicts:
	awx/main/signals.py
This commit is contained in:
Matthew Jones
2014-05-13 15:12:42 -04:00
parent db3151a9dd
commit 93c2a5e31c
3 changed files with 40 additions and 13 deletions
+7 -1
View File
@@ -127,7 +127,7 @@ def handle_work_error(self, task_id, subtasks=None):
instance.socketio_emit_status("failed")
@task()
def update_inventory_computed_fields(inventory_id, should_update_hosts):
def update_inventory_computed_fields(inventory_id, should_update_hosts=True):
'''
Signal handler and wrapper around inventory.update_computed_fields to
prevent unnecessary recursive calls.
@@ -589,6 +589,12 @@ class RunJob(BaseTask):
Hook for actions to run after job/task has completed.
'''
super(RunJob, self).post_run_hook(job, **kwargs)
try:
inventory = job.inventory
except Inventory.DoesNotExist:
pass
else:
update_inventory_computed_fields.delay(inventory.id, True)
# Update job event fields after job has completed (only when using REST
# API callback).
if not settings.CALLBACK_CONSUMER_PORT: