You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ariatosca.apache.org by av...@apache.org on 2017/08/30 14:57:24 UTC
incubator-ariatosca git commit: ARIA-353 Add node template directives
Repository: incubator-ariatosca
Updated Branches:
refs/heads/ARIA-353-substitution-directive [created] bdf9558f5
ARIA-353 Add node template directives
The directives field already existed in the presentsation 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/bdf9558f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/bdf9558f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/bdf9558f
Branch: refs/heads/ARIA-353-substitution-directive
Commit: bdf9558f54c8d53d7e5dda17bdabaf1922d4a146
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:54:46 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/bdf9558f/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/bdf9558f/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/bdf9558f/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(