Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-163-Update-node-state-for-stub-tasks dc55aa669 -> 1602ddbed
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/1602ddbe Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/1602ddbe Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/1602ddbe Branch: refs/heads/ARIA-163-Update-node-state-for-stub-tasks Commit: 1602ddbedd1024e6f96b034c621bf576e9036b72 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 15:50:40 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 ++++++++--- 4 files changed, 17 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1602ddbe/aria/orchestrator/workflows/api/task.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/workflows/api/task.py b/aria/orchestrator/workflows/api/task.py index 43cbe57..739e1b2 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/1602ddbe/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/1602ddbe/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/1602ddbe/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):
