ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From emblempar...@apache.org
Subject incubator-ariatosca git commit: Document backreferences (and fix for many-to-many)
Date Sun, 05 Mar 2017 19:45:28 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-105-integrate-modeling 24ad8ba1e -> 5ceb14cd4


Document backreferences (and fix for many-to-many)


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

Branch: refs/heads/ARIA-105-integrate-modeling
Commit: 5ceb14cd43a04703aee0c78b79018217bdf25494
Parents: 24ad8ba
Author: Tal Liron <tal.liron@gmail.com>
Authored: Sun Mar 5 13:45:11 2017 -0600
Committer: Tal Liron <tal.liron@gmail.com>
Committed: Sun Mar 5 13:45:11 2017 -0600

----------------------------------------------------------------------
 aria/modeling/bases.py            |   2 +-
 aria/modeling/orchestration.py    |   3 +-
 aria/modeling/service.py          | 102 +++++++++++++++++++++++++++++----
 aria/modeling/service_template.py |  76 ++++++++++++++++++++++++
 4 files changed, 169 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5ceb14cd/aria/modeling/bases.py
----------------------------------------------------------------------
diff --git a/aria/modeling/bases.py b/aria/modeling/bases.py
index 7fe218d..a4db320 100644
--- a/aria/modeling/bases.py
+++ b/aria/modeling/bases.py
@@ -199,7 +199,7 @@ class ModelMixin(object):
         helper_table = '{0}_{1}'.format(this_table, other_table)
 
         if backreference is None:
-            backreference = this_table
+            backreference = formatting.pluralize(this_table)
             if table_prefix:
                 helper_table = '{0}_{1}'.format(table_prefix, helper_table)
                 backreference = '{0}_{1}'.format(table_prefix, backreference)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5ceb14cd/aria/modeling/orchestration.py
----------------------------------------------------------------------
diff --git a/aria/modeling/orchestration.py b/aria/modeling/orchestration.py
index 30879e9..8428b69 100644
--- a/aria/modeling/orchestration.py
+++ b/aria/modeling/orchestration.py
@@ -174,7 +174,8 @@ class ServiceUpdateBase(ModelMixin):
 
     @declared_attr
     def service(cls):
-        return cls.many_to_one_relationship('service')
+        return cls.many_to_one_relationship('service',
+                                            backreference='updates')
 
     @declared_attr
     def service_name(cls):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5ceb14cd/aria/modeling/service.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service.py b/aria/modeling/service.py
index 842d0fc..eb8acb5 100644
--- a/aria/modeling/service.py
+++ b/aria/modeling/service.py
@@ -69,6 +69,18 @@ class ServiceBase(InstanceModelMixin): # pylint: disable=too-many-public-methods
     :vartype created_at: :class:`datetime.datetime`
     :ivar updated_at: Update timestamp
     :vartype updated_at: :class:`datetime.datetime`
+
+    :ivar permalink: ??
+    :vartype permalink: basestring
+    :ivar scaling_groups: ??
+    :vartype scaling_groups: {}
+
+    :ivar modifications: Modifications of this service
+    :vartype modifications: [:class:`ServiceModification`]
+    :ivar updates: Updates of this service
+    :vartype updates: [:class:`ServiceUpdate`]
+    :ivar executions: Executions on this service
+    :vartype executions: [:class:`Execution`]
     """
 
     __tablename__ = 'service'
@@ -304,6 +316,26 @@ class NodeBase(InstanceModelMixin):
     :vartype plugins: {basestring: :class:`Plugin`}
     :ivar host: Host node (can be self)
     :vartype host: :class:`Node`
+
+    :ivar runtime_properties: TODO: should be replaced with attributes
+    :vartype runtime_properties: {}
+    :ivar scaling_groups: ??
+    :vartype scaling_groups: []
+    :ivar state: ??
+    :vartype state: basestring
+    :ivar version: ??
+    :vartype version: int
+
+    :ivar service: Containing service
+    :vartype service: :class:`Service`
+    :ivar groups: We are a member of these groups
+    :vartype groups: [:class:`Group`]
+    :ivar policies: Policies enacted on this node
+    :vartype policies: [:class:`Policy`]
+    :ivar substitution_mapping: Our contribution to service substitution
+    :vartype substitution_mapping: :class:`SubstitutionMapping`
+    :ivar tasks: Tasks on this node
+    :vartype tasks: [:class:`Task`]
     """
 
     __tablename__ = 'node'
@@ -558,6 +590,11 @@ class GroupBase(InstanceModelMixin):
     :vartype properties: {basestring: :class:`Parameter`}
     :ivar interfaces: Bundles of operations
     :vartype interfaces: {basestring: :class:`Interface`}
