You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by mx...@apache.org on 2016/11/06 08:51:22 UTC
[2/2] incubator-ariatosca git commit: Intorduced task_graph tasks,
smarter workflow context, and tests.
Intorduced task_graph tasks, smarter workflow context, and tests.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/9002019e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/9002019e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/9002019e
Branch: refs/heads/ARIA-3-api-for-creating-workflows
Commit: 9002019e8d8198745142b00a1ea872d02e54b40b
Parents: 3d1c8b1
Author: mxmrlv <mx...@gmail.com>
Authored: Mon Oct 31 15:29:16 2016 +0200
Committer: mxmrlv <mx...@gmail.com>
Committed: Sun Nov 6 10:46:05 2016 +0200
----------------------------------------------------------------------
aria/.pylintrc | 2 +-
aria/__init__.py | 2 +-
aria/cli/commands.py | 2 +-
aria/context/__init__.py | 20 ++
aria/context/operation.py | 68 ++++++
aria/context/workflow.py | 188 +++++++++++++++++
aria/contexts.py | 211 -------------------
aria/decorators.py | 47 ++---
aria/storage/drivers.py | 2 +-
aria/storage/models.py | 58 ++---
aria/workflows/api/__init__.py | 2 +
aria/workflows/api/task.py | 90 ++++++++
aria/workflows/api/task_graph.py | 29 ++-
aria/workflows/builtin/execute_operation.py | 27 +--
aria/workflows/builtin/heal.py | 91 +++++---
aria/workflows/builtin/install.py | 12 +-
aria/workflows/builtin/uninstall.py | 10 +-
aria/workflows/builtin/workflows.py | 85 ++++----
aria/workflows/core/__init__.py | 2 +
aria/workflows/core/executor.py | 5 +-
aria/workflows/core/task.py | 106 ++++++++++
aria/workflows/core/tasks.py | 104 ---------
aria/workflows/core/translation.py | 36 ++--
tests/.pylintrc | 6 +-
tests/mock/__init__.py | 16 ++
tests/mock/context.py | 36 ++++
tests/mock/models.py | 132 ++++++++++++
tests/mock/operations.py | 33 +++
tests/test_logger.py | 2 +-
tests/workflows/__init__.py | 2 +
tests/workflows/api/test_task.py | 120 +++++++++++
tests/workflows/api/test_task_graph.py | 9 +-
tests/workflows/builtin/__init__.py | 130 +-----------
.../workflows/builtin/test_execute_operation.py | 61 ++++--
tests/workflows/builtin/test_heal.py | 43 +++-
tests/workflows/builtin/test_install.py | 38 +++-
tests/workflows/builtin/test_uninstall.py | 38 +++-
tests/workflows/core/test_executor.py | 13 +-
.../test_task_graph_into_exececution_graph.py | 56 ++---
tox.ini | 4 +-
40 files changed, 1226 insertions(+), 712 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/.pylintrc
----------------------------------------------------------------------
diff --git a/aria/.pylintrc b/aria/.pylintrc
index eb188a0..ee27fdb 100644
--- a/aria/.pylintrc
+++ b/aria/.pylintrc
@@ -62,7 +62,7 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
-disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,redefined-builtin,logging-format-interpolation
+disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,redefined-builtin,logging-format-interpolation,import-error
[REPORTS]
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/__init__.py
----------------------------------------------------------------------
diff --git a/aria/__init__.py b/aria/__init__.py
index 4d9b0f4..eca7b9b 100644
--- a/aria/__init__.py
+++ b/aria/__init__.py
@@ -56,7 +56,7 @@ def application_model_storage(driver):
models.DeploymentModification,
models.Execution,
models.ProviderContext,
- models.Operation,
+ models.Task,
])
return _model_storage[driver]
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/cli/commands.py
----------------------------------------------------------------------
diff --git a/aria/cli/commands.py b/aria/cli/commands.py
index a38229d..f909a1e 100644
--- a/aria/cli/commands.py
+++ b/aria/cli/commands.py
@@ -29,7 +29,7 @@ from aria import application_model_storage, application_resource_storage
from aria.logger import LoggerMixin
from aria.storage import FileSystemModelDriver, FileSystemResourceDriver
from aria.tools.application import StorageManager
-from aria.contexts import WorkflowContext
+from aria.context.workflow import WorkflowContext
from aria.workflows.core.engine import Engine
from aria.workflows.core.executor import ThreadExecutor
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/context/__init__.py
----------------------------------------------------------------------
diff --git a/aria/context/__init__.py b/aria/context/__init__.py
new file mode 100644
index 0000000..20e19db
--- /dev/null
+++ b/aria/context/__init__.py
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+Provides contexts to workflow and operation
+"""
+
+from . import workflow, operation
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/context/operation.py
----------------------------------------------------------------------
diff --git a/aria/context/operation.py b/aria/context/operation.py
new file mode 100644
index 0000000..d4d229a
--- /dev/null
+++ b/aria/context/operation.py
@@ -0,0 +1,68 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+Workflow and operation contexts
+"""
+
+from uuid import uuid4
+
+from aria.logger import LoggerMixin
+
+class OperationContext(LoggerMixin):
+ """
+ Context object used during operation creation and execution
+ """
+
+ def __init__(
+ self,
+ name,
+ operation_details,
+ workflow_context,
+ node_instance,
+ inputs=None):
+ super(OperationContext, self).__init__()
+ self.name = name
+ self.id = str(uuid4())
+ self.operation_details = operation_details
+ self.workflow_context = workflow_context
+ self.node_instance = node_instance
+ self.inputs = inputs or {}
+
+ def __repr__(self):
+ details = ', '.join(
+ '{0}={1}'.format(key, value)
+ for key, value in self.operation_details.items())
+ return '{name}({0})'.format(details, name=self.name)
+
+ def __getattr__(self, attr):
+ try:
+ return getattr(self.workflow_context, attr)
+ except AttributeError:
+ return super(OperationContext, self).__getattribute__(attr)
+
+ @property
+ def operation(self):
+ """
+ The model operation
+ """
+ return self.storage.operation.get(self.id)
+
+ @operation.setter
+ def operation(self, value):
+ """
+ Store the operation in the model storage
+ """
+ self.storage.operation.store(value)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/context/workflow.py
----------------------------------------------------------------------
diff --git a/aria/context/workflow.py b/aria/context/workflow.py
new file mode 100644
index 0000000..b5b4e4b
--- /dev/null
+++ b/aria/context/workflow.py
@@ -0,0 +1,188 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+Workflow and operation contexts
+"""
+
+import threading
+from uuid import uuid4
+from contextlib import contextmanager
+
+from ..logger import LoggerMixin
+from ..tools.lru_cache import lru_cache
+
+
+class WorkflowContext(LoggerMixin):
+ """
+ Context object used during workflow creation and execution
+ """
+
+ def __init__(
+ self,
+ model_storage,
+ resource_storage,
+ deployment_id,
+ workflow_id,
+ # TODO: this should be changed when we decide where the execution is created
+ execution_id=None,
+ parameters=None,
+ **kwargs):
+ super(WorkflowContext, self).__init__(**kwargs)
+ self.id = str(uuid4())
+ self.model = model_storage
+ self.resource = resource_storage
+ self.deployment_id = deployment_id
+ self.workflow_id = workflow_id
+ self.execution_id = execution_id
+ self.parameters = parameters or {}
+
+ def __repr__(self):
+ return (
+ '{name}(deployment_id={self.deployment_id}, '
+ 'workflow_id={self.workflow_id}, '
+ 'execution_id={self.execution_id})'.format(
+ name=self.__class__.__name__, self=self))
+
+ @property
+ def blueprint_id(self):
+ """
+ The blueprint id
+ """
+ return self.deployment.blueprint_id
+
+ @property
+ @lru_cache()
+ def blueprint(self):
+ """
+ The blueprint model
+ """
+ return self.model.blueprint.get(self.blueprint_id)
+
+ @property
+ @lru_cache()
+ def deployment(self):
+ """
+ The deployment model
+ """
+ return self.model.deployment.get(self.deployment_id)
+
+ @property
+ def nodes(self):
+ """
+ Iterator over nodes
+ """
+ return self.model.node.iter(
+ filters={'blueprint_id': self.blueprint_id})
+
+ @property
+ def node_instances(self):
+ """
+ Iterator over node instances
+ """
+ return self.model.node_instance.iter(filters={'deployment_id': self.deployment_id})
+
+ @property
+ def execution(self):
+ """
+ The execution model
+ """
+ return self.model.execution.get(self.execution_id)
+
+ @execution.setter
+ def execution(self, value):
+ """
+ Store the execution in the model storage
+ """
+ self.model.execution.store(value)
+
+ def download_blueprint_resource(self, destination, path=None):
+ """
+ Download a blueprint resource from the resource storage
+ """
+ return self.resource.blueprint.download(
+ entry_id=self.blueprint_id,
+ destination=destination,
+ path=path)
+
+ def download_deployment_resource(self, destination, path=None):
+ """
+ Download a deployment resource from the resource storage
+ """
+ return self.resource.deployment.download(
+ entry_id=self.deployment_id,
+ destination=destination,
+ path=path)
+
+ @lru_cache()
+ def get_deployment_resource_data(self, path=None):
+ """
+ Read a deployment resource as string from the resource storage
+ """
+ return self.resource.deployment.data(entry_id=self.deployment_id, path=path)
+
+ @lru_cache()
+ def get_blueprint_resource_data(self, path=None):
+ """
+ Read a blueprint resource as string from the resource storage
+ """
+ return self.resource.blueprint.data(entry_id=self.blueprint_id, path=path)
+
+
+class _CurrentContext(threading.local):
+ """
+ Provides thread-level context, which sugarcoats the task api.
+ """
+
+ def _set(self, value):
+ setattr(self, '_workflow_context', value)
+
+ def get(self):
+ """
+ Retrieves the current workflow context
+ :return: the workflow context
+ :rtype: WorkflowContext
+ """
+ try:
+ return getattr(self, '_workflow_context')
+ except AttributeError:
+ return None
+
+ def clear(self):
+ """
+ Clears the current context
+ """
+ if hasattr(self, '_workflow_context'):
+ delattr(self, '_workflow_context')
+
+ @contextmanager
+ def push(self, workflow_context):
+ """
+ Switches the current context to the provides context
+ :param workflow_context: the context to switch to.
+ :yields: the current context
+ """
+ if hasattr(self, '_workflow_context'):
+ prev_workflow_context = getattr(self, '_workflow_context')
+ else:
+ prev_workflow_context = None
+ self._set(workflow_context)
+ try:
+ yield self
+ finally:
+ self._set(prev_workflow_context)
+
+current = _CurrentContext()
+
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/contexts.py
----------------------------------------------------------------------
diff --git a/aria/contexts.py b/aria/contexts.py
deleted file mode 100644
index 3bda9be..0000000
--- a/aria/contexts.py
+++ /dev/null
@@ -1,211 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""
-Workflow and operation contexts
-"""
-
-from uuid import uuid4
-
-from aria.logger import LoggerMixin
-from aria.tools.lru_cache import lru_cache
-from aria.workflows.api.task_graph import TaskGraph
-
-
-class WorkflowContext(LoggerMixin):
- """
- Context object used during workflow creation and execution
- """
-
- def __init__(
- self,
- name,
- model_storage,
- resource_storage,
- deployment_id,
- workflow_id,
- parameters=None,
- **kwargs):
- super(WorkflowContext, self).__init__(**kwargs)
- self.name = name
- self.id = str(uuid4())
- self.model = model_storage
- self.resource = resource_storage
- self.deployment_id = deployment_id
- self.workflow_id = workflow_id
- self.execution_id = str(uuid4())
- self.parameters = parameters or {}
-
- def __repr__(self):
- return (
- '{name}(deployment_id={self.deployment_id}, '
- 'workflow_id={self.workflow_id}, '
- 'execution_id={self.execution_id})'.format(
- name=self.__class__.__name__, self=self))
-
- def operation(
- self,
- name,
- operation_details,
- node_instance,
- inputs=None):
- """
- Called during workflow creation, return an operation context. This object should be added to
- the task graph.
- """
- return OperationContext(
- name=name,
- operation_details=operation_details,
- workflow_context=self,
- node_instance=node_instance,
- inputs=inputs or {})
-
- @property
- def task_graph(self):
- """
- The task graph class
- """
- return TaskGraph
-
- @property
- def blueprint_id(self):
- """
- The blueprint id
- """
- return self.deployment.blueprint_id
-
- @property
- @lru_cache()
- def blueprint(self):
- """
- The blueprint model
- """
- return self.model.blueprint.get(self.blueprint_id)
-
- @property
- @lru_cache()
- def deployment(self):
- """
- The deployment model
- """
- return self.model.deployment.get(self.deployment_id)
-
- @property
- def nodes(self):
- """
- Iterator over nodes
- """
- return self.model.node.iter(
- filters={'blueprint_id': self.blueprint_id})
-
- @property
- def node_instances(self):
- """
- Iterator over node instances
- """
- return self.model.node_instance.iter(filters={'deployment_id': self.deployment_id})
-
- @property
- def execution(self):
- """
- The execution model
- """
- return self.model.execution.get(self.execution_id)
-
- @execution.setter
- def execution(self, value):
- """
- Store the execution in the model storage
- """
- self.model.execution.store(value)
-
- def download_blueprint_resource(self, destination, path=None):
- """
- Download a blueprint resource from the resource storage
- """
- return self.resource.blueprint.download(
- entry_id=self.blueprint_id,
- destination=destination,
- path=path)
-
- def download_deployment_resource(self, destination, path=None):
- """
- Download a deployment resource from the resource storage
- """
- return self.resource.deployment.download(
- entry_id=self.deployment_id,
- destination=destination,
- path=path)
-
- @lru_cache()
- def get_deployment_resource_data(self, path=None):
- """
- Read a deployment resource as string from the resource storage
- """
- return self.resource.deployment.data(entry_id=self.deployment_id, path=path)
-
- @lru_cache()
- def get_blueprint_resource_data(self, path=None):
- """
- Read a blueprint resource as string from the resource storage
- """
- return self.resource.blueprint.data(entry_id=self.blueprint_id, path=path)
-
-
-class OperationContext(LoggerMixin):
- """
- Context object used during operation creation and execution
- """
-
- def __init__(
- self,
- name,
- operation_details,
- workflow_context,
- node_instance,
- inputs=None):
- super(OperationContext, self).__init__()
- self.name = name
- self.id = str(uuid4())
- self.operation_details = operation_details
- self.workflow_context = workflow_context
- self.node_instance = node_instance
- self.inputs = inputs or {}
-
- def __repr__(self):
- details = ', '.join(
- '{0}={1}'.format(key, value)
- for key, value in self.operation_details.items())
- return '{name}({0})'.format(details, name=self.name)
-
- def __getattr__(self, attr):
- try:
- return getattr(self.workflow_context, attr)
- except AttributeError:
- return super(OperationContext, self).__getattribute__(attr)
-
- @property
- def operation(self):
- """
- The model operation
- """
- return self.storage.operation.get(self.id)
-
- @operation.setter
- def operation(self, value):
- """
- Store the operation in the model storage
- """
- self.storage.operation.store(value)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/decorators.py
----------------------------------------------------------------------
diff --git a/aria/decorators.py b/aria/decorators.py
index 7bc41b3..5713246 100644
--- a/aria/decorators.py
+++ b/aria/decorators.py
@@ -20,12 +20,13 @@ Workflow and operation decorators
from uuid import uuid4
from functools import partial, wraps
-from aria.tools.validation import validate_function_arguments
+from . import context
+from .workflows.api import task_graph
+from .tools.validation import validate_function_arguments
def workflow(
func=None,
- workflow_context=True,
simple_workflow=True,
suffix_template=''):
"""
@@ -34,31 +35,29 @@ def workflow(
if func is None:
return partial(
workflow,
- workflow_context=workflow_context,
simple_workflow=simple_workflow,
suffix_template=suffix_template)
@wraps(func)
- def _wrapper(context, **custom_kwargs):
+ def _wrapper(ctx, **custom_kwargs):
+
workflow_name = _generate_workflow_name(
func_name=func.__name__,
suffix_template=suffix_template,
- context=context,
+ ctx=ctx,
**custom_kwargs)
- func_kwargs = _create_func_kwargs(
- custom_kwargs,
- context,
- add_context=workflow_context,
- workflow_name=workflow_name)
- validate_function_arguments(func, func_kwargs)
- func(**func_kwargs)
- return func_kwargs['graph']
+
+ custom_kwargs.setdefault('ctx', ctx)
+ custom_kwargs.setdefault('graph', task_graph.TaskGraph(workflow_name))
+ validate_function_arguments(func, custom_kwargs)
+ with context.workflow.current.push(ctx):
+ func(**custom_kwargs)
+ return custom_kwargs['graph']
return _wrapper
def operation(
- func=None,
- operation_context=True):
+ func=None):
"""
Operation decorator
"""
@@ -66,29 +65,25 @@ def operation(
return partial(operation)
@wraps(func)
- def _wrapper(context, **custom_kwargs):
+ def _wrapper(ctx, **custom_kwargs):
func_kwargs = _create_func_kwargs(
custom_kwargs,
- context,
- add_context=operation_context)
+ ctx)
validate_function_arguments(func, func_kwargs)
- context.description = func.__doc__
+ ctx.description = func.__doc__
return func(**func_kwargs)
return _wrapper
-def _generate_workflow_name(func_name, context, suffix_template, **custom_kwargs):
+def _generate_workflow_name(func_name, ctx, suffix_template, **custom_kwargs):
return '{func_name}.{suffix}'.format(
func_name=func_name,
- suffix=suffix_template.format(context=context, **custom_kwargs) or str(uuid4()))
+ suffix=suffix_template.format(ctx=ctx, **custom_kwargs) or str(uuid4()))
def _create_func_kwargs(
kwargs,
- context,
- add_context=True,
+ ctx,
workflow_name=None):
- if add_context:
- kwargs['context'] = context
- kwargs.setdefault('graph', context.task_graph(workflow_name))
+ kwargs.setdefault('graph', ctx.task_graph(workflow_name))
return kwargs
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/storage/drivers.py
----------------------------------------------------------------------
diff --git a/aria/storage/drivers.py b/aria/storage/drivers.py
index 33b7c00..0ad2f49 100644
--- a/aria/storage/drivers.py
+++ b/aria/storage/drivers.py
@@ -32,7 +32,7 @@ import shutil
# pylint has an issue with distutils and virtualenvs: https://github.com/PyCQA/pylint/issues/73
import distutils.dir_util # pylint: disable=no-name-in-module, import-error
from functools import partial
-from billiard import RLock
+from multiprocessing import RLock
import jsonpickle
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/storage/models.py
----------------------------------------------------------------------
diff --git a/aria/storage/models.py b/aria/storage/models.py
index 32403ed..64c00bc 100644
--- a/aria/storage/models.py
+++ b/aria/storage/models.py
@@ -216,32 +216,6 @@ class Execution(Model):
is_system_workflow = Field(type=bool, default=False)
-class Operation(Model):
- """
- A Model which represents an operation
- """
- PENDING = 'pending'
- STARTED = 'started'
- SUCCESS = 'success'
- FAILED = 'failed'
- STATES = (
- PENDING,
- STARTED,
- SUCCESS,
- FAILED,
- )
- END_STATES = [SUCCESS, FAILED]
-
- id = Field(type=basestring, default=uuid_generator)
- status = Field(type=basestring, choices=STATES, default=STARTED)
- execution_id = Field(type=basestring)
- eta = Field(type=datetime, default=0)
- started_at = Field(type=datetime, default=None)
- ended_at = Field(type=datetime, default=None)
- max_retries = Field(type=int, default=0)
- retry_count = Field(type=int, default=0)
-
-
class Relationship(Model):
"""
A Model which represents a relationship
@@ -395,3 +369,35 @@ class Plugin(Model):
excluded_wheels = Field()
supported_py_versions = Field(type=list)
uploaded_at = Field(type=datetime)
+
+
+class Task(Model):
+ """
+ A Model which represents an task
+ """
+ PENDING = 'pending'
+ STARTED = 'started'
+ SUCCESS = 'success'
+ FAILED = 'failed'
+ STATES = (
+ PENDING,
+ STARTED,
+ SUCCESS,
+ FAILED,
+ )
+ END_STATES = [SUCCESS, FAILED]
+
+ id = Field(type=basestring, default=uuid_generator)
+ status = Field(type=basestring, choices=STATES, default=STARTED)
+ execution_id = Field(type=basestring)
+ eta = Field(type=datetime, default=0)
+ started_at = Field(type=datetime, default=None)
+ ended_at = Field(type=datetime, default=None)
+ max_retries = Field(type=int, default=0)
+ retry_count = Field(type=int, default=0)
+
+ # Operation specific fields
+ name = Field(type=basestring)
+ operation_details = Field(type=dict)
+ node_instance = PointerField(type=NodeInstance)
+ inputs = Field(type=dict, default=lambda: {})
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/workflows/api/__init__.py
----------------------------------------------------------------------
diff --git a/aria/workflows/api/__init__.py b/aria/workflows/api/__init__.py
index ae1e83e..b7f4b0c 100644
--- a/aria/workflows/api/__init__.py
+++ b/aria/workflows/api/__init__.py
@@ -12,3 +12,5 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+
+from . import task, task_graph
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/workflows/api/task.py
----------------------------------------------------------------------
diff --git a/aria/workflows/api/task.py b/aria/workflows/api/task.py
new file mode 100644
index 0000000..a24fdc4
--- /dev/null
+++ b/aria/workflows/api/task.py
@@ -0,0 +1,90 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+Provides the tasks to be enterd into the task graph
+"""
+from uuid import uuid4
+
+from aria import context
+
+
+class BaseTask(object):
+ """
+ Abstract task_graph task
+ """
+ pass
+
+
+class OperationTask(BaseTask):
+ """
+ Represents an operation task in the task_graph
+ """
+
+ def __init__(self,
+ name,
+ operation_details,
+ node_instance,
+ **operation_kwargs):
+ """
+ Creates an operation task using the name, details, node instance and any additional kwargs.
+ :param name: the operation of the name.
+ :param operation_details: the details for the operation.
+ :param node_instance: the node instnace on which this operation is registered.
+ :param operation_kwargs: any additional kwargs for the operation.
+ """
+ self.id = uuid4()
+ self.workflow_context = context.workflow.current.get()
+ self.name = name
+ self.operation_details = operation_details
+ self.node_instance = node_instance
+ self.operation_kwargs = operation_kwargs
+
+ def __getattr__(self, item):
+ try:
+ return self.__getattribute__(item)
+ except AttributeError:
+ return getattr(self._workflow_context.model.task.get(self._task_model.id), item)
+
+
+class WorkflowTask(BaseTask):
+ """
+ Represents an workflow task in the task_graph
+ """
+ def __init__(self, workflow_func, **kwargs):
+ """
+ Creates a workflow task using the workflow_func provided and its kwargs
+ :param workflow_func: the function to run
+ :param kwargs: the kwargs that would be passed to the workflow_func
+ """
+ kwargs.setdefault('ctx', context.workflow.current.get())
+ self._graph = workflow_func(**kwargs)
+
+ @property
+ def graph(self):
+ """
+ The graph constructed by the sub workflow
+ :return:
+ """
+ return self._graph
+
+ def __getattr__(self, item):
+ try:
+ return self.__getattribute__(item)
+ except AttributeError:
+ try:
+ return getattr(self._graph, item)
+ except AttributeError:
+ return getattr(context.workflow.current.get(), item)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/workflows/api/task_graph.py
----------------------------------------------------------------------
diff --git a/aria/workflows/api/task_graph.py b/aria/workflows/api/task_graph.py
index 20b0a50..42cf8b6 100644
--- a/aria/workflows/api/task_graph.py
+++ b/aria/workflows/api/task_graph.py
@@ -22,6 +22,8 @@ from collections import Iterable
from networkx import DiGraph, topological_sort
+from . import task
+
class TaskNotInGraphError(Exception):
"""
@@ -130,14 +132,15 @@ class TaskGraph(object):
:return: A list of added tasks
:rtype: list
"""
+ # assert all([isinstance(t, (task.BaseTask, Iterable)) for t in tasks])
return_tasks = []
- for task in tasks:
- if isinstance(task, Iterable):
- return_tasks += self.add_tasks(*task)
- elif not self.has_tasks(task):
- self._graph.add_node(task.id, task=task)
- return_tasks.append(task)
+ for t in tasks:
+ if isinstance(t, Iterable):
+ return_tasks += self.add_tasks(*t)
+ elif not self.has_tasks(t):
+ self._graph.add_node(t.id, task=t)
+ return_tasks.append(t)
return return_tasks
@@ -168,13 +171,14 @@ class TaskGraph(object):
:return: True if all tasks are in the graph, otherwise True
:rtype: list
"""
+ # assert all(isinstance(t, (task.BaseTask, Iterable)) for t in tasks)
return_value = True
- for task in tasks:
- if isinstance(task, Iterable):
- return_value &= self.has_tasks(*task)
+ for t in tasks:
+ if isinstance(t, Iterable):
+ return_value &= self.has_tasks(*t)
else:
- return_value &= self._graph.has_node(task.id)
+ return_value &= self._graph.has_node(t.id)
return return_value
@@ -276,6 +280,11 @@ class TaskGraph(object):
@_filter_out_empty_tasks
def sequence(self, *tasks):
+ """
+ Create and insert a sequence into the graph, effectively each task i depends on i-1
+ :param tasks: an iterable of dependencies
+ :return: the provided tasks
+ """
if tasks:
self.add_tasks(*tasks)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/workflows/builtin/execute_operation.py
----------------------------------------------------------------------
diff --git a/aria/workflows/builtin/execute_operation.py b/aria/workflows/builtin/execute_operation.py
index 2843375..ddbb8e7 100644
--- a/aria/workflows/builtin/execute_operation.py
+++ b/aria/workflows/builtin/execute_operation.py
@@ -24,7 +24,7 @@ from .workflows import execute_operation_on_instance
@workflow
def execute_operation(
- context,
+ ctx,
graph,
operation,
operation_kwargs,
@@ -37,7 +37,7 @@ def execute_operation(
"""
The execute_operation workflow
- :param WorkflowContext context: the workflow context
+ :param WorkflowContext workflow_context: the workflow context
:param TaskGraph graph: the graph which will describe the workflow.
:param basestring operation: the operation name to execute
:param dict operation_kwargs:
@@ -52,7 +52,7 @@ def execute_operation(
subgraphs = {}
# filtering node instances
filtered_node_instances = list(_filter_node_instances(
- context=context,
+ context=ctx,
node_ids=node_ids,
node_instance_ids=node_instance_ids,
type_names=type_names))
@@ -60,27 +60,28 @@ def execute_operation(
if run_by_dependency_order:
filtered_node_instances_ids = set(node_instance.id
for node_instance in filtered_node_instances)
- for node_instance in context.node_instances:
+ for node_instance in ctx.node_instances:
if node_instance.id not in filtered_node_instances_ids:
- subgraphs[node_instance.id] = context.task_graph(
+ subgraphs[node_instance.id] = ctx.task_graph(
name='execute_operation_stub_{0}'.format(node_instance.id))
# registering actual tasks to sequences
for node_instance in filtered_node_instances:
- execute_operation_on_instance(
- context=context,
- graph=graph,
- node_instance=node_instance,
- operation=operation,
- operation_kwargs=operation_kwargs,
- allow_kwargs_override=allow_kwargs_override)
+ graph.add_tasks(
+ execute_operation_on_instance(
+ node_instance=node_instance,
+ operation=operation,
+ operation_kwargs=operation_kwargs,
+ allow_kwargs_override=allow_kwargs_override
+ )
+ )
for _, node_instance_sub_workflow in subgraphs.items():
graph.add_tasks(node_instance_sub_workflow)
# adding tasks dependencies if required
if run_by_dependency_order:
- for node_instance in context.node_instances:
+ for node_instance in ctx.node_instances:
for relationship_instance in node_instance.relationship_instances:
graph.add_dependency(source_task=subgraphs[node_instance.id],
after=[subgraphs[relationship_instance.target_id]])
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/workflows/builtin/heal.py
----------------------------------------------------------------------
diff --git a/aria/workflows/builtin/heal.py b/aria/workflows/builtin/heal.py
index efdd7b1..2f3d538 100644
--- a/aria/workflows/builtin/heal.py
+++ b/aria/workflows/builtin/heal.py
@@ -19,36 +19,36 @@ Builtin heal workflow
from aria import workflow
-from .uninstall import uninstall
-from .install import install
-from .workflows import relationship_tasks
+from .workflows import relationship_tasks, install_node_instance, uninstall_node_instance
+from ..api import task, task_graph
@workflow
-def heal(context, graph, node_instance_id):
+def heal(ctx, graph, node_instance_id):
"""
The heal workflow
- :param WorkflowContext context: the workflow context
+ :param WorkflowContext ctx: the workflow context
:param TaskGraph graph: the graph which will describe the workflow.
:param node_instance_id: the id of the node instance to heal
:return:
"""
- failing_node = context.model.node_instance.get(node_instance_id)
- host_node = context.model.node_instance.get(failing_node.host_id)
- failed_node_instance_subgraph = _get_contained_subgraph(context, host_node)
+ failing_node = ctx.model.node_instance.get(node_instance_id)
+ host_node = ctx.model.node_instance.get(failing_node.host_id)
+ failed_node_instance_subgraph = _get_contained_subgraph(ctx, host_node)
failed_node_instance_ids = list(n.id for n in failed_node_instance_subgraph)
- targeted_node_instances = [node_instance for node_instance in context.node_instances
+ targeted_node_instances = [node_instance for node_instance in ctx.node_instances
if node_instance.id not in failed_node_instance_ids]
- uninstall_subgraph = heal_uninstall(
- context=context,
+ uninstall_subgraph = task.WorkflowTask(
+ heal_uninstall,
failing_node_instances=failed_node_instance_subgraph,
- targeted_node_instances=targeted_node_instances)
+ targeted_node_instances=targeted_node_instances
+ )
- install_subgraph = heal_install(
- context=context,
+ install_subgraph = task.WorkflowTask(
+ heal_install,
failing_node_instances=failed_node_instance_subgraph,
targeted_node_instances=targeted_node_instances)
@@ -58,10 +58,10 @@ def heal(context, graph, node_instance_id):
@workflow(suffix_template='{failing_node_instances}')
-def heal_uninstall(context, graph, failing_node_instances, targeted_node_instances):
+def heal_uninstall(ctx, graph, failing_node_instances, targeted_node_instances):
"""
the uninstall part of the heal mechanism
- :param WorkflowContext context: the workflow context
+ :param WorkflowContext ctx: the workflow context
:param TaskGraph graph: the task graph to edit.
:param failing_node_instances: the failing nodes to heal.
:param targeted_node_instances: the targets of the relationships where the failing node are
@@ -72,24 +72,34 @@ def heal_uninstall(context, graph, failing_node_instances, targeted_node_instanc
# Create install stub workflow for each unaffected node instance
for node_instance in targeted_node_instances:
- node_instance_sub_workflow = context.task_graph(
+ node_instance_sub_workflow = task_graph.TaskGraph(
name='uninstall_stub_{0}'.format(node_instance.id))
node_instance_sub_workflows[node_instance.id] = node_instance_sub_workflow
graph.add_tasks(node_instance_sub_workflow)
- # Create install sub workflow for each failing node
- uninstall(
- context=context,
- graph=graph,
- node_instances=failing_node_instances,
- node_instance_sub_workflows=node_instance_sub_workflows)
+ # Create install sub workflow for each failing node on the same graph
+ node_instance_sub_workflows = node_instance_sub_workflows or {}
+
+ # create install sub workflow for every node instance
+ for node_instance in failing_node_instances:
+ node_instance_sub_workflow = task.WorkflowTask(uninstall_node_instance,
+ node_instance=node_instance)
+ node_instance_sub_workflows[node_instance.id] = node_instance_sub_workflow
+ graph.add_tasks(node_instance_sub_workflow)
+
+ # create dependencies between the node instance sub workflow
+ for node_instance in failing_node_instances:
+ node_instance_sub_workflow = node_instance_sub_workflows[node_instance.id]
+ for relationship_instance in reversed(node_instance.relationship_instances):
+ graph.add_dependency(node_instance_sub_workflows[relationship_instance.target_id],
+ node_instance_sub_workflow)
# Add operations for intact nodes depending on a node instance belonging to node_instances
for node_instance in targeted_node_instances:
node_instance_sub_workflow = node_instance_sub_workflows[node_instance.id]
for relationship_instance in reversed(node_instance.relationship_instances):
- target_node_instance = context.model.node_instance.get(relationship_instance.target_id)
+ target_node_instance = ctx.model.node_instance.get(relationship_instance.target_id)
target_node_instance_subgraph = node_instance_sub_workflows[target_node_instance.id]
graph.add_dependency(target_node_instance_subgraph, node_instance_sub_workflow)
@@ -98,17 +108,17 @@ def heal_uninstall(context, graph, failing_node_instances, targeted_node_instanc
graph=graph,
node_instance=node_instance,
relationship_instance=relationship_instance,
- context=context,
+ context=ctx,
operation_name='aria.interfaces.relationship_lifecycle.unlink')
graph.add_dependency(node_instance_sub_workflow, dependency)
@workflow(suffix_template='{failing_node_instances}')
-def heal_install(context, graph, failing_node_instances, targeted_node_instances):
+def heal_install(ctx, graph, failing_node_instances, targeted_node_instances):
"""
the install part of the heal mechanism
- :param WorkflowContext context: the workflow context
+ :param WorkflowContext ctx: the workflow context
:param TaskGraph graph: the task graph to edit.
:param failing_node_instances: the failing nodes to heal.
:param targeted_node_instances: the targets of the relationships where the failing node are
@@ -119,17 +129,28 @@ def heal_install(context, graph, failing_node_instances, targeted_node_instances
# Create install sub workflow for each unaffected
for node_instance in targeted_node_instances:
- node_instance_sub_workflow = context.task_graph(
+ node_instance_sub_workflow = task_graph.TaskGraph(
name='install_stub_{0}'.format(node_instance.id))
node_instance_sub_workflows[node_instance.id] = node_instance_sub_workflow
graph.add_tasks(node_instance_sub_workflow)
+ # create install sub workflow for each failing node on the same graph
+ node_instance_sub_workflows = node_instance_sub_workflows or {}
+
# create install sub workflow for every node instance
- install(
- context=context,
- graph=graph,
- node_instances=failing_node_instances,
- node_instance_sub_workflows=node_instance_sub_workflows)
+ for node_instance in failing_node_instances:
+ node_instance_sub_workflow = task.WorkflowTask(install_node_instance,
+ node_instance=node_instance)
+ node_instance_sub_workflows[node_instance.id] = node_instance_sub_workflow
+ graph.add_tasks(node_instance_sub_workflow)
+
+ # create dependencies between the node instance sub workflow
+ for node_instance in failing_node_instances:
+ node_instance_sub_workflow = node_instance_sub_workflows[node_instance.id]
+ if node_instance.relationship_instances:
+ dependencies = [node_instance_sub_workflows[relationship_instance.target_id]
+ for relationship_instance in node_instance.relationship_instances]
+ graph.add_dependency(node_instance_sub_workflow, dependencies)
# Add operations for intact nodes depending on a node instance
# belonging to node_instances
@@ -137,7 +158,7 @@ def heal_install(context, graph, failing_node_instances, targeted_node_instances
node_instance_sub_workflow = node_instance_sub_workflows[node_instance.id]
for relationship_instance in node_instance.relationship_instances:
- target_node_instance = context.model.node_instance.get(relationship_instance.target_id)
+ target_node_instance = ctx.model.node_instance.get(relationship_instance.target_id)
target_node_instance_subworkflow = node_instance_sub_workflows[target_node_instance.id]
graph.add_dependency(node_instance_sub_workflow, target_node_instance_subworkflow)
@@ -146,7 +167,7 @@ def heal_install(context, graph, failing_node_instances, targeted_node_instances
graph=graph,
node_instance=node_instance,
relationship_instance=relationship_instance,
- context=context,
+ context=ctx,
operation_name='aria.interfaces.relationship_lifecycle.establish')
graph.add_dependency(dependent, node_instance_sub_workflow)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/workflows/builtin/install.py
----------------------------------------------------------------------
diff --git a/aria/workflows/builtin/install.py b/aria/workflows/builtin/install.py
index c6b392f..0ab3ad6 100644
--- a/aria/workflows/builtin/install.py
+++ b/aria/workflows/builtin/install.py
@@ -20,13 +20,14 @@ Builtin install workflow
from aria import workflow
from .workflows import install_node_instance
+from ..api import task
@workflow
-def install(context, graph, node_instances=(), node_instance_sub_workflows=None):
+def install(ctx, graph, node_instances=(), node_instance_sub_workflows=None):
"""
The install workflow
- :param WorkflowContext context: the workflow context
+ :param WorkflowContext ctx: the workflow context
:param TaskGraph graph: the graph which will describe the workflow.
:param node_instances: the node instances on which to run the workflow
:param dict node_instance_sub_workflows: a dictionary of subworkflows with id as key and
@@ -34,13 +35,12 @@ def install(context, graph, node_instances=(), node_instance_sub_workflows=None)
:return:
"""
node_instance_sub_workflows = node_instance_sub_workflows or {}
- node_instances = node_instances or list(context.node_instances)
+ node_instances = node_instances or list(ctx.node_instances)
# create install sub workflow for every node instance
for node_instance in node_instances:
- node_instance_sub_workflow = install_node_instance(
- context=context,
- node_instance=node_instance)
+ node_instance_sub_workflow = task.WorkflowTask(install_node_instance,
+ node_instance=node_instance)
node_instance_sub_workflows[node_instance.id] = node_instance_sub_workflow
graph.add_tasks(node_instance_sub_workflow)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/workflows/builtin/uninstall.py
----------------------------------------------------------------------
diff --git a/aria/workflows/builtin/uninstall.py b/aria/workflows/builtin/uninstall.py
index 9557dd8..f4e965c 100644
--- a/aria/workflows/builtin/uninstall.py
+++ b/aria/workflows/builtin/uninstall.py
@@ -20,10 +20,11 @@ Builtin uninstall workflow
from aria import workflow
from .workflows import uninstall_node_instance
+from ..api import task
@workflow
-def uninstall(context, graph, node_instances=(), node_instance_sub_workflows=None):
+def uninstall(ctx, graph, node_instances=(), node_instance_sub_workflows=None):
"""
The uninstall workflow
:param WorkflowContext context: the workflow context
@@ -34,13 +35,12 @@ def uninstall(context, graph, node_instances=(), node_instance_sub_workflows=Non
:return:
"""
node_instance_sub_workflows = node_instance_sub_workflows or {}
- node_instances = node_instances or list(context.node_instances)
+ node_instances = node_instances or list(ctx.node_instances)
# create install sub workflow for every node instance
for node_instance in node_instances:
- node_instance_sub_workflow = uninstall_node_instance(
- context=context,
- node_instance=node_instance)
+ node_instance_sub_workflow = task.WorkflowTask(uninstall_node_instance,
+ node_instance=node_instance)
node_instance_sub_workflows[node_instance.id] = node_instance_sub_workflow
graph.add_tasks(node_instance_sub_workflow)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/workflows/builtin/workflows.py
----------------------------------------------------------------------
diff --git a/aria/workflows/builtin/workflows.py b/aria/workflows/builtin/workflows.py
index 0119e26..4bff7cd 100644
--- a/aria/workflows/builtin/workflows.py
+++ b/aria/workflows/builtin/workflows.py
@@ -21,6 +21,8 @@ from itertools import groupby
from aria import workflow
+from ..api import task
+
__all__ = (
'install_node_instance',
@@ -32,42 +34,43 @@ __all__ = (
# Install node instance workflow and sub workflows
@workflow(suffix_template='{node_instance.id}')
-def install_node_instance(context, graph, node_instance):
+def install_node_instance(ctx, graph, node_instance):
"""
A workflow which installs a node instance.
- :param WorkflowContext context: the workflow context
+ :param WorkflowContext ctx: the workflow context
:param TaskGraph graph: the tasks graph of which to edit
:param node_instance: the node instance to install
:return:
"""
- create_node_instance = context.operation(
+ create_node_instance = task.OperationTask(
name='aria.interfaces.lifecycle.create.{0}'.format(node_instance.id),
- operation_details=node_instance.node.operations[
- 'aria.interfaces.lifecycle.create'],
+ operation_details=node_instance.node.operations['aria.interfaces.lifecycle.create'],
node_instance=node_instance
)
- configure_node_instance = context.operation(
+ configure_node_instance = task.OperationTask(
name='aria.interfaces.lifecycle.configure.{0}'.format(node_instance.id),
operation_details=node_instance.node.operations['aria.interfaces.lifecycle.configure'],
node_instance=node_instance
)
- start_node_instance = context.operation(
+ start_node_instance = task.OperationTask(
name='aria.interfaces.lifecycle.start.{0}'.format(node_instance.id),
- operation_details=node_instance.node.operations[
- 'aria.interfaces.lifecycle.start'],
+ operation_details=node_instance.node.operations['aria.interfaces.lifecycle.start'],
node_instance=node_instance
)
- graph.sequence(create_node_instance,
- preconfigure_relationship(graph, context, node_instance),
- configure_node_instance,
- postconfigure_relationship(graph, context, node_instance),
- start_node_instance,
- establish_relationship(graph, context, node_instance)
- )
+ graph.sequence(
+ create_node_instance,
+ preconfigure_relationship(graph, ctx, node_instance),
+ configure_node_instance,
+ postconfigure_relationship(graph, ctx, node_instance),
+ start_node_instance,
+ establish_relationship(graph, ctx, node_instance)
+ )
+
+ return graph
-def preconfigure_relationship(graph, context, node_instance):
+def preconfigure_relationship(graph, ctx, node_instance):
"""
:param context:
@@ -78,11 +81,11 @@ def preconfigure_relationship(graph, context, node_instance):
return relationships_tasks(
graph=graph,
operation_name='aria.interfaces.relationship_lifecycle.preconfigure',
- context=context,
+ context=ctx,
node_instance=node_instance)
-def postconfigure_relationship(graph, context, node_instance):
+def postconfigure_relationship(graph, ctx, node_instance):
"""
:param context:
@@ -93,11 +96,11 @@ def postconfigure_relationship(graph, context, node_instance):
return relationships_tasks(
graph=graph,
operation_name='aria.interfaces.relationship_lifecycle.postconfigure',
- context=context,
+ context=ctx,
node_instance=node_instance)
-def establish_relationship(graph, context, node_instance):
+def establish_relationship(graph, ctx, node_instance):
"""
:param context:
@@ -108,14 +111,14 @@ def establish_relationship(graph, context, node_instance):
return relationships_tasks(
graph=graph,
operation_name='aria.interfaces.relationship_lifecycle.establish',
- context=context,
+ context=ctx,
node_instance=node_instance)
# Uninstall node instance workflow and subworkflows
@workflow(suffix_template='{node_instance.id}')
-def uninstall_node_instance(graph, context, node_instance):
+def uninstall_node_instance(ctx, graph, node_instance):
"""
A workflow which uninstalls a node instance.
:param WorkflowContext context: the workflow context
@@ -123,27 +126,25 @@ def uninstall_node_instance(graph, context, node_instance):
:param node_instance: the node instance to uninstall
:return:
"""
- stop_node_instance = context.operation(
+ stop_node_instance = task.OperationTask(
name='aria.interfaces.lifecycle.stop.{0}'.format(node_instance.id),
- operation_details=node_instance.node.operations[
- 'aria.interfaces.lifecycle.stop'],
+ operation_details=node_instance.node.operations['aria.interfaces.lifecycle.stop'],
node_instance=node_instance
)
- delete_node_instance = context.operation(
+ delete_node_instance = task.OperationTask(
name='aria.interfaces.lifecycle.delete.{0}'.format(node_instance.id),
- operation_details=node_instance.node.operations[
- 'aria.interfaces.lifecycle.delete'],
+ operation_details=node_instance.node.operations['aria.interfaces.lifecycle.delete'],
node_instance=node_instance
)
graph.sequence(
stop_node_instance,
- unlink_relationship(graph, context, node_instance),
+ unlink_relationship(graph, ctx, node_instance),
delete_node_instance
)
-def unlink_relationship(graph, context, node_instance):
+def unlink_relationship(graph, ctx, node_instance):
"""
:param context:
@@ -154,15 +155,12 @@ def unlink_relationship(graph, context, node_instance):
return relationships_tasks(
graph=graph,
operation_name='aria.interfaces.relationship_lifecycle.unlink',
- context=context,
+ context=ctx,
node_instance=node_instance
)
-@workflow(suffix_template='{node_instance.id}.{operation}')
def execute_operation_on_instance(
- context,
- graph,
node_instance,
operation,
operation_kwargs,
@@ -185,13 +183,12 @@ def execute_operation_on_instance(
node_instance=node_instance,
operation_name=operation)
- graph.add_tasks(
- context.operation(
- name=task_name,
- operation_details=node_instance.node.operations[operation],
- node_instance=node_instance,
- inputs=operation_kwargs)
- )
+ return task.OperationTask(
+ name=task_name,
+ operation_details=node_instance.node.operations[operation],
+ node_instance=node_instance,
+ inputs=operation_kwargs)
+
def relationships_tasks(graph,
@@ -246,12 +243,12 @@ def relationship_tasks(graph,
source_id=node_instance.id,
target_id=relationship_instance.target_id,
)
- source_operation = context.operation(
+ source_operation = task.OperationTask(
name=operation_name_template.format('source'),
node_instance=node_instance,
operation_details=relationship_instance.relationship.source_operations[
operation_name])
- target_operation = context.operation(
+ target_operation = task.OperationTask(
name=operation_name_template.format('target'),
node_instance=context.model.node_instance.get(relationship_instance.target_id),
operation_details=relationship_instance.relationship.target_operations[
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/workflows/core/__init__.py
----------------------------------------------------------------------
diff --git a/aria/workflows/core/__init__.py b/aria/workflows/core/__init__.py
index ae1e83e..08ccff7 100644
--- a/aria/workflows/core/__init__.py
+++ b/aria/workflows/core/__init__.py
@@ -12,3 +12,5 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+
+from . import translation, task
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/workflows/core/executor.py
----------------------------------------------------------------------
diff --git a/aria/workflows/core/executor.py b/aria/workflows/core/executor.py
index 1abecac..0a5cd67 100644
--- a/aria/workflows/core/executor.py
+++ b/aria/workflows/core/executor.py
@@ -18,7 +18,7 @@ Executors for workflow tasks
"""
import threading
-import billiard as multiprocessing
+import multiprocessing
import Queue
import jsonpickle
@@ -134,8 +134,7 @@ class MultiprocessExecutor(BaseExecutor):
self._listener_thread = threading.Thread(target=self._listener)
self._listener_thread.daemon = True
self._listener_thread.start()
- self._pool = multiprocessing.Pool(processes=pool_size,
- maxtasksperchild=1)
+ self._pool = multiprocessing.Pool(processes=pool_size)
def execute(self, task):
self._tasks[task.id] = task
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/workflows/core/task.py
----------------------------------------------------------------------
diff --git a/aria/workflows/core/task.py b/aria/workflows/core/task.py
new file mode 100644
index 0000000..de8a561
--- /dev/null
+++ b/aria/workflows/core/task.py
@@ -0,0 +1,106 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+Workflow tasks
+"""
+
+
+class BaseTask(object):
+ """
+ Base class for Task objects
+ """
+
+ def __init__(self, id):
+ self._id = id
+
+ @property
+ def id(self):
+ """
+ :return: the task's id
+ """
+ return self._id
+
+
+class StartWorkflowTask(BaseTask):
+ """
+ Tasks marking a workflow start
+ """
+ pass
+
+
+class EndWorkflowTask(BaseTask):
+ """
+ Tasks marking a workflow end
+ """
+ pass
+
+
+class StartSubWorkflowTask(BaseTask):
+ """
+ Tasks marking a subworkflow start
+ """
+ pass
+
+
+class EndSubWorkflowTask(BaseTask):
+ """
+ Tasks marking a subworkflow end
+ """
+ pass
+
+
+class OperationTask(BaseTask):
+ """
+ Operation tasks
+ """
+
+ def __init__(self, api_task, *args, **kwargs):
+ self._api_task = api_task
+ self._ctx = api_task.workflow_context
+ super(OperationTask, self).__init__(id=api_task.id)
+ self._create_operation_in_storage()
+
+ @property
+ def ctx(self):
+ """
+ :return: the task's name
+ """
+ return self._ctx
+
+ @property
+ def api_task(self):
+ """
+ :return: the task's context
+ """
+ return self._api_task
+
+ def _create_operation_in_storage(self):
+ task = self.ctx.model.task.model_cls(
+ name=self.api_task.name,
+ operation_details=self.api_task.operation_details,
+ node_instance=self.api_task.node_instance,
+ inputs=self.api_task.operation_kwargs,
+
+ execution_id=self.ctx.execution_id,
+ max_retries=self.ctx.parameters.get('max_retries', 1),
+ )
+ self.ctx.model.task.store(task)
+
+ def __getattr__(self, attr):
+ try:
+ return super(OperationTask, self).__getattribute__(attr)
+ except AttributeError:
+ return getattr(self.context, attr)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/workflows/core/tasks.py
----------------------------------------------------------------------
diff --git a/aria/workflows/core/tasks.py b/aria/workflows/core/tasks.py
deleted file mode 100644
index 76ae609..0000000
--- a/aria/workflows/core/tasks.py
+++ /dev/null
@@ -1,104 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""
-Workflow tasks
-"""
-
-
-class BaseTask(object):
- """
- Base class for Task objects
- """
-
- def __init__(self, id, name, context):
- self._id = id
- self._name = name
- self._context = context
-
- @property
- def id(self):
- """
- :return: the task's id
- """
- return self._id
-
- @property
- def name(self):
- """
- :return: the task's name
- """
- return self._name
-
- @property
- def context(self):
- """
- :return: the task's context
- """
- return self._context
-
-
-class StartWorkflowTask(BaseTask):
- """
- Tasks marking a workflow start
- """
- pass
-
-
-class EndWorkflowTask(BaseTask):
- """
- Tasks marking a workflow end
- """
- pass
-
-
-class StartSubWorkflowTask(BaseTask):
- """
- Tasks marking a subworkflow start
- """
- pass
-
-
-class EndSubWorkflowTask(BaseTask):
- """
- Tasks marking a subworkflow end
- """
- pass
-
-
-class OperationTask(BaseTask):
- """
- Operation tasks
- """
-
- def __init__(self, *args, **kwargs):
- super(OperationTask, self).__init__(*args, **kwargs)
- self._create_operation_in_storage()
-
- def _create_operation_in_storage(self):
- operation_cls = self.context.storage.operation.model_cls
- operation = operation_cls(
- id=self.context.id,
- execution_id=self.context.execution_id,
- max_retries=self.context.parameters.get('max_retries', 1),
- status=operation_cls.PENDING,
- )
- self.context.operation = operation
-
- def __getattr__(self, attr):
- try:
- return getattr(self.context, attr)
- except AttributeError:
- return super(OperationTask, self).__getattribute__(attr)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/aria/workflows/core/translation.py
----------------------------------------------------------------------
diff --git a/aria/workflows/core/translation.py b/aria/workflows/core/translation.py
index f746fb9..ec44f48 100644
--- a/aria/workflows/core/translation.py
+++ b/aria/workflows/core/translation.py
@@ -17,17 +17,15 @@
Translation of user graph's API to the execution graph
"""
-from aria import contexts
-
-from . import tasks
+from . import task
+from .. import api
def build_execution_graph(
task_graph,
- workflow_context,
execution_graph,
- start_cls=tasks.StartWorkflowTask,
- end_cls=tasks.EndWorkflowTask,
+ start_cls=task.StartWorkflowTask,
+ end_cls=task.EndWorkflowTask,
depends_on=()):
"""
Translates the user graph to the execution graph
@@ -39,30 +37,27 @@ def build_execution_graph(
:param depends_on: internal use
"""
# Insert start marker
- start_task = start_cls(id=_start_graph_suffix(task_graph.id),
- name=_start_graph_suffix(task_graph.name),
- context=workflow_context)
+ start_task = start_cls(id=_start_graph_suffix(task_graph.id))
_add_task_and_dependencies(execution_graph, start_task, depends_on)
- for task in task_graph.topological_order(reverse=True):
- dependencies = task_graph.get_dependencies(task)
+ for api_task in task_graph.topological_order(reverse=True):
+ dependencies = task_graph.get_dependencies(api_task)
operation_dependencies = _get_tasks_from_dependencies(
execution_graph,
dependencies,
default=[start_task])
- if _is_operation(task):
+ if _is_operation(api_task):
# Add the task an the dependencies
- operation_task = tasks.OperationTask(id=task.id, name=task.name, context=task)
+ operation_task = task.OperationTask(api_task)
_add_task_and_dependencies(execution_graph, operation_task, operation_dependencies)
else:
# Built the graph recursively while adding start and end markers
build_execution_graph(
- task_graph=task,
- workflow_context=workflow_context,
+ task_graph=api_task,
execution_graph=execution_graph,
- start_cls=tasks.StartSubWorkflowTask,
- end_cls=tasks.EndSubWorkflowTask,
+ start_cls=task.StartSubWorkflowTask,
+ end_cls=task.EndSubWorkflowTask,
depends_on=operation_dependencies
)
@@ -71,10 +66,7 @@ def build_execution_graph(
execution_graph,
_get_non_dependency_tasks(task_graph),
default=[start_task])
- end_task = end_cls(
- id=_end_graph_suffix(task_graph.id),
- name=_end_graph_suffix(task_graph.name),
- context=workflow_context)
+ end_task = end_cls(id=_end_graph_suffix(task_graph.id))
_add_task_and_dependencies(execution_graph, end_task, workflow_dependencies)
@@ -94,7 +86,7 @@ def _get_tasks_from_dependencies(execution_graph, dependencies, default=()):
def _is_operation(task):
- return isinstance(task, contexts.OperationContext)
+ return isinstance(task, api.task.OperationTask)
def _start_graph_suffix(id):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/tests/.pylintrc
----------------------------------------------------------------------
diff --git a/tests/.pylintrc b/tests/.pylintrc
index f6cfd7a..59cca90 100644
--- a/tests/.pylintrc
+++ b/tests/.pylintrc
@@ -62,7 +62,7 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
-disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,redefined-builtin,no-self-use,missing-docstring,attribute-defined-outside-init
+disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,redefined-builtin,no-self-use,missing-docstring,attribute-defined-outside-init,redefined-outer-name,import-error
[REPORTS]
@@ -339,7 +339,7 @@ max-args=15
ignored-argument-names=_.*
# Maximum number of locals for function / method body
-max-locals=15
+max-locals=30
# Maximum number of return / yield for function / method body
max-returns=6
@@ -360,7 +360,7 @@ max-attributes=15
min-public-methods=0
# Maximum number of public methods for a class (see R0904).
-max-public-methods=20
+max-public-methods=50
# Maximum number of boolean expressions in a if statement
max-bool-expr=5
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/tests/mock/__init__.py
----------------------------------------------------------------------
diff --git a/tests/mock/__init__.py b/tests/mock/__init__.py
new file mode 100644
index 0000000..14541d0
--- /dev/null
+++ b/tests/mock/__init__.py
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from . import models, context, operations
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/tests/mock/context.py
----------------------------------------------------------------------
diff --git a/tests/mock/context.py b/tests/mock/context.py
new file mode 100644
index 0000000..71df67c
--- /dev/null
+++ b/tests/mock/context.py
@@ -0,0 +1,36 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from aria import context, application_model_storage
+
+from ..storage import InMemoryModelDriver
+from . import models
+
+
+def simple():
+ """
+ Create the following graph in storage:
+ dependency_node <------ dependent_node
+ :return:
+ """
+ storage = application_model_storage(InMemoryModelDriver())
+ storage.setup()
+ return context.workflow.WorkflowContext(
+ model_storage=storage,
+ resource_storage=None,
+ deployment_id=models.DEPLOYMENT_ID,
+ workflow_id=models.WORKFLOW_ID,
+ execution_id=models.EXECUTION_ID
+ )
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/tests/mock/models.py
----------------------------------------------------------------------
diff --git a/tests/mock/models.py b/tests/mock/models.py
new file mode 100644
index 0000000..633adbb
--- /dev/null
+++ b/tests/mock/models.py
@@ -0,0 +1,132 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from datetime import datetime
+
+from aria.storage import models
+
+from . import operations
+
+DEPLOYMENT_ID = 'test_deployment_id'
+BLUEPRINT_ID = 'test_blueprint_id'
+WORKFLOW_ID = 'test_workflow_id'
+EXECUTION_ID = 'test_execution_id'
+
+
+def get_dependency_node():
+ return models.Node(
+ id='dependency_node',
+ host_id='dependency_node',
+ blueprint_id=BLUEPRINT_ID,
+ type='test_node_type',
+ type_hierarchy=[],
+ number_of_instances=1,
+ planned_number_of_instances=1,
+ deploy_number_of_instances=1,
+ properties={},
+ operations=dict((key, {}) for key in operations.NODE_OPERATIONS),
+ relationships=[],
+ min_number_of_instances=1,
+ max_number_of_instances=1,
+ )
+
+
+def get_dependency_node_instance(dependency_node=None):
+ return models.NodeInstance(
+ id='dependency_node_instance',
+ host_id='dependency_node_instance',
+ deployment_id=DEPLOYMENT_ID,
+ runtime_properties={},
+ version=None,
+ relationship_instances=[],
+ node=dependency_node or get_dependency_node()
+ )
+
+
+def get_relationship(target=None):
+ return models.Relationship(
+ target_id=target.id or get_dependency_node().id,
+ source_interfaces={},
+ source_operations=dict((key, {}) for key in operations.RELATIONSHIP_OPERATIONS),
+ target_interfaces={},
+ target_operations=dict((key, {}) for key in operations.RELATIONSHIP_OPERATIONS),
+ type='rel_type',
+ type_hierarchy=[],
+ properties={},
+ )
+
+
+def get_relationship_instance(target_instance=None, relationship=None):
+ return models.RelationshipInstance(
+ target_id=target_instance.id or get_dependency_node_instance().id,
+ target_name='test_target_name',
+ type='some_type',
+ relationship=relationship or get_relationship(target_instance.node
+ if target_instance else None)
+ )
+
+
+def get_dependent_node(relationship=None):
+ return models.Node(
+ id='dependent_node',
+ host_id='dependent_node',
+ blueprint_id=BLUEPRINT_ID,
+ type='test_node_type',
+ type_hierarchy=[],
+ number_of_instances=1,
+ planned_number_of_instances=1,
+ deploy_number_of_instances=1,
+ properties={},
+ operations=dict((key, {}) for key in operations.NODE_OPERATIONS),
+ relationships=[relationship or get_relationship()],
+ min_number_of_instances=1,
+ max_number_of_instances=1,
+ )
+
+
+def get_dependent_node_instance(relationship_instance, dependent_node=None):
+ return models.NodeInstance(
+ id='dependent_node_instance',
+ host_id='dependent_node_instance',
+ deployment_id=DEPLOYMENT_ID,
+ runtime_properties={},
+ version=None,
+ relationship_instances=[relationship_instance or get_relationship_instance()],
+ node=dependent_node or get_dependency_node()
+ )
+
+
+def get_execution():
+ return models.Execution(
+ id=EXECUTION_ID,
+ status=models.Execution.STARTED,
+ deployment_id=DEPLOYMENT_ID,
+ workflow_id=WORKFLOW_ID,
+ blueprint_id=BLUEPRINT_ID,
+ started_at=datetime.now(),
+ parameters=None
+ )
+
+
+def get_deployment():
+ now = datetime.now()
+ return models.Deployment(
+ id=DEPLOYMENT_ID,
+ description=None,
+ created_at=now,
+ updated_at=now,
+ blueprint_id=BLUEPRINT_ID,
+ workflows={}
+ )
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/tests/mock/operations.py
----------------------------------------------------------------------
diff --git a/tests/mock/operations.py b/tests/mock/operations.py
new file mode 100644
index 0000000..407061f
--- /dev/null
+++ b/tests/mock/operations.py
@@ -0,0 +1,33 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+NODE_OPERATIONS_INSTALL = [
+ 'aria.interfaces.lifecycle.create',
+ 'aria.interfaces.lifecycle.configure',
+ 'aria.interfaces.lifecycle.start',
+ ]
+NODE_OPERATIONS_UNINSTALL = [
+ 'aria.interfaces.lifecycle.stop',
+ 'aria.interfaces.lifecycle.delete',
+]
+NODE_OPERATIONS = NODE_OPERATIONS_INSTALL + NODE_OPERATIONS_UNINSTALL
+
+RELATIONSHIP_OPERATIONS_INSTALL = [
+ 'aria.interfaces.relationship_lifecycle.preconfigure',
+ 'aria.interfaces.relationship_lifecycle.postconfigure',
+ 'aria.interfaces.relationship_lifecycle.establish',
+ ]
+RELATIONSHIP_OPERATIONS_UNINSTALL = ['aria.interfaces.relationship_lifecycle.unlink']
+RELATIONSHIP_OPERATIONS = RELATIONSHIP_OPERATIONS_INSTALL + RELATIONSHIP_OPERATIONS_UNINSTALL
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/tests/test_logger.py
----------------------------------------------------------------------
diff --git a/tests/test_logger.py b/tests/test_logger.py
index 7891dd6..37731bb 100644
--- a/tests/test_logger.py
+++ b/tests/test_logger.py
@@ -80,7 +80,7 @@ def test_create_file_log_handler():
assert handler.baseFilename == temp_file.name
assert handler.maxBytes == 5 * 1000 * 1024
assert handler.backupCount == 10
- assert handler.delay is True
+ assert handler.stream is None
assert handler.level == logging.DEBUG
assert handler.formatter == _default_file_formatter
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9002019e/tests/workflows/__init__.py
----------------------------------------------------------------------
diff --git a/tests/workflows/__init__.py b/tests/workflows/__init__.py
index ae1e83e..fe04b2f 100644
--- a/tests/workflows/__init__.py
+++ b/tests/workflows/__init__.py
@@ -12,3 +12,5 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+
+from . import api, builtin, core