def start_workflow(self, wf_identifier, wf_namespace='', wf_ex_id=None, wf_input=None, description='', **params): if wf_namespace: params['namespace'] = wf_namespace if cfg.CONF.notifier.notify: if 'notify' not in params or not params['notify']: params['notify'] = [] params['notify'].extend(cfg.CONF.notifier.notify) try: with db_api.transaction(): wf_ex = wf_handler.start_workflow(wf_identifier, wf_namespace, wf_ex_id, wf_input or {}, description, params) # Checking a case when all tasks are completed immediately. wf_handler.check_and_complete(wf_ex.id) return wf_ex.get_clone() except exceptions.DBDuplicateEntryError: # NOTE(akovi): the workflow execution with a provided # wf_ex_id may already exist. In this case, simply # return the existing entity. with db_api.transaction(): wf_ex = db_api.get_workflow_execution(wf_ex_id) return wf_ex.get_clone()
def start_workflow(self, wf_identifier, wf_namespace='', wf_ex_id=None, wf_input=None, description='', async_=False, **params): if wf_namespace: params['namespace'] = wf_namespace if cfg.CONF.notifier.notify: if 'notify' not in params or not params['notify']: params['notify'] = [] params['notify'].extend(cfg.CONF.notifier.notify) try: with db_api.transaction(): wf_ex = wf_handler.start_workflow( wf_identifier, wf_namespace, wf_ex_id, wf_input or {}, description, params ) # Checking a case when all tasks are completed immediately. wf_handler.check_and_complete(wf_ex.id) return wf_ex.get_clone() except exceptions.DBDuplicateEntryError: # NOTE(akovi): the workflow execution with a provided # wf_ex_id may already exist. In this case, simply # return the existing entity. with db_api.transaction(): wf_ex = db_api.get_workflow_execution(wf_ex_id) return wf_ex.get_clone()
def _check(): wf_handler.check_and_complete(self.wf_ex.id)