+
+    :ivar service: Containing service
+    :vartype service: :class:`Service`
+    :ivar policies: Policies enacted on this group
+    :vartype policies: [:class:`Policy`]
     """
 
     __tablename__ = 'group'
@@ -654,6 +691,9 @@ class PolicyBase(InstanceModelMixin):
     :vartype groups: [:class:`Group`]
     :ivar properties: Associated parameters
     :vartype properties: {basestring: :class:`Parameter`}
+
+    :ivar service: Containing service
+    :vartype service: :class:`Service`
     """
 
     __tablename__ = 'policy'
@@ -746,6 +786,9 @@ class SubstitutionBase(InstanceModelMixin):
     :vartype node_type: :class:`Type`
     :ivar mappings: Requirement and capability mappings
     :vartype mappings: {basestring: :class:`SubstitutionTemplate`}
+
+    :ivar service: Containing service
+    :vartype service: :class:`Service`
     """
 
     __tablename__ = 'substitution'
@@ -814,6 +857,9 @@ class SubstitutionMappingBase(InstanceModelMixin):
     :vartype capability: :class:`Capability`
     :ivar requirement_template: Requirement template in the node template
     :vartype requirement_template: :class:`RequirementTemplate`
+
+    :ivar substitution: Containing substitution
+    :vartype substitution: :class:`Substitution`
     """
 
     __tablename__ = 'substitution_mapping'
@@ -891,18 +937,28 @@ class RelationshipBase(InstanceModelMixin):
     :vartype name: basestring
     :ivar relationship_template: Template from which this relationship was instantiated (optional)
     :vartype relationship_template: :class:`RelationshipTemplate`
+    :ivar requirement_template: Template from which this relationship was instantiated (optional)
+    :vartype requirement_template: :class:`RequirementTemplate`
     :ivar type: Relationship type
     :vartype type: :class:`Type`
-    :ivar source_node: Source node
-    :vartype source_node: :class:`Node`
-    :ivar target_node: Target node
-    :vartype target_node: :class:`Node`
     :ivar target_capability: Capability at the target node (optional)
     :vartype target_capability: :class:`Capability`
     :ivar properties: Associated parameters
     :vartype properties: {basestring: :class:`Parameter`}
-    :ivar interface_templates: Bundles of operations
-    :vartype interface_templates: {basestring: :class:`InterfaceTemplate`}
+    :ivar interfaces: Bundles of operations
+    :vartype interfaces: {basestring: :class:`Interfaces`}
+
+    :ivar source_position: ??
+    :vartype source_position: int
+    :ivar target_position: ??
+    :vartype target_position: int
+
+    :ivar source_node: Source node
+    :vartype source_node: :class:`Node`
+    :ivar target_node: Target node
+    :vartype target_node: :class:`Node`
+    :ivar tasks: Tasks on this node
+    :vartype tasks: [:class:`Task`]
     """
 
     __tablename__ = 'relationship'
@@ -912,6 +968,10 @@ class RelationshipBase(InstanceModelMixin):
         return cls.many_to_one_relationship('relationship_template')
 
     @declared_attr
+    def requirement_template(cls):
+        return cls.many_to_one_relationship('requirement_template')
+
+    @declared_attr
     def type(cls):
         return cls.many_to_one_relationship('type')
 
@@ -928,10 +988,6 @@ class RelationshipBase(InstanceModelMixin):
     def interfaces(cls):
         return cls.one_to_many_relationship('interface', dict_key='name')
 
-    @declared_attr
-    def requirement_template(cls):
-        return cls.many_to_one_relationship('requirement_template')
-
     # region orchestration
 
     source_position = Column(Integer) # ???
@@ -944,7 +1000,7 @@ class RelationshipBase(InstanceModelMixin):
     __private_fields__ = ['type_fk',
                           'source_node_fk',
                           'target_node_fk',
-                          'capability_fk',
+                          'target_capability_fk',
                           'requirement_template_fk',
                           'relationship_template_fk']
 
@@ -965,7 +1021,7 @@ class RelationshipBase(InstanceModelMixin):
 
     # Relationship one-to-one to Capability
     @declared_attr
-    def capability_fk(cls):
+    def target_capability_fk(cls):
         return cls.foreign_key('capability', nullable=True)
 
     # Relationship many-to-one to RequirementTemplate
@@ -1037,6 +1093,13 @@ class CapabilityBase(InstanceModelMixin):
     :vartype occurrences: int
     :ivar properties: Associated parameters
     :vartype properties: {basestring: :class:`Parameter`}
+
+    :ivar node: Containing node
+    :vartype node: :class:`Node`
+    :ivar relationship: Available when we are the target of a relationship
+    :vartype relationship: :class:`Relationship`
+    :ivar substitution_mapping: Our contribution to service substitution
+    :vartype substitution_mapping: :class:`SubstitutionMapping`
     """
 
     __tablename__ = 'capability'
