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/12/14 19:58:53 UTC
incubator-ariatosca git commit: reinstated foreign keys
Repository: incubator-ariatosca
Updated Branches:
refs/heads/ARIA-39-Genericize-storage-models c0499229f -> 89dfdb61c
reinstated foreign keys
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/89dfdb61
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/89dfdb61
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/89dfdb61
Branch: refs/heads/ARIA-39-Genericize-storage-models
Commit: 89dfdb61cd10eea90d95e43647afc1d273acd7dc
Parents: c049922
Author: mxmrlv <mx...@gmail.com>
Authored: Wed Dec 14 21:58:42 2016 +0200
Committer: mxmrlv <mx...@gmail.com>
Committed: Wed Dec 14 21:58:42 2016 +0200
----------------------------------------------------------------------
aria/orchestrator/context/workflow.py | 5 +-
aria/orchestrator/workflows/builtin/heal.py | 2 +-
aria/orchestrator/workflows/core/engine.py | 3 +-
aria/orchestrator/workflows/core/task.py | 2 +-
aria/storage/models_base.py | 201 ++++++++++++-------
aria/storage/structures.py | 47 +++--
tests/mock/models.py | 25 +--
tests/orchestrator/context/test_toolbelt.py | 8 +-
.../orchestrator/workflows/builtin/test_heal.py | 4 +-
.../orchestrator/workflows/core/test_engine.py | 4 +-
tests/storage/test_models.py | 80 ++++----
11 files changed, 231 insertions(+), 150 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/89dfdb61/aria/orchestrator/context/workflow.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/context/workflow.py b/aria/orchestrator/context/workflow.py
index e2e8e25..f5ba86b 100644
--- a/aria/orchestrator/context/workflow.py
+++ b/aria/orchestrator/context/workflow.py
@@ -46,8 +46,7 @@ class WorkflowContext(BaseContext):
execution_cls = self.model.execution.model_cls
now = datetime.utcnow()
execution = self.model.execution.model_cls(
- blueprint_id=self.blueprint.id,
- deployment_id=self.deployment.id,
+ deployment=self.deployment,
workflow_name=self._workflow_name,
created_at=now,
status=execution_cls.PENDING,
@@ -88,7 +87,7 @@ class WorkflowContext(BaseContext):
"""
return self.model.node_instance.iter(
filters={
- 'deployment_id': self.deployment.id
+ 'deployment_id': getattr(self.deployment, self.deployment.user_id_column)
}
)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/89dfdb61/aria/orchestrator/workflows/builtin/heal.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/builtin/heal.py b/aria/orchestrator/workflows/builtin/heal.py
index de07095..dcf398c 100644
--- a/aria/orchestrator/workflows/builtin/heal.py
+++ b/aria/orchestrator/workflows/builtin/heal.py
@@ -34,7 +34,7 @@ def heal(ctx, graph, node_instance_id):
:return:
"""
failing_node = ctx.model.node_instance.get(node_instance_id)
- host_node = ctx.model.node_instance.get(failing_node.host_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)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/89dfdb61/aria/orchestrator/workflows/core/engine.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/core/engine.py b/aria/orchestrator/workflows/core/engine.py
index 2d26aeb..2f0b3f1 100644
--- a/aria/orchestrator/workflows/core/engine.py
+++ b/aria/orchestrator/workflows/core/engine.py
@@ -103,7 +103,8 @@ class Engine(logger.LoggerMixin):
for _, data in self._execution_graph.nodes_iter(data=True):
task = data['task']
if isinstance(task, engine_task.OperationTask):
- self._workflow_context.model.task.refresh(task.model_task)
+ if task.model_task.status not in models.Task.END_STATES:
+ self._workflow_context.model.task.refresh(task.model_task)
yield task
def _handle_executable_task(self, task):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/89dfdb61/aria/orchestrator/workflows/core/task.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/core/task.py b/aria/orchestrator/workflows/core/task.py
index 0be17fe..d381916 100644
--- a/aria/orchestrator/workflows/core/task.py
+++ b/aria/orchestrator/workflows/core/task.py
@@ -121,7 +121,7 @@ class OperationTask(BaseTask):
operation_task = task_model_cls(
name=api_task.name,
operation_mapping=api_task.operation_mapping,
- instance_id=api_task.actor.id,
+ instance_fk=api_task.actor.id,
inputs=api_task.inputs,
status=base_task_model.PENDING,
max_attempts=api_task.max_attempts,
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/89dfdb61/aria/storage/models_base.py
----------------------------------------------------------------------
diff --git a/aria/storage/models_base.py b/aria/storage/models_base.py
index e9a27b1..95ad01e 100644
--- a/aria/storage/models_base.py
+++ b/aria/storage/models_base.py
@@ -39,6 +39,8 @@ classes:
from collections import namedtuple
from datetime import datetime
+from sqlalchemy.ext.associationproxy import association_proxy
+
from .structures import (
Column,
Integer,
@@ -79,6 +81,8 @@ __all__ = (
class ModelCommon(object):
id = Column(Integer, primary_key=True, autoincrement=True)
+ storage_id_column = 'id'
+ user_id_column = 'name'
class BlueprintBase(object):
@@ -101,7 +105,7 @@ class DeploymentBase(object):
"""
__tablename__ = 'deployments'
- _private_fields = ['blueprint_id']
+ _private_fields = ['blueprint_fk']
name = Column(Text, index=True)
created_at = Column(DateTime, nullable=False, index=True)
@@ -112,17 +116,21 @@ class DeploymentBase(object):
policy_triggers = Column(Dict)
policy_types = Column(Dict)
outputs = Column(Dict)
- scaling_groups = Column(Dict)
+ scaling_groups = Column(List)
updated_at = Column(DateTime)
workflows = Column(List)
@declared_attr
- def blueprint_id(cls):
- return foreign_key('blueprints.id', nullable=False)
+ def blueprint_fk(cls):
+ return foreign_key(cls, 'blueprints', nullable=False)
@declared_attr
def blueprint(cls):
- return one_to_many_relationship(cls, 'blueprint_id', 'Blueprint')
+ return one_to_many_relationship(cls, 'blueprint_fk', 'Blueprint')
+
+ @declared_attr
+ def blueprint_id(cls):
+ return association_proxy('blueprint', cls.user_id_column)
class ExecutionBase(object):
@@ -177,23 +185,22 @@ class ExecutionBase(object):
is_system_workflow = Column(Boolean, nullable=False, default=False)
parameters = Column(Dict)
status = Column(Enum(*STATES, name='execution_status'), default=PENDING)
- workflow_name = Column(Text, nullable=False)
+ workflow_name = Column(Text)
- @declared_attr
- def deployment_id(cls):
- return foreign_key('deployments.id')
+ blueprint = association_proxy('deployment', 'blueprint')
+ blueprint_id = association_proxy('deployment', 'blueprint_id')
@declared_attr
- def deployment(cls):
- return one_to_many_relationship(cls, 'deployment_id', 'Deployment')
+ def deployment_fk(cls):
+ return foreign_key(cls, 'deployments', nullable=False)
@declared_attr
- def blueprint_id(cls):
- return foreign_key('blueprints.id')
+ def deployment(cls):
+ return one_to_many_relationship(cls, 'deployment_fk', 'Deployment')
@declared_attr
- def blueprint(cls):
- return one_to_many_relationship(cls, 'blueprint_id', 'Blueprint')
+ def deployment_id(cls):
+ return association_proxy('deployment', cls.user_id_column)
def __str__(self):
return '<{0} id=`{1}` (status={2})>'.format(
@@ -223,20 +230,28 @@ class DeploymentUpdateBase(object):
state = Column(Text)
@declared_attr
+ def execution_fk(cls):
+ return foreign_key(cls, 'executions', nullable=True)
+
+ @declared_attr
def execution_id(cls):
- return foreign_key('executions.id', nullable=True)
+ return association_proxy('executions', cls.user_id_column)
@declared_attr
def execution(cls):
- return one_to_many_relationship(cls, 'execution_id', 'Execution')
+ return one_to_many_relationship(cls, 'execution_fk', 'Execution')
+
+ @declared_attr
+ def deployment_fk(cls):
+ return foreign_key(cls, 'deployments')
@declared_attr
def deployment_id(cls):
- return foreign_key('deployments.id')
+ return association_proxy('deployment', cls.user_id_column)
@declared_attr
def deployment(cls):
- return one_to_many_relationship(cls, 'deployment_id', 'Deployment')
+ return one_to_many_relationship(cls, 'deployment_fk', 'Deployment')
def to_dict(self, suppress_error=False, **kwargs):
dep_update_dict = super(DeploymentUpdateBase, self).to_dict(suppress_error) #pylint: disable=no-member
@@ -281,13 +296,17 @@ class DeploymentUpdateStepBase(object):
entity_type = Column(Enum(*ENTITY_TYPES, name='entity_type'), nullable=False)
@declared_attr
+ def deployment_update_fk(cls):
+ return foreign_key(cls, 'deployment_updates')
+
+ @declared_attr
def deployment_update_id(cls):
- return foreign_key('deployment_updates.id')
+ return association_proxy('deployment_updates', cls.user_id_column)
@declared_attr
def deployment_update(cls):
return one_to_many_relationship(cls,
- 'deployment_update_id',
+ 'deployment_update_fk',
'DeploymentUpdate',
backreference='steps')
@@ -343,12 +362,16 @@ class DeploymentModificationBase(object):
@declared_attr
def deployment_id(cls):
- return foreign_key('deployments.id')
+ return association_proxy('deployment', cls.user_id_column)
+
+ @declared_attr
+ def deployment_fk(cls):
+ return foreign_key(cls, 'deployments')
@declared_attr
def deployment(cls):
return one_to_many_relationship(cls,
- 'deployment_id',
+ 'deployment_fk',
'Deployment',
backreference='modifications')
@@ -362,31 +385,39 @@ class NodeBase(object):
# See base class for an explanation on these properties
is_id_unique = False
- name = Column(Text, index=True)
_private_fields = ['deployment_id', 'host_id']
@declared_attr
def host_id(cls):
- return foreign_key('nodes.id', nullable=True)
+ return association_proxy('host', cls.user_id_column)
+
+ @declared_attr
+ def host_fk(cls):
+ return foreign_key(cls, 'nodes', nullable=True)
@declared_attr
def host(cls):
- return relationship_to_self(cls, 'host_id')
+ return relationship_to_self(cls, 'host_fk')
@declared_attr
def deployment_id(cls):
- return foreign_key('deployments.id')
+ return association_proxy('deployment', cls.user_id_column)
+
+ @declared_attr
+ def deployment_fk(cls):
+ return foreign_key(cls, 'deployments')
@declared_attr
def deployment(cls):
- return one_to_many_relationship(cls, 'deployment_id', 'Deployment')
+ return one_to_many_relationship(cls, 'deployment_fk', 'Deployment')
+ name = Column(Text, index=True)
deploy_number_of_instances = Column(Integer, nullable=False)
max_number_of_instances = Column(Integer, nullable=False)
min_number_of_instances = Column(Integer, nullable=False)
number_of_instances = Column(Integer, nullable=False)
planned_number_of_instances = Column(Integer, nullable=False)
- plugins = Column(Dict)
+ plugins = Column(List)
plugins_to_install = Column(Dict)
properties = Column(Dict)
operations = Column(Dict)
@@ -403,26 +434,33 @@ class RelationshipBase(object):
_private_fields = ['source_node_id', 'target_node_id']
@declared_attr
- def source_node_id(cls):
- return foreign_key('nodes.id')
+ def source_id(cls):
+ return association_proxy('source_node', cls.user_id_column)
+
+ @declared_attr
+ def source_node_fk(cls):
+ return foreign_key(cls, 'nodes')
@declared_attr
def source_node(cls):
return one_to_many_relationship(cls,
- 'source_node_id',
+ 'source_node_fk',
'Node',
- 'outbound_relationships')
+ backreference='outbound_relationships')
+ @declared_attr
+ def target_name(cls):
+ return association_proxy('target_node', cls.user_id_column)
@declared_attr
- def target_node_id(cls):
- return foreign_key('nodes.id')
+ def target_node_fk(cls):
+ return foreign_key(cls, 'nodes')
@declared_attr
def target_node(cls):
return one_to_many_relationship(cls,
- 'target_node_id',
+ 'target_node_fk',
'Node',
- 'inbound_relationships')
+ backreference='inbound_relationships')
source_interfaces = Column(Dict)
source_operations = Column(Dict, nullable=False)
@@ -442,33 +480,37 @@ class NodeInstanceBase(object):
name = Column(Text, index=True)
runtime_properties = Column(Dict)
- scaling_groups = Column(Dict)
+ scaling_groups = Column(List)
state = Column(Text, nullable=False)
version = Column(Integer, default=1)
@declared_attr
def host_id(cls):
- return foreign_key('node_instances.id', nullable=True)
+ return association_proxy('host', cls.user_id_column)
@declared_attr
- def host(cls):
- return relationship_to_self(cls, 'host_id')
+ def host_fk(cls):
+ return foreign_key(cls, 'node_instances', nullable=True)
@declared_attr
- def deployment_id(cls):
- return foreign_key('deployments.id')
+ def host(cls):
+ return relationship_to_self(cls, 'host_fk')
- @declared_attr
- def deployment(cls):
- return one_to_many_relationship(cls, 'deployment_id', 'Deployment')
+ deployment = association_proxy('node', 'deployment')
+ deployment_id = association_proxy('node', 'deployment_id')
+ deployment_name = association_proxy('node', 'deployment_name')
@declared_attr
def node_id(cls):
- return foreign_key('nodes.id')
+ return association_proxy('node', cls.user_id_column)
+
+ @declared_attr
+ def node_fk(cls):
+ return foreign_key(cls, 'nodes', nullable=True)
@declared_attr
def node(cls):
- return one_to_many_relationship(cls, 'node_id', 'Node')
+ return one_to_many_relationship(cls, 'node_fk', 'Node')
class RelationshipInstanceBase(object):
@@ -482,33 +524,45 @@ class RelationshipInstanceBase(object):
@declared_attr
def source_node_instance_id(cls):
- return foreign_key('node_instances.id')
+ return association_proxy('source_node_instance', cls.user_id_column)
+
+ @declared_attr
+ def source_node_instance_fk(cls):
+ return foreign_key(cls, 'node_instances')
@declared_attr
def source_node_instance(cls):
return one_to_many_relationship(cls,
- 'source_node_instance_id',
+ 'source_node_instance_fk',
'NodeInstance',
- 'outbound_relationship_instances')
+ backreference='outbound_relationship_instances')
@declared_attr
def target_node_instance_id(cls):
- return foreign_key('node_instances.id')
+ return association_proxy('target_node_instance', cls.user_id_column)
+
+ @declared_attr
+ def target_node_instance_fk(cls):
+ return foreign_key(cls, 'node_instances')
@declared_attr
def target_node_instance(cls):
return one_to_many_relationship(cls,
- 'target_node_instance_id',
+ 'target_node_instance_fk',
'NodeInstance',
- 'inbound_relationship_instances')
+ backreference='inbound_relationship_instances')
+
+ @declared_attr
+ def relationship_fk(cls):
+ return foreign_key(cls, 'relationships')
@declared_attr
def relationship_id(cls):
- return foreign_key('relationships.id')
+ return association_proxy('relationship', cls.user_id_column)
@declared_attr
def relationship(cls):
- return one_to_many_relationship(cls, 'relationship_id', 'Relationship')
+ return one_to_many_relationship(cls, 'relationship_fk', 'Relationship')
class ProviderContextBase(object):
@@ -517,7 +571,8 @@ class ProviderContextBase(object):
"""
__tablename__ = 'provider_context'
- name = Column(Text, nullable=False)
+ name = Column(Text, nullable=True)
+ id = Column(Text, nullable=False)
context = Column(Dict, nullable=False)
@@ -550,25 +605,29 @@ class TaskBase(object):
'relationship_instance_id',
'execution_id']
+ @declared_attr
+ def node_instance_fk(cls):
+ return foreign_key(cls, 'node_instances', nullable=True)
@declared_attr
def node_instance_id(cls):
- return foreign_key('node_instances.id', nullable=True)
+ return association_proxy('node_instance', cls.user_id_column)
@declared_attr
def node_instance(cls):
- return one_to_many_relationship(cls, 'node_instance_id', 'NodeInstance')
+ return one_to_many_relationship(cls, 'node_instance_fk', 'NodeInstance')
+ @declared_attr
+ def relationship_instance_fk(cls):
+ return foreign_key(cls, 'relationship_instances', nullable=True)
@declared_attr
def relationship_instance_id(cls):
- return foreign_key('relationship_instances.id', nullable=True)
+ return association_proxy('relationship_instance', cls.user_id_column)
@declared_attr
def relationship_instance(cls):
- return one_to_many_relationship(cls,
- 'relationship_instance_id',
- 'RelationshipInstance')
+ return one_to_many_relationship(cls, 'relationship_instance_fk', 'RelationshipInstance')
PENDING = 'pending'
RETRYING = 'retrying'
@@ -614,12 +673,16 @@ class TaskBase(object):
inputs = Column(Dict)
@declared_attr
+ def execution_fk(cls):
+ return foreign_key(cls, 'executions', nullable=True)
+
+ @declared_attr
def execution_id(cls):
- return foreign_key('executions.id', nullable=True)
+ return association_proxy('execution', cls.user_id_column)
@declared_attr
def execution(cls):
- return one_to_many_relationship(cls, 'execution_id', 'Execution')
+ return one_to_many_relationship(cls, 'execution_fk', 'Execution')
@property
def actor(self):
@@ -630,9 +693,9 @@ class TaskBase(object):
return self.node_instance or self.relationship_instance
@classmethod
- def as_node_instance(cls, instance_id, **kwargs):
- return cls(node_instance_id=instance_id, **kwargs)
+ def as_node_instance(cls, instance_fk, **kwargs):
+ return cls(node_instance_fk=instance_fk, **kwargs)
@classmethod
- def as_relationship_instance(cls, instance_id, **kwargs):
- return cls(relationship_instance_id=instance_id, **kwargs)
+ def as_relationship_instance(cls, instance_fk, **kwargs):
+ return cls(relationship_instance_fk=instance_fk, **kwargs)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/89dfdb61/aria/storage/structures.py
----------------------------------------------------------------------
diff --git a/aria/storage/structures.py b/aria/storage/structures.py
index c3d78db..6949305 100644
--- a/aria/storage/structures.py
+++ b/aria/storage/structures.py
@@ -55,16 +55,31 @@ from sqlalchemy import (
from aria.storage import exceptions
-def foreign_key(foreign_key_column, nullable=False):
+def _get_cls_by_tablename(cls, tablename):
+ """Return class reference mapped to table.
+
+ :param tablename: String with name of table.
+ :return: Class reference or None.
+ """
+ if tablename in (cls.__name__, cls.__tablename__):
+ return cls
+
+ for table_cls in cls._decl_class_registry.values():
+ if tablename in (getattr(table_cls, '__name__', None),
+ getattr(table_cls, '__tablename__', None)):
+ return table_cls
+
+
+def foreign_key(child_class, tablename, nullable=False):
"""Return a ForeignKey object with the relevant
- :param foreign_key_column: Unique id column in the parent table
+ :param tablename: Unique id column in the parent table
:param nullable: Should the column be allowed to remain empty
"""
- return Column(
- ForeignKey(foreign_key_column, ondelete='CASCADE'),
- nullable=nullable
- )
+ table = _get_cls_by_tablename(child_class, tablename)
+ foreign_key_str = '{tablename}.{unique_id}'.format(tablename=tablename,
+ unique_id=table.storage_id_column)
+ return Column(ForeignKey(foreign_key_str, ondelete='CASCADE'), nullable=nullable)
def one_to_many_relationship(child_class,
@@ -79,11 +94,15 @@ def one_to_many_relationship(child_class,
:param foreign_key_column: The column of the foreign key (from the child table)
:param backreference: The name to give to the reference to the child (on the parent table)
"""
- primaryjoin_str = '{parent_class_name}.id == {child_class.__name__}.{foreign_key_column}'\
- .format(parent_class_name=parent_class,
- child_class=child_class,
- foreign_key_column=foreign_key_column
- )
+ parent_table = _get_cls_by_tablename(child_class, parent_class)
+ primaryjoin_str = \
+ '{parent_class_name}.{parent_unique_id} == {child_class.__name__}.{foreign_key_column}'\
+ .format(
+ parent_class_name=parent_class,
+ parent_unique_id=parent_table.storage_id_column,
+ child_class=child_class,
+ foreign_key_column=foreign_key_column
+ )
return relationship(
parent_class,
primaryjoin=primaryjoin_str,
@@ -93,8 +112,10 @@ def one_to_many_relationship(child_class,
)
-def relationship_to_self(cls, local_column, remote_column='id'):
- remote_side_str = '{cls.__name__}.{remote_column}'.format(cls=cls, remote_column=remote_column)
+def relationship_to_self(cls, local_column):
+
+ remote_side_str = '{cls.__name__}.{remote_column}'.format(cls=cls,
+ remote_column=cls.storage_id_column)
primaryjoin_str = '{remote_side_str} == {cls.__name__}.{local_column}'.format(
remote_side_str=remote_side_str,
cls=cls,
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/89dfdb61/tests/mock/models.py
----------------------------------------------------------------------
diff --git a/tests/mock/models.py b/tests/mock/models.py
index e2e3d2f..aeda7ca 100644
--- a/tests/mock/models.py
+++ b/tests/mock/models.py
@@ -46,7 +46,7 @@ def get_dependency_node(deployment):
operations=dict((key, {}) for key in operations.NODE_OPERATIONS),
min_number_of_instances=1,
max_number_of_instances=1,
- deployment_id=deployment.id
+ deployment_fk=deployment.id
)
@@ -55,8 +55,7 @@ def get_dependency_node_instance(dependency_node):
name=DEPENDENCY_NODE_INSTANCE_NAME,
runtime_properties={'ip': '1.1.1.1'},
version=None,
- node_id=dependency_node.id,
- deployment_id=dependency_node.deployment.id,
+ node_fk=dependency_node.id,
state='',
scaling_groups={}
)
@@ -64,8 +63,8 @@ def get_dependency_node_instance(dependency_node):
def get_relationship(source=None, target=None):
return models.Relationship(
- source_node_id=source.id,
- target_node_id=target.id,
+ source_node_fk=source.id,
+ target_node_fk=target.id,
source_interfaces={},
source_operations=dict((key, {}) for key in operations.RELATIONSHIP_OPERATIONS),
target_interfaces={},
@@ -78,16 +77,16 @@ def get_relationship(source=None, target=None):
def get_relationship_instance(source_instance, target_instance, relationship):
return models.RelationshipInstance(
- relationship_id=relationship.id,
- target_node_instance_id=target_instance.id,
- source_node_instance_id=source_instance.id,
+ relationship_fk=relationship.id,
+ target_node_instance_fk=target_instance.id,
+ source_node_instance_fk=source_instance.id,
)
def get_dependent_node(deployment):
return models.Node(
name=DEPENDENT_NODE_NAME,
- deployment_id=deployment.id,
+ deployment_fk=deployment.id,
type='test_node_type',
type_hierarchy=[],
number_of_instances=1,
@@ -105,8 +104,7 @@ def get_dependent_node_instance(dependent_node):
name=DEPENDENT_NODE_INSTANCE_NAME,
runtime_properties={},
version=None,
- node_id=dependent_node.id,
- deployment_id=dependent_node.deployment.id,
+ node_fk=dependent_node.id,
state='',
scaling_groups={}
)
@@ -126,8 +124,7 @@ def get_blueprint():
def get_execution(deployment):
return models.Execution(
- deployment_id=deployment.id,
- blueprint_id=deployment.blueprint.id,
+ deployment_fk=deployment.id,
status=models.Execution.STARTED,
workflow_name=WORKFLOW_NAME,
started_at=datetime.utcnow(),
@@ -139,7 +136,7 @@ def get_deployment(blueprint):
now = datetime.utcnow()
return models.Deployment(
name=DEPLOYMENT_NAME,
- blueprint_id=blueprint.id,
+ blueprint_fk=blueprint.id,
description='',
created_at=now,
updated_at=now,
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/89dfdb61/tests/orchestrator/context/test_toolbelt.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/test_toolbelt.py b/tests/orchestrator/context/test_toolbelt.py
index da46696..6f24ca5 100644
--- a/tests/orchestrator/context/test_toolbelt.py
+++ b/tests/orchestrator/context/test_toolbelt.py
@@ -49,21 +49,21 @@ def executor():
def _get_elements(workflow_context):
dependency_node = workflow_context.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME)
- dependency_node.host_id = dependency_node.id
+ dependency_node.host_fk = dependency_node.id
workflow_context.model.node.update(dependency_node)
dependency_node_instance = workflow_context.model.node_instance.get_by_name(
mock.models.DEPENDENCY_NODE_INSTANCE_NAME)
- dependency_node_instance.host_id = dependency_node_instance.id
+ dependency_node_instance.host_fk = dependency_node_instance.id
workflow_context.model.node_instance.update(dependency_node_instance)
dependent_node = workflow_context.model.node.get_by_name(mock.models.DEPENDENT_NODE_NAME)
- dependent_node.host_id = dependency_node.id
+ dependent_node.host_fk = dependency_node.id
workflow_context.model.node.update(dependent_node)
dependent_node_instance = workflow_context.model.node_instance.get_by_name(
mock.models.DEPENDENT_NODE_INSTANCE_NAME)
- dependent_node_instance.host_id = dependent_node_instance.id
+ dependent_node_instance.host_fk = dependent_node_instance.id
workflow_context.model.node_instance.update(dependent_node_instance)
relationship = workflow_context.model.relationship.list()[0]
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/89dfdb61/tests/orchestrator/workflows/builtin/test_heal.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/builtin/test_heal.py b/tests/orchestrator/workflows/builtin/test_heal.py
index 97121b9..ad281fd 100644
--- a/tests/orchestrator/workflows/builtin/test_heal.py
+++ b/tests/orchestrator/workflows/builtin/test_heal.py
@@ -34,7 +34,7 @@ def ctx(tmpdir):
def test_heal_dependent_node(ctx):
dependent_node_instance = \
ctx.model.node_instance.get_by_name(mock.models.DEPENDENT_NODE_INSTANCE_NAME)
- dependent_node_instance.host_id = dependent_node_instance.id
+ dependent_node_instance.host_fk = dependent_node_instance.id
ctx.model.node_instance.update(dependent_node_instance)
heal_graph = task.WorkflowTask(heal, ctx=ctx, node_instance_id=dependent_node_instance.id)
@@ -63,7 +63,7 @@ def test_heal_dependent_node(ctx):
def test_heal_dependency_node(ctx):
dependency_node_instance = \
ctx.model.node_instance.get_by_name(mock.models.DEPENDENCY_NODE_INSTANCE_NAME)
- dependency_node_instance.host_id = dependency_node_instance.id
+ dependency_node_instance.host_fk = dependency_node_instance.id
ctx.model.node_instance.update(dependency_node_instance)
heal_graph = task.WorkflowTask(heal, ctx=ctx, node_instance_id=dependency_node_instance.id)
# both subgraphs should contain un\install for both the dependent and the dependency
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/89dfdb61/tests/orchestrator/workflows/core/test_engine.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/core/test_engine.py b/tests/orchestrator/workflows/core/test_engine.py
index baded7f..44f7cc1 100644
--- a/tests/orchestrator/workflows/core/test_engine.py
+++ b/tests/orchestrator/workflows/core/test_engine.py
@@ -116,7 +116,9 @@ class BaseTest(object):
@pytest.fixture
def executor(self):
- result = thread.ThreadExecutor()
+ from aria.orchestrator.workflows.executor import blocking
+ result = blocking.CurrentThreadBlockingExecutor()
+ # result = thread.ThreadExecutor()
try:
yield result
finally:
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/89dfdb61/tests/storage/test_models.py
----------------------------------------------------------------------
diff --git a/tests/storage/test_models.py b/tests/storage/test_models.py
index 454a003..2985eca 100644
--- a/tests/storage/test_models.py
+++ b/tests/storage/test_models.py
@@ -73,7 +73,7 @@ def _deployment_storage():
def _deployment_update_storage():
storage = _deployment_storage()
deployment_update = DeploymentUpdate(
- deployment_id=storage.deployment.list()[0].id,
+ deployment=storage.deployment.list()[0],
created_at=now,
deployment_plan={},
)
@@ -209,32 +209,32 @@ class TestDeployment(object):
'is_valid, name, created_at, description, inputs, groups, permalink, policy_triggers, '
'policy_types, outputs, scaling_groups, updated_at, workflows',
[
- (False, m_cls, now, 'desc', {}, {}, 'perlnk', {}, {}, {}, {}, now, {}),
- (False, 'name', m_cls, 'desc', {}, {}, 'perlnk', {}, {}, {}, {}, now, {}),
- (False, 'name', now, m_cls, {}, {}, 'perlnk', {}, {}, {}, {}, now, {}),
- (False, 'name', now, 'desc', m_cls, {}, 'perlnk', {}, {}, {}, {}, now, {}),
- (False, 'name', now, 'desc', {}, m_cls, 'perlnk', {}, {}, {}, {}, now, {}),
- (False, 'name', now, 'desc', {}, {}, m_cls, {}, {}, {}, {}, now, {}),
- (False, 'name', now, 'desc', {}, {}, 'perlnk', m_cls, {}, {}, {}, now, {}),
- (False, 'name', now, 'desc', {}, {}, 'perlnk', {}, m_cls, {}, {}, now, {}),
- (False, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, m_cls, {}, now, {}),
+ (False, m_cls, now, 'desc', {}, {}, 'perlnk', {}, {}, {}, [], now, {}),
+ (False, 'name', m_cls, 'desc', {}, {}, 'perlnk', {}, {}, {}, [], now, {}),
+ (False, 'name', now, m_cls, {}, {}, 'perlnk', {}, {}, {}, [], now, {}),
+ (False, 'name', now, 'desc', m_cls, {}, 'perlnk', {}, {}, {}, [], now, {}),
+ (False, 'name', now, 'desc', {}, m_cls, 'perlnk', {}, {}, {}, [], now, {}),
+ (False, 'name', now, 'desc', {}, {}, m_cls, {}, {}, {}, [], now, {}),
+ (False, 'name', now, 'desc', {}, {}, 'perlnk', m_cls, {}, {}, [], now, {}),
+ (False, 'name', now, 'desc', {}, {}, 'perlnk', {}, m_cls, {}, [], now, {}),
+ (False, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, m_cls, [], now, {}),
(False, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, m_cls, now, {}),
- (False, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, {}, m_cls, {}),
- (False, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, {}, now, m_cls),
-
- (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, {}, now, {}),
- (True, None, now, 'desc', {}, {}, 'perlnk', {}, {}, {}, {}, now, {}),
- (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, {}, now, {}),
- (True, 'name', now, None, {}, {}, 'perlnk', {}, {}, {}, {}, now, {}),
- (True, 'name', now, 'desc', None, {}, 'perlnk', {}, {}, {}, {}, now, {}),
- (True, 'name', now, 'desc', {}, None, 'perlnk', {}, {}, {}, {}, now, {}),
- (True, 'name', now, 'desc', {}, {}, None, {}, {}, {}, {}, now, {}),
- (True, 'name', now, 'desc', {}, {}, 'perlnk', None, {}, {}, {}, now, {}),
- (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, None, {}, {}, now, {}),
- (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, None, {}, now, {}),
+ (False, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, [], m_cls, {}),
+ (False, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, [], now, m_cls),
+
+ (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, [], now, {}),
+ (True, None, now, 'desc', {}, {}, 'perlnk', {}, {}, {}, [], now, {}),
+ (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, [], now, {}),
+ (True, 'name', now, None, {}, {}, 'perlnk', {}, {}, {}, [], now, {}),
+ (True, 'name', now, 'desc', None, {}, 'perlnk', {}, {}, {}, [], now, {}),
+ (True, 'name', now, 'desc', {}, None, 'perlnk', {}, {}, {}, [], now, {}),
+ (True, 'name', now, 'desc', {}, {}, None, {}, {}, {}, [], now, {}),
+ (True, 'name', now, 'desc', {}, {}, 'perlnk', None, {}, {}, [], now, {}),
+ (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, None, {}, [], now, {}),
+ (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, None, [], now, {}),
(True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, None, now, {}),
- (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, {}, None, {}),
- (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, {}, now, None),
+ (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, [], None, {}),
+ (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, [], now, None),
]
)
def test_deployment_model_creation(self, deployment_storage, is_valid, name, created_at,
@@ -247,7 +247,7 @@ class TestDeployment(object):
model_cls=Deployment,
model_kwargs=dict(
name=name,
- blueprint_id=deployment_storage.blueprint.list()[0].id,
+ blueprint=deployment_storage.blueprint.list()[0],
created_at=created_at,
description=description,
inputs=inputs,
@@ -293,8 +293,7 @@ class TestExecution(object):
model_name='execution',
model_cls=Execution,
model_kwargs=dict(
- deployment_id=deployment_storage.deployment.list()[0].id,
- blueprint_id=deployment_storage.blueprint.list()[0].id,
+ deployment=deployment_storage.deployment.list()[0],
created_at=created_at,
started_at=started_at,
ended_at=ended_at,
@@ -404,7 +403,7 @@ class TestDeploymentUpdate(object):
model_name='deployment_update',
model_cls=DeploymentUpdate,
model_kwargs=dict(
- deployment_id=deployment_storage.deployment.list()[0].id,
+ deployment=deployment_storage.deployment.list()[0],
created_at=created_at,
deployment_plan=deployment_plan,
deployment_update_node_instances=deployment_update_node_instances,
@@ -439,7 +438,7 @@ class TestDeploymentUpdateStep(object):
model_name='deployment_update_step',
model_cls=DeploymentUpdateStep,
model_kwargs=dict(
- deployment_update_id=deployment_update_storage.deployment_update.list()[0].id,
+ deployment_update=deployment_update_storage.deployment_update.list()[0],
action=action,
entity_id=entity_id,
entity_type=entity_type
@@ -515,7 +514,7 @@ class TestDeploymentModification(object):
model_name='deployment_modification',
model_cls=DeploymentModification,
model_kwargs=dict(
- deployment_id=deployment_storage.deployment.list()[0].id,
+ deployment=deployment_storage.deployment.list()[0],
context=context,
created_at=created_at,
ended_at=ended_at,
@@ -578,7 +577,7 @@ class TestNode(object):
operations=operations,
type=type,
type_hierarchy=type_hierarchy,
- deployment_id=deployment_storage.deployment.list()[0].id
+ deployment=deployment_storage.deployment.list()[0]
))
if is_valid:
assert node.deployment == deployment_storage.deployment.list()[0]
@@ -613,8 +612,8 @@ class TestRelationship(object):
model_name='relationship',
model_cls=Relationship,
model_kwargs=dict(
- source_node_id=nodes_storage.node.list()[1].id,
- target_node_id=nodes_storage.node.list()[0].id,
+ source_node=nodes_storage.node.list()[1],
+ target_node=nodes_storage.node.list()[0],
source_interfaces=source_interfaces,
source_operations=source_operations,
target_interfaces=target_interfaces,
@@ -653,8 +652,7 @@ class TestNodeInstance(object):
model_name='node_instance',
model_cls=NodeInstance,
model_kwargs=dict(
- node_id=node_storage.node.list()[0].id,
- deployment_id=node_storage.deployment.list()[0].id,
+ node=node_storage.node.list()[0],
name=name,
runtime_properties=runtime_properties,
scaling_groups=scaling_groups,
@@ -683,9 +681,9 @@ class TestRelationshipInstance(object):
model_name='relationship_instance',
model_cls=RelationshipInstance,
model_kwargs=dict(
- relationship_id=relationship.id,
- source_node_instance_id=source_node_instance.id,
- target_node_instance_id=target_node_instance.id
+ relationship=relationship,
+ source_node_instance=source_node_instance,
+ target_node_instance=target_node_instance
))
assert relationship_instance.relationship == relationship
assert relationship_instance.source_node_instance == source_node_instance
@@ -808,7 +806,7 @@ class TestTask(object):
model_cls=Task,
model_kwargs=dict(
status=status,
- execution_id=execution_storage.execution.list()[0].id,
+ execution=execution_storage.execution.list()[0],
due_at=due_at,
started_at=started_at,
ended_at=ended_at,
@@ -825,7 +823,7 @@ class TestTask(object):
def test_task_max_attempts_validation(self):
def create_task(max_attempts):
- Task(execution_id='eid',
+ Task(execution_fk='eid',
name='name',
operation_mapping='',
inputs={},