Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-214-Dry-execution-still-change-the-state-of-non-implemented-operations 1cb3086f3 -> 93b798328
wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/93b79832 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/93b79832 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/93b79832 Branch: refs/heads/ARIA-214-Dry-execution-still-change-the-state-of-non-implemented-operations Commit: 93b7983282e1c40a104caf9b023937e6bd0a9b6d Parents: 1cb3086 Author: max-orlov <[email protected]> Authored: Sun May 7 16:12:56 2017 +0300 Committer: max-orlov <[email protected]> Committed: Sun May 7 16:12:56 2017 +0300 ---------------------------------------------------------------------- aria/orchestrator/workflows/core/task.py | 5 ++++- aria/orchestrator/workflows/core/translation.py | 6 +----- aria/orchestrator/workflows/executor/base.py | 10 ++++------ aria/orchestrator/workflows/executor/dry.py | 5 +++++ 4 files changed, 14 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/93b79832/aria/orchestrator/workflows/core/task.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/workflows/core/task.py b/aria/orchestrator/workflows/core/task.py index 0e081c2..0dbb26d 100644 --- a/aria/orchestrator/workflows/core/task.py +++ b/aria/orchestrator/workflows/core/task.py @@ -164,7 +164,10 @@ class OperationTask(BaseTask): self._update_fields = None def execute(self): - super(OperationTask, self).execute() + if self.model_task.implementation: + return self._executor.execute(self) + else: + return self._executor.execute_empty_task(self) @contextmanager def _update(self): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/93b79832/aria/orchestrator/workflows/core/translation.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/workflows/core/translation.py b/aria/orchestrator/workflows/core/translation.py index 0bbce90..fec108b 100644 --- a/aria/orchestrator/workflows/core/translation.py +++ b/aria/orchestrator/workflows/core/translation.py @@ -48,11 +48,7 @@ def build_execution_graph( execution_graph, dependencies, default=[start_task]) if isinstance(api_task, api.task.OperationTask): - if api_task.implementation: - operation_task = core_task.OperationTask(api_task, executor=default_executor) - else: - operation_task = core_task.OperationTask(api_task, - executor=base.EmptyOperationExecutor()) + operation_task = core_task.OperationTask(api_task, executor=default_executor) _add_task_and_dependencies(execution_graph, operation_task, operation_dependencies) elif isinstance(api_task, api.task.WorkflowTask): # Build the graph recursively while adding start and end markers http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/93b79832/aria/orchestrator/workflows/executor/base.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/workflows/executor/base.py b/aria/orchestrator/workflows/executor/base.py index a225837..d71dafc 100644 --- a/aria/orchestrator/workflows/executor/base.py +++ b/aria/orchestrator/workflows/executor/base.py @@ -33,6 +33,10 @@ class BaseExecutor(logger.LoggerMixin): """ raise NotImplementedError + def execute_empty_task(self, task): + self._task_started(task) + self._task_succeeded(task) + def close(self): """ Close the executor @@ -55,9 +59,3 @@ class BaseExecutor(logger.LoggerMixin): class StubTaskExecutor(BaseExecutor): def execute(self, task): task.status = task.SUCCESS - - -class EmptyOperationExecutor(BaseExecutor): - def execute(self, task): - events.start_task_signal.send(task) - events.on_success_task_signal.send(task) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/93b79832/aria/orchestrator/workflows/executor/dry.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/workflows/executor/dry.py b/aria/orchestrator/workflows/executor/dry.py index eb70a41..6470b4c 100644 --- a/aria/orchestrator/workflows/executor/dry.py +++ b/aria/orchestrator/workflows/executor/dry.py @@ -26,6 +26,11 @@ class DryExecutor(BaseExecutor): Executor which dry runs tasks - prints task information without causing any side effects """ + def execute_empty_task(self, task): + with task._update(): + task.ended_at = datetime.utcnow() + task.status = task.SUCCESS + def execute(self, task): # updating the task manually instead of calling self._task_started(task), # to avoid any side effects raising that event might cause