@@ -1138,6 +1201,13 @@ class InterfaceBase(InstanceModelMixin):
     :vartype inputs: {basestring: :class:`Parameter`}
     :ivar operations: Operations
     :vartype operations: {basestring: :class:`Operation`}
+
+    :ivar node: Containing node
+    :vartype node: :class:`Node`
+    :ivar group: Containing group
+    :vartype group: :class:`Group`
+    :ivar relationship: Containing relationship
+    :vartype relationship: :class:`Relationship`
     """
 
     __tablename__ = 'interface'
@@ -1249,6 +1319,11 @@ class OperationBase(InstanceModelMixin):
     :vartype max_retries: int
     :ivar retry_interval: Interval between retries (in seconds)
     :vartype retry_interval: int
+
+    :ivar interface: Containing interface
+    :vartype interface: :class:`Interface`
+    :ivar service: Containing service
+    :vartype service: :class:`Service`
     """
 
     __tablename__ = 'operation'
@@ -1369,6 +1444,9 @@ class ArtifactBase(InstanceModelMixin):
     :vartype repository_credential: {basestring: basestring}
     :ivar properties: Associated parameters
     :vartype properties: {basestring: :class:`Parameter`}
+
+    :ivar node: Containing node
+    :vartype node: :class:`Node`
     """
 
     __tablename__ = 'artifact'

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5ceb14cd/aria/modeling/service_template.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_template.py b/aria/modeling/service_template.py
index aec7aa0..ebbe904 100644
--- a/aria/modeling/service_template.py
+++ b/aria/modeling/service_template.py
@@ -88,6 +88,9 @@ class ServiceTemplateBase(TemplateModelMixin):
     :vartype created_at: :class:`datetime.datetime`
     :ivar updated_at: Update timestamp
     :vartype updated_at: :class:`datetime.datetime`
+
+    :ivar services: Instantiated services
+    :vartype services: [:class:`Service`]
     """
 
     __tablename__ = 'service_template'
@@ -406,6 +409,17 @@ class NodeTemplateBase(TemplateModelMixin):
     :vartype target_node_template_constraints: [:class:`FunctionType`]
     :ivar plugins: Plugins required to be installed on the node's host
     :vartype plugins: {basestring: :class:`Plugin`}
+
+    :ivar service_template: Containing service template
+    :vartype service_template: :class:`ServiceTemplate`
+    :ivar group_templates: We are a member of these groups
+    :vartype group_templates: [:class:`GroupTemplate`]
+    :ivar policy_templates: Policy templates enacted on this node
+    :vartype policy_templates: [:class:`PolicyTemplate`]
+    :ivar substitution_template_mapping: Our contribution to service substitution
+    :vartype substitution_template_mapping: :class:`SubstitutionTemplateMapping`
+    :ivar nodes: Instantiated nodes
+    :vartype nodes: [:class:`Node`]
     """
 
     __tablename__ = 'node_template'
@@ -552,6 +566,13 @@ class GroupTemplateBase(TemplateModelMixin):
     :vartype properties: {basestring: :class:`Parameter`}
     :ivar interface_templates: Bundles of operations
     :vartype interface_templates: {basestring: :class:`InterfaceTemplate`}
+
+    :ivar service_template: Containing service template
+    :vartype service_template: :class:`ServiceTemplate`
+    :ivar policy_templates: Policy templates enacted on this group
+    :vartype policy_templates: [:class:`PolicyTemplate`]
+    :ivar groups: Instantiated groups
+    :vartype groups: [:class:`Group`]
     """
 
     __tablename__ = 'group_template'
@@ -652,6 +673,11 @@ class PolicyTemplateBase(TemplateModelMixin):
     :vartype group_templates: [:class:`GroupTemplate`]
     :ivar properties: Associated parameters
     :vartype properties: {basestring: :class:`Parameter`}
+
+    :ivar service_template: Containing service template
+    :vartype service_template: :class:`ServiceTemplate`
+    :ivar policies: Instantiated policies
+    :vartype policies: [:class:`Policy`]
     """
 
     __tablename__ = 'policy_template'
@@ -744,6 +770,11 @@ class SubstitutionTemplateBase(TemplateModelMixin):
     :vartype node_type: :class:`Type`
     :ivar mappings: Requirement and capability mappings
     :vartype mappings: {basestring: :class:`SubstitutionTemplateMapping`}
+
+    :ivar service_template: Containing service template
+    :vartype service_template: :class:`ServiceTemplate`
+    :ivar substitutions: Instantiated substitutions
+    :vartype substitutions: [:class:`Substitution`]
     """
 
     __tablename__ = 'substitution_template'
