def execute(self, actions): try: # NOTE(jed) We want to have a strong separation of concern # between the Watcher planner and the Watcher Applier in order # to us the possibility to support several workflow engine. # We want to provide the 'taskflow' engine by # default although we still want to leave the possibility for # the users to change it. # The current implementation uses graph with linked actions. # todo(jed) add olso conf for retry and name flow = gf.Flow("watcher_flow") actions_uuid = {} for a in actions: task = TaskFlowActionContainer(a, self) flow.add(task) actions_uuid[a.uuid] = task for a in actions: for parent_id in a.parents: flow.link(actions_uuid[parent_id], actions_uuid[a.uuid], decider=self.decider) e = engines.load(flow, engine='parallel', max_workers=self.config.max_workers) e.run() return flow except Exception as e: raise exception.WorkflowExecutionException(error=e)
def execute(self, actions): try: # NOTE(jed) We want to have a strong separation of concern # between the Watcher planner and the Watcher Applier in order # to us the possibility to support several workflow engine. # We want to provide the 'taskflow' engine by # default although we still want to leave the possibility for # the users to change it. # todo(jed) we need to change the way the actions are stored. # The current implementation only use a linked list of actions. # todo(jed) add olso conf for retry and name flow = gf.Flow("watcher_flow") previous = None for a in actions: task = TaskFlowActionContainer(a, self) flow.add(task) if previous is None: previous = task # we have only one Action in the Action Plan if len(actions) == 1: nop = TaskFlowNop() flow.add(nop) flow.link(previous, nop) else: # decider == guard (UML) flow.link(previous, task, decider=self.decider) previous = task e = engines.load(flow) e.run() except Exception as e: raise exception.WorkflowExecutionException(error=e)
def execute(self, actions): try: flow = gf.Flow("watcher_flow") for a in actions: task = TaskFlowActionContainer(a, self) flow.add(task) executor = futurist.GreenThreadPoolExecutor(max_workers=100) e = engines.load(flow, engine='parallel', executor=executor) e.run() except Exception as e: raise exception.WorkflowExecutionException(error=e) finally: executor.shutdown()