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 2017/02/09 14:49:12 UTC

[09/11] incubator-ariatosca git commit: added private fields back to the models

added private fields back to the models


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

Branch: refs/heads/ARIA-44-Merge-parser-and-storage-models
Commit: 7dc3692469aa6d726b07d0fd50187194b4b46eee
Parents: 2b3276b
Author: mxmrlv <mx...@gmail.com>
Authored: Wed Feb 8 21:00:56 2017 +0200
Committer: mxmrlv <mx...@gmail.com>
Committed: Thu Feb 9 13:20:30 2017 +0200

----------------------------------------------------------------------
 aria/storage/modeling/instance_elements.py     | 42 ++++++++++++++++++++-
 aria/storage/modeling/orchestrator_elements.py | 13 +++++--
 aria/storage/modeling/structure.py             |  2 +-
 aria/storage/modeling/template_elements.py     | 39 +++++++++++++++++++
 4 files changed, 91 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7dc36924/aria/storage/modeling/instance_elements.py
----------------------------------------------------------------------
diff --git a/aria/storage/modeling/instance_elements.py b/aria/storage/modeling/instance_elements.py
index 9c5e750..7b8fe14 100644
--- a/aria/storage/modeling/instance_elements.py
+++ b/aria/storage/modeling/instance_elements.py
@@ -41,6 +41,9 @@ from . import (
 class ServiceInstanceBase(structure.ModelMixin):
     __tablename__ = 'service_instance'
 
+    __private_fields__ = ['substituion_fk',
+                          'service_template_fk']
+
     description = Column(Text)
     _metadata = Column(Text)
 
@@ -166,6 +169,10 @@ class OperationBase(structure.ModelMixin):
     * :code:`inputs`: Dict of :class:`Parameter`
     """
     __tablename__ = 'operation'
+
+    __private_fields__ = ['service_template_fk',
+                          'interface_instance_fk']
+
     # region foreign_keys
 
     @declared_attr
@@ -254,6 +261,12 @@ class InterfaceBase(structure.ModelMixin):
     * :code:`operations`: Dict of :class:`Operation`
     """
     __tablename__ = 'interface'
+
+    __private_fields__ = ['group_fk',
+                          'node_fk',
+                          'relationship_fk']
+
+
     # region foreign_keys
     @declared_attr
     def group_fk(cls):
@@ -346,6 +359,9 @@ class CapabilityBase(structure.ModelMixin):
     * :code:`properties`: Dict of :class:`Parameter`
     """
     __tablename__ = 'capability'
+
+    __private_fields__ = ['node_fk']
+
     # region foreign_keys
     @declared_attr
     def node_fk(cls):
@@ -358,7 +374,6 @@ class CapabilityBase(structure.ModelMixin):
     max_occurrences = Column(Integer, default=None) # optional
     occurrences = Column(Integer, default=0)
 
-
     # region many-to-one relationships
     @declared_attr
     def node(cls):
@@ -435,6 +450,9 @@ class ArtifactBase(structure.ModelMixin):
     * :code:`properties`: Dict of :class:`Parameter`
     """
     __tablename__ = 'artifact'
+
+    __private_fields__ = ['node_fk']
+
     # region foreign_keys
 
     @declared_attr
@@ -519,7 +537,11 @@ class PolicyBase(structure.ModelMixin):
     * :code:`target_group_ids`: Must be represented in the :class:`ServiceInstance`
     """
     __tablename__ = 'policy'
+
+    __private_fields__ = ['service_instance_fk']
+
     # region foreign_keys
+
     @declared_attr
     def service_instance_fk(cls):
         return cls.foreign_key('service_instance')
@@ -592,7 +614,11 @@ class GroupPolicyBase(structure.ModelMixin):
     * :code:`triggers`: Dict of :class:`GroupPolicyTrigger`
     """
     __tablename__ = 'group_policy'
+
+    __private_fields__ = ['group_fk']
+
     # region foreign_keys
+
     @declared_attr
     def group_fk(cls):
         return cls.foreign_key('group')
@@ -662,6 +688,9 @@ class GroupPolicyTriggerBase(structure.ModelMixin):
     * :code:`properties`: Dict of :class:`Parameter`
     """
     __tablename__ = 'group_policy_trigger'
+
+    __private_fields__ = ['group_policy_fk']
+
     # region foreign keys
 
     @declared_attr
@@ -752,6 +781,7 @@ class SubstitutionBase(structure.ModelMixin):
     * :code:`requirements`: Dict of :class:`Mapping`
     """
     __tablename__ = 'substitution'
+
     node_type_name = Column(Text)
 
     # region many-to-many relationships
@@ -822,6 +852,10 @@ class NodeBase(structure.ModelMixin):
     """
     __tablename__ = 'node'
 
+    __private_fields__ = ['service_instance_fk',
+                          'host_fk',
+                          'node_template_fk']
+
     # region foreign_keys
     @declared_attr
     def service_instance_fk(cls):
@@ -1035,6 +1069,9 @@ class GroupBase(structure.ModelMixin):
     * :code:`member_group_ids`: Must be represented in the :class:`ServiceInstance`
     """
     __tablename__ = 'group'
+
+    __private_fields__ = ['service_instance_fk']
+
     # region foreign_keys
 
     @declared_attr
@@ -1128,6 +1165,9 @@ class RelationshipBase(structure.ModelMixin):
     """
     __tablename__ = 'relationship'
 
+    __private_fields__ = ['source_node_fk',
+                          'target_node_fk']
+
     source_requirement_index = Column(Integer)
     target_node_id = Column(Text)
     target_capability_name = Column(Text)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7dc36924/aria/storage/modeling/orchestrator_elements.py
----------------------------------------------------------------------
diff --git a/aria/storage/modeling/orchestrator_elements.py b/aria/storage/modeling/orchestrator_elements.py
index a7ed5e9..5aaf02f 100644
--- a/aria/storage/modeling/orchestrator_elements.py
+++ b/aria/storage/modeling/orchestrator_elements.py
@@ -76,6 +76,8 @@ class Execution(ModelMixin):
     # Needed only for pylint. the id will be populated by sqlalcehmy and the proper column.
     __tablename__ = 'execution'
 
+    __private_fields__ = ['service_instance_fk']
+
     TERMINATED = 'terminated'
     FAILED = 'failed'
     CANCELLED = 'cancelled'
@@ -155,6 +157,8 @@ class ServiceInstanceUpdateBase(ModelMixin):
     steps = None
 
     __tablename__ = 'service_instance_update'
+    __private_fields__ = ['service_instance_fk',
+                          'execution_fk']
 
     _private_fields = ['execution_fk', 'deployment_fk']
 
@@ -203,7 +207,7 @@ class ServiceInstanceUpdateStepBase(ModelMixin):
     """
     # Needed only for pylint. the id will be populated by sqlalcehmy and the proper column.
     __tablename__ = 'service_instance_update_step'
-    _private_fields = ['deployment_update_fk']
+    __private_fields__ = ['service_instance_update_fk']
 
     _action_types = namedtuple('ACTION_TYPES', 'ADD, REMOVE, MODIFY')
     ACTION_TYPES = _action_types(ADD='add', REMOVE='remove', MODIFY='modify')
@@ -275,7 +279,7 @@ class ServiceInstanceModificationBase(ModelMixin):
     Deployment modification model representation.
     """
     __tablename__ = 'service_instance_modification'
-    _private_fields = ['deployment_fk']
+    __private_fields__ = ['service_instance_fk']
 
     STARTED = 'started'
     FINISHED = 'finished'
@@ -329,7 +333,10 @@ class TaskBase(ModelMixin):
     A Model which represents an task
     """
     __tablename__ = 'task'
-    _private_fields = ['node_instance_fk', 'relationship_instance_fk', 'execution_fk']
+    __private_fields__ = ['node_fk',
+                          'relationship_fk',
+                          'execution_fk',
+                          'plugin_fk']
 
     @declared_attr
     def node_fk(cls):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7dc36924/aria/storage/modeling/structure.py
----------------------------------------------------------------------
diff --git a/aria/storage/modeling/structure.py b/aria/storage/modeling/structure.py
index 386887e..eacdb44 100644
--- a/aria/storage/modeling/structure.py
+++ b/aria/storage/modeling/structure.py
@@ -299,7 +299,7 @@ class ModelMixin(ModelElementBase):
         """
         fields = set(cls._association_proxies())
         fields.update(cls.__table__.columns.keys())
-        return fields - set(getattr(cls, '_private_fields', []))
+        return fields - set(getattr(cls, '__private_fields__', []))
 
     def __repr__(self):
         return '<{__class__.__name__} id=`{id}`>'.format(

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7dc36924/aria/storage/modeling/template_elements.py
----------------------------------------------------------------------
diff --git a/aria/storage/modeling/template_elements.py b/aria/storage/modeling/template_elements.py
index 17cc292..b4ba031 100644
--- a/aria/storage/modeling/template_elements.py
+++ b/aria/storage/modeling/template_elements.py
@@ -45,6 +45,8 @@ class ServiceTemplateBase(structure.ModelMixin):
 
     __tablename__ = 'service_template'
 
+    __private_fields__ = ['substitution_template_fk']
+
     description = Column(Text)
     metadata = Column(Text)
 
@@ -172,6 +174,10 @@ class ServiceTemplateBase(structure.ModelMixin):
 
 class InterfaceTemplateBase(structure.ModelMixin):
     __tablename__ = 'interface_template'
+
+    __private_fields__ = ['node_template_fk',
+                          'group_template_fk']
+
     # region foreign keys
 
     @declared_attr
@@ -253,6 +259,9 @@ class InterfaceTemplateBase(structure.ModelMixin):
 class OperationTemplateBase(structure.ModelMixin):
     __tablename__ = 'operation_template'
 
+    __private_fields__ = ['service_template_fk',
+                          'interface_template_fk']
+
     # region foreign keys
 
     @declared_attr
@@ -358,6 +367,9 @@ class ArtifactTemplateBase(structure.ModelMixin):
     * :code:`properties`: Dict of :class:`Parameter`
     """
     __tablename__ = 'artifact_template'
+
+    __private_fields__ = ['node_template_fk']
+
     # region foreign keys
 
     @declared_attr
@@ -451,7 +463,12 @@ class PolicyTemplateBase(structure.ModelMixin):
     * :code:`target_group_template_names`: Must be represented in the :class:`ServiceModel`
     """
     __tablename__ = 'policy_template'
+
+    __private_fields__ = ['service_templaet_fk',
+                          'group_template_fk']
+
     # region foreign keys
+
     @declared_attr
     def service_template_fk(cls):
         return cls.foreign_key('service_template')
@@ -547,6 +564,9 @@ class GroupPolicyTemplateBase(structure.ModelMixin):
     """
 
     __tablename__ = 'group_policy_template'
+
+    __private_fields__ = ['group_template_fk']
+
     # region foreign keys
     @declared_attr
     def group_template_fk(cls):
@@ -616,7 +636,11 @@ class GroupPolicyTriggerTemplateBase(structure.ModelMixin):
     * :code:`properties`: Dict of :class:`Parameter`
     """
     __tablename__ = 'group_policy_trigger_template'
+
+    __private_fields__ = ['group_policy_template_fk']
+
     # region foreign keys
+
     @declared_attr
     def group_policy_template_fk(cls):
         return cls.foreign_key('group_policy_template')
@@ -794,7 +818,11 @@ class SubstitutionTemplateBase(structure.ModelMixin):
 class NodeTemplateBase(structure.ModelMixin):
     __tablename__ = 'node_template'
 
+    __private_fields__ = ['service_template_fk',
+                          'host_fk']
+
     # region foreign_keys
+
     @declared_attr
     def service_template_fk(cls):
         return cls.foreign_key('service_template')
@@ -930,6 +958,9 @@ class GroupTemplateBase(structure.ModelMixin):
     * :code:`member_group_template_names`: Must be represented in the :class:`ServiceModel`
     """
     __tablename__ = 'group_template'
+
+    __private_fields__ = ['service_template_fk']
+
     # region foreign keys
 
     @declared_attr
@@ -1037,7 +1068,11 @@ class RequirementTemplateBase(structure.ModelMixin):
     * :code:`relationship_template`: :class:`RelationshipTemplate`
     """
     __tablename__ = 'requirement_template'
+
+    __private_fields__ = ['node_template_fk']
+
     # region foreign keys
+
     @declared_attr
     def node_template_fk(cls):
         return cls.foreign_key('node_template', nullable=True)
@@ -1195,7 +1230,11 @@ class CapabilityTemplateBase(structure.ModelMixin):
     * :code:`properties`: Dict of :class:`Parameter`
     """
     __tablename__ = 'capability_template'
+
+    __private_fields__ = ['node_template_fk']
+
     # region foreign keys
+
     @declared_attr
     def node_template_fk(cls):
         return cls.foreign_key('node_template', nullable=True)