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 [Forced Update!]
Date Thu, 22 Dec 2016 12:42:22 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-39-Genericize-storage-models 9fe443f12 -> 602760e5f (forced update)


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/602760e5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/602760e5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/602760e5

Branch: refs/heads/ARIA-39-Genericize-storage-models
Commit: 602760e5f42473fc61bb60c5e4d8c1f52f9bc41d
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:41:43 2016 +0200

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


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/602760e5/aria/orchestrator/context/workflow.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/context/workflow.py b/aria/orchestrator/context/workflow.py
index 387ca02..a15790e 100644
--- a/aria/orchestrator/context/workflow.py
+++ b/aria/orchestrator/context/workflow.py
@@ -85,7 +85,7 @@ 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.name_column_name())
 
         return self.model.node.iter(
             filters={

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/602760e5/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/602760e5/aria/orchestrator/workflows/core/task.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/core/task.py b/aria/orchestrator/workflows/core/task.py
index 6e23895..67be2ea 100644
--- a/aria/orchestrator/workflows/core/task.py
+++ b/aria/orchestrator/workflows/core/task.py
@@ -122,10 +122,9 @@ class OperationTask(BaseTask):
         plugins = model_storage.plugin.list(filters={
             'package_name': plugin.get('package_name', ''),
             'package_version': plugin.get('package_version', '')
-        }, include=['id'])
+        })
         # Validation during installation ensures that at most one plugin can exists with
provided
         # package_name and package_version
-        plugin_id = plugins[0].id if plugins else None
         operation_task = task_model_cls(
             name=api_task.name,
             operation_mapping=api_task.operation_mapping,
@@ -135,7 +134,7 @@ class OperationTask(BaseTask):
             max_attempts=api_task.max_attempts,
             retry_interval=api_task.retry_interval,
             ignore_failure=api_task.ignore_failure,
-            plugin_fk=plugin_id,
+            plugin=plugins[0] if plugins else None,
             execution=self._workflow_context.execution
         )
         self._workflow_context.model.task.put(operation_task)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/602760e5/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/602760e5/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/602760e5/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