@@ -807,6 +838,9 @@ class SubstitutionTemplateMappingBase(TemplateModelMixin):
     :vartype capability_template: :class:`CapabilityTemplate`
     :ivar requirement_template: Requirement template in the node template
     :vartype requirement_template: :class:`RequirementTemplate`
+
+    :ivar substitution_template: Containing substitution template
+    :vartype substitution_template: :class:`SubstitutionTemplate`
     """
 
     __tablename__ = 'substitution_template_mapping'
@@ -918,6 +952,13 @@ class RequirementTemplateBase(TemplateModelMixin):
     :vartype target_node_template_constraints: [:class:`FunctionType`]
     :ivar relationship_template: Template for relationships (optional)
     :vartype relationship_template: :class:`RelationshipTemplate`
+
+    :ivar node_template: Containing node template
+    :vartype node_template: :class:`NodeTemplate`
+    :ivar substitution_template_mapping: Our contribution to service substitution
+    :vartype substitution_template_mapping: :class:`SubstitutionTemplateMapping`
+    :ivar substitution_mapping: Our contribution to service substitution
+    :vartype substitution_mapping: :class:`SubstitutionMapping`
     """
 
     __tablename__ = 'requirement_template'
@@ -1094,6 +1135,11 @@ class RelationshipTemplateBase(TemplateModelMixin):
     :vartype properties: {basestring: :class:`Parameter`}
     :ivar interface_templates: Bundles of operations
     :vartype interface_templates: {basestring: :class:`InterfaceTemplate`}
+
+    :ivar requirement_template: Containing requirement template
+    :vartype requirement_template: :class:`RequirementTemplate`
+    :ivar relationships: Instantiated relationships
+    :vartype relationships: [:class:`Relationship`]
     """
 
     __tablename__ = 'relationship_template'
@@ -1176,12 +1222,21 @@ class CapabilityTemplateBase(TemplateModelMixin):
     :vartype type: :class:`Type`
     :ivar description: Human-readable description
     :vartype description: basestring
+    :ivar valid_source_node_types: Reject requirements that are not from these node types
(optional)
+    :vartype valid_source_node_types: [:class:`Type`]
     :ivar min_occurrences: Minimum number of requirement matches required
     :vartype min_occurrences: int
     :ivar max_occurrences: Maximum number of requirement matches allowed
     :vartype min_occurrences: int
     :ivar properties: Associated parameters
     :vartype properties: {basestring: :class:`Parameter`}
+
+    :ivar node_template: Containing node template
+    :vartype node_template: :class:`NodeTemplate`
+    :ivar substitution_template_mapping: Our contribution to service substitution
+    :vartype substitution_template_mapping: :class:`SubstitutionTemplateMapping`
+    :ivar capabilities: Instantiated capabilities
+    :vartype capabilities: [:class:`Capability`]
     """
 
     __tablename__ = 'capability_template'
@@ -1305,6 +1360,15 @@ class InterfaceTemplateBase(TemplateModelMixin):
     :vartype inputs: {basestring: :class:`Parameter`}
     :ivar operation_templates: Operations
     :vartype operation_templates: {basestring: :class:`OperationTemplate`}
+
+    :ivar node_template: Containing node template
+    :vartype node_template: :class:`NodeTemplate`
+    :ivar group_template: Containing group template
+    :vartype group_template: :class:`GroupTemplate`
+    :ivar relationship_template: Containing relationship template
+    :vartype relationship_template: :class:`RelationshipTemplate`
+    :ivar interfaces: Instantiated interfaces
+    :vartype interfaces: [:class:`Interface`]
     """
 
     __tablename__ = 'interface_template'
@@ -1414,6 +1478,13 @@ class OperationTemplateBase(TemplateModelMixin):
     :vartype max_retries: int
     :ivar retry_interval: Interval between retries (in seconds)
     :vartype retry_interval: int
+
+    :ivar interface_template: Containing interface template
+    :vartype interface_template: :class:`InterfaceTemplate`
+    :ivar service_template: Containing service template
+    :vartype service_template: :class:`ServiceTemplate`
+    :ivar operations: Instantiated operations
+    :vartype operations: [:class:`Operation`]
     """
 
     __tablename__ = 'operation_template'
@@ -1532,6 +1603,11 @@ class ArtifactTemplateBase(TemplateModelMixin):
     :vartype repository_credential: {basestring: basestring}
     :ivar properties: Associated parameters
     :vartype properties: {basestring: :class:`Parameter`}
+
+    :ivar node_template: Containing node template
+    :vartype node_template: :class:`NodeTemplate`
+    :ivar artifacts: Instantiated artifacts
+    :vartype artifacts: [:class:`Artifact`]
     """
 
     __tablename__ = 'artifact_template'


Mime
View raw message