Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-163-Update-node-state-for-stub-tasks 1602ddbed -> b7b9ab63b (forced update)
review4 Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/b7b9ab63 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/b7b9ab63 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/b7b9ab63 Branch: refs/heads/ARIA-163-Update-node-state-for-stub-tasks Commit: b7b9ab63b271adfcac77c58c221ba9fccf4fa608 Parents: dc55aa6 Author: max-orlov <[email protected]> Authored: Thu May 4 15:50:40 2017 +0300 Committer: max-orlov <[email protected]> Committed: Thu May 4 16:00:07 2017 +0300 ---------------------------------------------------------------------- aria/orchestrator/workflows/api/task.py | 12 +++++++----- aria/orchestrator/workflows/core/engine.py | 2 ++ aria/orchestrator/workflows/core/task.py | 4 ---- aria/orchestrator/workflows/events_logging.py | 11 ++++++++--- aria/orchestrator/workflows/executor/base.py | 4 ---- 5 files changed, 17 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b7b9ab63/aria/orchestrator/workflows/api/task.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/workflows/api/task.py b/aria/orchestrator/workflows/api/task.py index 43cbe57..cb79eb3 100644 --- a/aria/orchestrator/workflows/api/task.py +++ b/aria/orchestrator/workflows/api/task.py @@ -79,7 +79,8 @@ class OperationTask(BaseTask): self.operation_name = operation_name self.max_attempts = max_attempts or self.workflow_context._task_max_attempts self.retry_interval = retry_interval or self.workflow_context._task_retry_interval - self.ignore_failure = ignore_failure or self.workflow_context._task_ignore_failure + self.ignore_failure = \ + self.workflow_context._task_ignore_failure if ignore_failure is None else ignore_failure self.name = OperationTask.NAME_FORMAT.format(type=type(actor).__name__.lower(), name=actor.name, interface=self.interface_name, @@ -143,13 +144,13 @@ class WorkflowTask(BaseTask): def create_task(actor, interface_name, operation_name, **kwargs): """ - This helper function enables safe creation of OperationTask, if the supplied interface and - operation have no implementation, None is returned. + This helper function enables safe creation of OperationTask, if the supplied interface or + operation do not exist, None is returned. :param actor: the actor for this task :param interface_name: the name of the interface :param operation_name: the name of the operation :param kwargs: any additional kwargs to be passed to the task OperationTask - :return: and OperationTask or None (if no interface/operation exists) + :return: and OperationTask or None (if the interface/operation does not exists) """ try: return OperationTask( @@ -219,4 +220,5 @@ def create_relationship_tasks(relationship, interface_name, source_operation_nam def has_operation(actor, interface_name, operation_name): - return actor.interfaces.get(interface_name, {}).operations.get(operation_name, False) + interface = actor.interfaces.get(interface_name, None) + return interface and interface.operations.get(operation_name, False) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b7b9ab63/aria/orchestrator/workflows/core/engine.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/workflows/core/engine.py b/aria/orchestrator/workflows/core/engine.py index 6a66eb1..fd0dd6d 100644 --- a/aria/orchestrator/workflows/core/engine.py +++ b/aria/orchestrator/workflows/core/engine.py @@ -112,6 +112,8 @@ class Engine(logger.LoggerMixin): @staticmethod def _handle_executable_task(task): + if isinstance(task, engine_task.OperationTask): + events.sent_task_signal.send(task) task.execute() def _handle_ended_tasks(self, task): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b7b9ab63/aria/orchestrator/workflows/core/task.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/workflows/core/task.py b/aria/orchestrator/workflows/core/task.py index cc27d29..cee4bf4 100644 --- a/aria/orchestrator/workflows/core/task.py +++ b/aria/orchestrator/workflows/core/task.py @@ -77,9 +77,6 @@ class StubTask(BaseTask): self.status = models.Task.PENDING self.due_at = datetime.utcnow() - def execute(self): - return self._executor.execute(self) - def has_ended(self): return self.status == self.SUCCESS @@ -170,7 +167,6 @@ class OperationTask(BaseTask): self._update_fields = None def execute(self): - self._executor._task_sent(self) super(OperationTask, self).execute() @contextmanager http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b7b9ab63/aria/orchestrator/workflows/events_logging.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/workflows/events_logging.py b/aria/orchestrator/workflows/events_logging.py index e3f85d5..236a55f 100644 --- a/aria/orchestrator/workflows/events_logging.py +++ b/aria/orchestrator/workflows/events_logging.py @@ -36,10 +36,15 @@ def _get_task_name(task): @events.start_task_signal.connect def _start_task_handler(task, **kwargs): # If the task has not implementation this is an empty task. - suffix = 'started...' if task.implementation else 'has no implementation' - task.context.logger.debug('{name} {task.interface_name}.{task.operation_name} {suffix}' - .format(name=_get_task_name(task), task=task, suffix=suffix)) + if task.implementation: + suffix = 'started...' + logger = task.context.logger.info + else: + suffix = 'has no implementation' + logger = task.context.logger.debug + logger('{name} {task.interface_name}.{task.operation_name} {suffix}'.format( + name=_get_task_name(task), task=task, suffix=suffix)) @events.on_success_task_signal.connect def _success_task_handler(task, **kwargs): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b7b9ab63/aria/orchestrator/workflows/executor/base.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/workflows/executor/base.py b/aria/orchestrator/workflows/executor/base.py index 0194ee7..a225837 100644 --- a/aria/orchestrator/workflows/executor/base.py +++ b/aria/orchestrator/workflows/executor/base.py @@ -40,10 +40,6 @@ class BaseExecutor(logger.LoggerMixin): pass @staticmethod - def _task_sent(task): - events.sent_task_signal.send(task) - - @staticmethod def _task_started(task): events.start_task_signal.send(task)
