add group_name to channel data

This commit is contained in:
Wayne Witzel III 2016-08-29 18:15:11 -04:00
parent ee09d881a4
commit 5faa21b72d
6 changed files with 9 additions and 4 deletions

View File

@ -544,7 +544,9 @@ class AuthTokenView(APIView):
# Mark them as invalid and inform the user
invalid_tokens = AuthToken.get_tokens_over_limit(serializer.validated_data['user'])
for t in invalid_tokens:
emit_channel_notification('control-limit_reached', dict(reason=force_text(AuthToken.reason_long('limit_reached')), token_key=t.key))
emit_channel_notification('control-limit_reached', dict(group_name='control',
reason=force_text(AuthToken.reason_long('limit_reached')),
token_key=t.key))
t.invalidate(reason='limit_reached')
# Note: This header is normally added in the middleware whenever an

View File

@ -1260,7 +1260,7 @@ class JobEvent(CreatedModifiedModel):
if update_fields:
host_summary.save(update_fields=update_fields)
job.inventory.update_computed_fields()
emit_channel_notification('jobs-summary', dict(unified_job_id=job.id))
emit_channel_notification('jobs-summary', dict(group_name='jobs', unified_job_id=job.id))
@classmethod
def get_startevent_queryset(cls, parent_task, starting_events, ordering=None):

View File

@ -113,7 +113,7 @@ class Schedule(CommonModel):
self.dtend = make_aware(datetime.datetime.strptime(until_date, "%Y%m%dT%H%M%SZ"), get_default_timezone())
if 'count' in self.rrule.lower():
self.dtend = future_rs[-1]
emit_channel_notification('schedules-changed', dict(id=self.id))
emit_channel_notification('schedules-changed', dict(id=self.id, group_name='schedules'))
with ignore_inventory_computed_fields():
self.unified_job_template.update_computed_fields()

View File

@ -782,6 +782,7 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
def websocket_emit_status(self, status):
status_data = dict(unified_job_id=self.id, status=status)
status_data.update(self.websocket_emit_data())
status_data['group_name'] = 'jobs'
emit_channel_notification('jobs-status_changed', status_data)
def generate_dependencies(self, active_tasks):

View File

@ -42,6 +42,7 @@ def emit_job_event_detail(sender, **kwargs):
event_serialized["created"] = event_serialized["created"].isoformat()
event_serialized["modified"] = event_serialized["modified"].isoformat()
event_serialized["event_name"] = instance.event
event_serialized["group_name"] = "job_events"
emit_channel_notification('job_events-' + str(instance.job.id), event_serialized)
def emit_ad_hoc_command_event_detail(sender, **kwargs):
@ -53,6 +54,7 @@ def emit_ad_hoc_command_event_detail(sender, **kwargs):
event_serialized["created"] = event_serialized["created"].isoformat()
event_serialized["modified"] = event_serialized["modified"].isoformat()
event_serialized["event_name"] = instance.event
event_serialized["group_name"] = "ad_hoc_command_events"
emit_channel_notification('ad_hoc_command_events-' + str(instance.ad_hoc_command_id), event_serialized)
def emit_update_inventory_computed_fields(sender, **kwargs):

View File

@ -177,7 +177,7 @@ def tower_periodic_scheduler(self):
new_unified_job.job_explanation = "Scheduled job could not start because it was not in the right state or required manual credentials"
new_unified_job.save(update_fields=['status', 'job_explanation'])
new_unified_job.websocket_emit_status("failed")
emit_channel_notification('schedules-changed', dict(id=schedule.id))
emit_channel_notification('schedules-changed', dict(id=schedule.id, group_name="schedules"))
@task(queue='default')
def notify_task_runner(metadata_dict):