def notify(self, old_task_state, new_task_state): publishers = self.wf_ex.params.get('notify') if not publishers and not isinstance(publishers, list): return notifier = notif.get_notifier(cfg.CONF.notifier.type) event = events.identify_task_event(old_task_state, new_task_state) def _convert_to_notification_data(): return { "id": self.task_ex.id, "name": self.task_ex.name, "workflow_name": self.task_ex.workflow_name, "workflow_namespace": self.task_ex.workflow_namespace, "workflow_id": self.task_ex.workflow_id, "state": self.task_ex.state, "state_info": self.task_ex.state_info, "type": self.task_ex.type, "project_id": self.task_ex.project_id } def _send_notification(): notifier.notify(self.task_ex.id, _convert_to_notification_data(), event, self.task_ex.updated_at, publishers) post_tx_queue.register_operation(_send_notification)
def notify(self, old_task_state, new_task_state): publishers = self.wf_ex.params.get('notify') if not publishers and not isinstance(publishers, list): return notifier = notif.get_notifier(cfg.CONF.notifier.type) event = events.identify_task_event(old_task_state, new_task_state) notifier.notify(self.task_ex.id, self.task_ex.to_dict(), event, self.task_ex.updated_at, publishers)
def notify(self, old_task_state, new_task_state): publishers = self.wf_ex.params.get('notify') if not publishers and not isinstance(publishers, list): return notifier = notif.get_notifier(cfg.CONF.notifier.type) event = events.identify_task_event(old_task_state, new_task_state) notifier.notify( self.task_ex.id, self.task_ex.to_dict(), event, self.task_ex.updated_at, publishers )
def _notify(self, from_state, to_state): publishers = self.wf_ex.params.get('notify') if not publishers and not isinstance(publishers, list): return notifier = notif.get_notifier(cfg.CONF.notifier.type) event = events.identify_task_event(from_state, to_state) filtered_publishers = [] for publisher in publishers: if not isinstance(publisher, dict): continue target_events = publisher.get('event_types', []) if not target_events or event in target_events: filtered_publishers.append(publisher) if not filtered_publishers: return data = { "id": self.task_ex.id, "name": self.task_ex.name, "workflow_execution_id": self.task_ex.workflow_execution_id, "workflow_name": self.task_ex.workflow_name, "workflow_namespace": self.task_ex.workflow_namespace, "workflow_id": self.task_ex.workflow_id, "state": self.task_ex.state, "state_info": self.task_ex.state_info, "type": self.task_ex.type, "project_id": self.task_ex.project_id, "created_at": utils.datetime_to_str(self.task_ex.created_at), "updated_at": utils.datetime_to_str(self.task_ex.updated_at), "started_at": utils.datetime_to_str(self.task_ex.started_at), "finished_at": utils.datetime_to_str(self.task_ex.finished_at) } def _send_notification(): notifier.notify(self.task_ex.id, data, event, self.task_ex.updated_at, filtered_publishers) post_tx_queue.register_operation(_send_notification)
def notify(self, old_task_state, new_task_state): publishers = self.wf_ex.params.get('notify') if not publishers and not isinstance(publishers, list): return notifier = notif.get_notifier(cfg.CONF.notifier.type) event = events.identify_task_event(old_task_state, new_task_state) filtered_publishers = [] for publisher in publishers: if not isinstance(publisher, dict): continue target_events = publisher.get('event_types', []) if not target_events or event in target_events: filtered_publishers.append(publisher) if not filtered_publishers: return def _convert_to_notification_data(): return { "id": self.task_ex.id, "name": self.task_ex.name, "workflow_execution_id": self.task_ex.workflow_execution_id, "workflow_name": self.task_ex.workflow_name, "workflow_namespace": self.task_ex.workflow_namespace, "workflow_id": self.task_ex.workflow_id, "state": self.task_ex.state, "state_info": self.task_ex.state_info, "type": self.task_ex.type, "project_id": self.task_ex.project_id } def _send_notification(): notifier.notify( self.task_ex.id, _convert_to_notification_data(), event, self.task_ex.updated_at, filtered_publishers ) post_tx_queue.register_operation(_send_notification)