You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ariatosca.apache.org by em...@apache.org on 2017/08/30 22:13:19 UTC

[03/10] incubator-ariatosca git commit: ARIA-353 Add node template directives

ARIA-353 Add node template directives

The directives field already existed in the presentation level, but it
needed to be added to the node template model.


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

Branch: refs/heads/ARIA-1-parser-test-suite
Commit: 969149bd98a9f2b60b98b2d0f1e64392d7c9f2da
Parents: a048f70
Author: Avia Efrat <av...@gigaspaces.com>
Authored: Wed Aug 30 17:54:46 2017 +0300
Committer: Avia Efrat <av...@gigaspaces.com>
Committed: Wed Aug 30 17:58:16 2017 +0300

----------------------------------------------------------------------
 aria/modeling/service_template.py                              | 6 ++++++
 aria/parser/presentation/fields.py                             | 5 +++--
 .../aria_extension_tosca/simple_v1_0/modeling/__init__.py      | 6 ++++--
 3 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/969149bd/aria/modeling/service_template.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_template.py b/aria/modeling/service_template.py
index d988d21..cd0adb4 100644
--- a/aria/modeling/service_template.py
+++ b/aria/modeling/service_template.py
@@ -457,6 +457,12 @@ class NodeTemplateBase(TemplateModelMixin):
     :type: :obj:`basestring`
     """)
 
+    directives = Column(PickleType, doc="""
+    Directives that apply to this node template.
+
+    :type: [:obj:`basestring`]
+    """)
+
     default_instances = Column(Integer, default=1, doc="""
     Default number nodes that will appear in the service.
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/969149bd/aria/parser/presentation/fields.py
----------------------------------------------------------------------
diff --git a/aria/parser/presentation/fields.py b/aria/parser/presentation/fields.py
index 5c08d4a..5c3e074 100644
--- a/aria/parser/presentation/fields.py
+++ b/aria/parser/presentation/fields.py
@@ -437,7 +437,7 @@ class Field(object):
             raw = deepcopy_with_locators(default_raw)
             merge(raw, presentation._raw)
 
-        # Handle unknown fields
+        # Handle unknown fields (only dict can have unknown fields, lists can't have them)
 
         if self.field_variant == 'primitive_dict_unknown_fields':
             return self._get_primitive_dict_unknown_fields(presentation, raw, context)
@@ -473,7 +473,8 @@ class Field(object):
 
         # Handle get according to variant
 
-        getter = getattr(self, '_get_%s' % self.field_variant, None)
+        getter = getattr(self, '_get_{field_variant}'.format(field_variant=self.field_variant),
+                         None)
 
         if getter is None:
             locator = self.get_locator(raw)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/969149bd/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
index 1f90d29..d960e05 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
@@ -163,12 +163,14 @@ def create_metadata_models(context, service_template, metadata):
 def create_node_template_model(context, service_template, node_template):
     node_type = node_template._get_type(context)
     node_type = service_template.node_types.get_descendant(node_type._name)
-    model = NodeTemplate(name=node_template._name,
-                         type=node_type)
+    model = NodeTemplate(name=node_template._name, type=node_type)
 
     if node_template.description:
         model.description = node_template.description.value
 
+    if node_template.directives:
+        model.directives = node_template.directives
+
     model.properties.update(create_property_models_from_values(
         template_properties=node_template._get_property_values(context)))
     model.attributes.update(create_attribute_models_from_values(