ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxm...@apache.org
Subject incubator-ariatosca git commit: review 1
Date Thu, 22 Dec 2016 12:35:34 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-39-Genericize-storage-models 8614c9a92 -> 9fe443f12


review 1


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/9fe443f1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/9fe443f1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/9fe443f1

Branch: refs/heads/ARIA-39-Genericize-storage-models
Commit: 9fe443f12095aeb68fbc734c72e7781ebf8162fe
Parents: 8614c9a
Author: mxmrlv <mxmrlv@gmail.com>
Authored: Thu Dec 22 14:35:21 2016 +0200
Committer: mxmrlv <mxmrlv@gmail.com>
Committed: Thu Dec 22 14:35:21 2016 +0200

----------------------------------------------------------------------
 aria/orchestrator/context/workflow.py       |  8 ++++----
 aria/orchestrator/workflows/builtin/heal.py |  9 ++++-----
 aria/storage/base_model.py                  |  2 +-
 aria/storage/structure.py                   | 10 ++++++----
 tests/storage/test_model_storage.py         |  6 ++++++
 5 files changed, 21 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9fe443f1/aria/orchestrator/context/workflow.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/context/workflow.py b/aria/orchestrator/context/workflow.py
index 387ca02..0299ea0 100644
--- a/aria/orchestrator/context/workflow.py
+++ b/aria/orchestrator/context/workflow.py
@@ -85,11 +85,11 @@ class WorkflowContext(BaseContext):
         """
         Iterator over nodes
         """
-        key = 'deployment_{0}'.format(self.model.node_instance.model_cls.name_column_name())
+        key = 'deployment_{0}'.format(self.model.node.model_cls.id_column_name())
 
         return self.model.node.iter(
             filters={
-                key: getattr(self.deployment, self.deployment.name_column_name())
+                key: getattr(self.deployment, self.deployment.id_column_name())
             }
         )
 
@@ -98,10 +98,10 @@ class WorkflowContext(BaseContext):
         """
         Iterator over node instances
         """
-        key = 'deployment_{0}'.format(self.model.node_instance.model_cls.name_column_name())
+        key = 'deployment_{0}'.format(self.model.node_instance.model_cls.id_column_name())
         return self.model.node_instance.iter(
             filters={
-                key: getattr(self.deployment, self.deployment.name_column_name())
+                key: getattr(self.deployment, self.deployment.id_column_name())
             }
         )
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9fe443f1/aria/orchestrator/workflows/builtin/heal.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/builtin/heal.py b/aria/orchestrator/workflows/builtin/heal.py
index 406a42a..21da2ed 100644
--- a/aria/orchestrator/workflows/builtin/heal.py
+++ b/aria/orchestrator/workflows/builtin/heal.py
@@ -163,11 +163,10 @@ def heal_install(ctx, graph, failing_node_instances, targeted_node_instances):
 
 
 def _get_contained_subgraph(context, host_node_instance):
-    contained_instances = [
-        node_instance
-        for node_instance in context.node_instances
-        if node_instance == host_node_instance and node_instance != node_instance
-        ]
+    contained_instances = [node_instance
+                           for node_instance in context.node_instances
+                           if node_instance.host_fk == host_node_instance.id and
+                           node_instance.host_fk != node_instance.id]
     result = [host_node_instance]
 
     if not contained_instances:

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9fe443f1/aria/storage/base_model.py
----------------------------------------------------------------------
diff --git a/aria/storage/base_model.py b/aria/storage/base_model.py
index 701bc83..9162c56 100644
--- a/aria/storage/base_model.py
+++ b/aria/storage/base_model.py
@@ -665,7 +665,7 @@ class TaskBase(ModelMixin):
         """
         Return the actor of the task
         :return:
-      `  """
+        """
         return self.node_instance or self.relationship_instance
 
     @classmethod

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9fe443f1/aria/storage/structure.py
----------------------------------------------------------------------
diff --git a/aria/storage/structure.py b/aria/storage/structure.py
index 3f09560..c307041 100644
--- a/aria/storage/structure.py
+++ b/aria/storage/structure.py
@@ -39,6 +39,8 @@ from sqlalchemy import (
 
 class ModelMixin(object):
 
+    # _private_fields = []
+
     @classmethod
     def id_column_name(cls):
         raise NotImplementedError
@@ -69,12 +71,12 @@ class ModelMixin(object):
         :param table: Unique id column in the parent table
         :param nullable: Should the column be allowed to remain empty
         """
-        table = cls._get_cls_by_tablename(table.__tablename__)
-        foreign_key_str = '{tablename}.{unique_id}'.format(tablename=table.__tablename__,
-                                                           unique_id=table.id_column_name())
+        table_cls = cls._get_cls_by_tablename(table.__tablename__)
+        foreign_key_str = '{tablename}.{unique_id}'.format(tablename=table_cls.__tablename__,
+                                                           unique_id=table_cls.id_column_name())
         column = Column(ForeignKey(foreign_key_str, ondelete='CASCADE'),
                         nullable=nullable)
-        column.__remote_table_name = table.__name__
+        column.__remote_table_name = table_cls.__name__
         return column
 
     @classmethod

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9fe443f1/tests/storage/test_model_storage.py
----------------------------------------------------------------------
diff --git a/tests/storage/test_model_storage.py b/tests/storage/test_model_storage.py
index 6f9527e..4991d19 100644
--- a/tests/storage/test_model_storage.py
+++ b/tests/storage/test_model_storage.py
@@ -130,6 +130,12 @@ def test_model_to_dict():
     assert 'blueprint_fk' not in deployment_dict
 
 
+def test_missing_private_fields():
+    mock_model = MockModel()
+    with pytest.raises(AttributeError):
+        mock_model.to_dict()
+
+
 def test_application_storage_factory():
     storage = application_model_storage(sql_mapi.SQLAlchemyModelAPI,
                                         api_kwargs=get_sqlite_api_kwargs())


Mime
View raw message