ariatosca-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxm...@apache.org
Subject incubator-ariatosca git commit: moved coerce
Date Mon, 24 Jul 2017 16:25:31 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-174-Refactor-instantiation-phase 5c92ccad6 -> a9640765a


moved coerce


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

Branch: refs/heads/ARIA-174-Refactor-instantiation-phase
Commit: a9640765a01f30da64212f65b8ef61af5767f7bc
Parents: 5c92cca
Author: max-orlov <maxim@gigaspaces.com>
Authored: Mon Jul 24 19:25:24 2017 +0300
Committer: max-orlov <maxim@gigaspaces.com>
Committed: Mon Jul 24 19:25:24 2017 +0300

----------------------------------------------------------------------
 aria/cli/commands/service_templates.py |  6 +--
 aria/modeling/service_common.py        |  6 ---
 aria/modeling/service_instance.py      | 51 -------------------
 aria/modeling/service_template.py      | 79 -----------------------------
 aria/modeling/utils.py                 | 13 -----
 aria/orchestrator/topology/__init__.py | 18 +++++++
 aria/orchestrator/topology/common.py   |  7 +++
 aria/orchestrator/topology/instance.py | 66 +++++++++++++++---------
 aria/orchestrator/topology/template.py | 74 ++++++++++++++++++---------
 aria/parser/consumption/modeling.py    |  6 +--
 10 files changed, 123 insertions(+), 203 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a9640765/aria/cli/commands/service_templates.py
----------------------------------------------------------------------
diff --git a/aria/cli/commands/service_templates.py b/aria/cli/commands/service_templates.py
index f567aa8..c455eb3 100644
--- a/aria/cli/commands/service_templates.py
+++ b/aria/cli/commands/service_templates.py
@@ -28,7 +28,7 @@ from ...core import Core
 from ...storage import exceptions as storage_exceptions
 from ...parser import consumption
 from ...utils import (formatting, collections, console)
-
+from ... orchestrator import topology
 
 DESCRIPTION_FIELD_LENGTH_LIMIT = 20
 SERVICE_TEMPLATE_COLUMNS = \
@@ -75,8 +75,8 @@ def show(service_template_name, model_storage, mode_full, mode_types, format_jso
         else:
             service_template.dump()
     elif mode_types:
-        consumption.ConsumptionContext()
-        service_template.dump_types()
+        context = consumption.ConsumptionContext()
+        topology.handler.dump_types(context, service_template)
     else:
         logger.info('Showing service template {0}...'.format(service_template_name))
         service_template_dict = service_template.to_dict()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a9640765/aria/modeling/service_common.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_common.py b/aria/modeling/service_common.py
index 60c7330..fc6d1bb 100644
--- a/aria/modeling/service_common.py
+++ b/aria/modeling/service_common.py
@@ -548,9 +548,6 @@ class TypeBase(InstanceModelMixin):
         self._append_raw_children(types)
         return types
 
-    def coerce_values(self, report_issues):
-        pass
-
     def _append_raw_children(self, types):
         for child in self.children:
             raw_child = formatting.as_raw(child)
@@ -589,6 +586,3 @@ class MetadataBase(TemplateModelMixin):
         return collections.OrderedDict((
             ('name', self.name),
             ('value', self.value)))
-
-    def coerce_values(self, report_issues):
-        pass

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a9640765/aria/modeling/service_instance.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_instance.py b/aria/modeling/service_instance.py
index 03f8632..15cf8fd 100644
--- a/aria/modeling/service_instance.py
+++ b/aria/modeling/service_instance.py
@@ -288,17 +288,6 @@ class ServiceBase(InstanceModelMixin):
             ('outputs', formatting.as_raw_dict(self.outputs)),
             ('workflows', formatting.as_raw_list(self.workflows))))
 
-    def coerce_values(self, report_issues):
-        utils.coerce_dict_values(self.meta_data, report_issues)
-        utils.coerce_dict_values(self.nodes, report_issues)
-        utils.coerce_dict_values(self.groups, report_issues)
-        utils.coerce_dict_values(self.policies, report_issues)
-        if self.substitution is not None:
-            self.substitution.coerce_values(report_issues)
-        utils.coerce_dict_values(self.inputs, report_issues)
-        utils.coerce_dict_values(self.outputs, report_issues)
-        utils.coerce_dict_values(self.workflows, report_issues)
-
     def dump_graph(self):
         for node in self.nodes.itervalues():
             if not self.is_node_a_target(node):
@@ -718,14 +707,6 @@ class NodeBase(InstanceModelMixin):
             ('capabilities', formatting.as_raw_list(self.capabilities)),
             ('relationships', formatting.as_raw_list(self.outbound_relationships))))
 
-    def coerce_values(self, report_issues):
-        utils.coerce_dict_values(self.properties, report_issues)
-        utils.coerce_dict_values(self.attributes, report_issues)
-        utils.coerce_dict_values(self.interfaces, report_issues)
-        utils.coerce_dict_values(self.artifacts, report_issues)
-        utils.coerce_dict_values(self.capabilities, report_issues)
-        utils.coerce_list_values(self.outbound_relationships, report_issues)
-
 
 class GroupBase(InstanceModelMixin):
     """
@@ -842,10 +823,6 @@ class GroupBase(InstanceModelMixin):
             ('properties', formatting.as_raw_dict(self.properties)),
             ('interfaces', formatting.as_raw_list(self.interfaces))))
 
-    def coerce_values(self, report_issues):
-        utils.coerce_dict_values(self.properties, report_issues)
-        utils.coerce_dict_values(self.interfaces, report_issues)
-
 
 class PolicyBase(InstanceModelMixin):
     """
@@ -959,9 +936,6 @@ class PolicyBase(InstanceModelMixin):
             ('type_name', self.type.name),
             ('properties', formatting.as_raw_dict(self.properties))))
 
-    def coerce_values(self, report_issues):
-        utils.coerce_dict_values(self.properties, report_issues)
-
 
 class SubstitutionBase(InstanceModelMixin):
     """
@@ -1039,9 +1013,6 @@ class SubstitutionBase(InstanceModelMixin):
             ('node_type_name', self.node_type.name),
             ('mappings', formatting.as_raw_dict(self.mappings))))
 
-    def coerce_values(self, report_issues):
-        utils.coerce_dict_values(self.mappings, report_issues)
-
 
 class SubstitutionMappingBase(InstanceModelMixin):
     """
@@ -1137,9 +1108,6 @@ class SubstitutionMappingBase(InstanceModelMixin):
         return collections.OrderedDict((
             ('name', self.name),))
 
-    def coerce_values(self, report_issues):
-        pass
-
 
 class RelationshipBase(InstanceModelMixin):
     """
@@ -1329,10 +1297,6 @@ class RelationshipBase(InstanceModelMixin):
             ('properties', formatting.as_raw_dict(self.properties)),
             ('interfaces', formatting.as_raw_list(self.interfaces))))
 
-    def coerce_values(self, report_issues):
-        utils.coerce_dict_values(self.properties, report_issues)
-        utils.coerce_dict_values(self.interfaces, report_issues)
-
 
 class CapabilityBase(InstanceModelMixin):
     """
@@ -1449,9 +1413,6 @@ class CapabilityBase(InstanceModelMixin):
             ('type_name', self.type.name),
             ('properties', formatting.as_raw_dict(self.properties))))
 
-    def coerce_values(self, report_issues):
-        utils.coerce_dict_values(self.properties, report_issues)
-
 
 class InterfaceBase(InstanceModelMixin):
     """
@@ -1589,10 +1550,6 @@ class InterfaceBase(InstanceModelMixin):
             ('inputs', formatting.as_raw_dict(self.inputs)),
             ('operations', formatting.as_raw_list(self.operations))))
 
-    def coerce_values(self, report_issues):
-        utils.coerce_dict_values(self.inputs, report_issues)
-        utils.coerce_dict_values(self.operations, report_issues)
-
 
 class OperationBase(InstanceModelMixin):
     """
@@ -1818,10 +1775,6 @@ class OperationBase(InstanceModelMixin):
             ('dependencies', self.dependencies),
             ('inputs', formatting.as_raw_dict(self.inputs))))
 
-    def coerce_values(self, report_issues):
-        utils.coerce_dict_values(self.inputs, report_issues)
-        utils.coerce_dict_values(self.configurations, report_issues)
-        utils.coerce_dict_values(self.arguments, report_issues)
 
 
 class ArtifactBase(InstanceModelMixin):
@@ -1941,7 +1894,3 @@ class ArtifactBase(InstanceModelMixin):
             ('repository_url', self.repository_url),
             ('repository_credential', formatting.as_agnostic(self.repository_credential)),
             ('properties', formatting.as_raw_dict(self.properties))))
-
-    def coerce_values(self, report_issues):
-        utils.coerce_dict_values(self.properties, report_issues)
-

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a9640765/aria/modeling/service_template.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_template.py b/aria/modeling/service_template.py
index 665a4f1..80a5dbb 100644
--- a/aria/modeling/service_template.py
+++ b/aria/modeling/service_template.py
@@ -325,40 +325,6 @@ class ServiceTemplateBase(TemplateModelMixin):
             ('interface_types', formatting.as_raw(self.interface_types)),
             ('artifact_types', formatting.as_raw(self.artifact_types))))
 
-    def coerce_values(self, report_issues):
-        utils.coerce_dict_values(self.meta_data, report_issues)
-        utils.coerce_dict_values(self.node_templates, report_issues)
-        utils.coerce_dict_values(self.group_templates, report_issues)
-        utils.coerce_dict_values(self.policy_templates, report_issues)
-        if self.substitution_template is not None:
-            self.substitution_template.coerce_values(report_issues)
-        utils.coerce_dict_values(self.inputs, report_issues)
-        utils.coerce_dict_values(self.outputs, report_issues)
-        utils.coerce_dict_values(self.workflow_templates, report_issues)
-
-    def dump_types(self):
-        if self.node_types.children:
-            console.puts('Node types:')
-            self.node_types.dump()
-        if self.group_types.children:
-            console.puts('Group types:')
-            self.group_types.dump()
-        if self.capability_types.children:
-            console.puts('Capability types:')
-            self.capability_types.dump()
-        if self.relationship_types.children:
-            console.puts('Relationship types:')
-            self.relationship_types.dump()
-        if self.policy_types.children:
-            console.puts('Policy types:')
-            self.policy_types.dump()
-        if self.artifact_types.children:
-            console.puts('Artifact types:')
-            self.artifact_types.dump()
-        if self.interface_types.children:
-            console.puts('Interface types:')
-            self.interface_types.dump()
-
 
 class NodeTemplateBase(TemplateModelMixin):
     """
@@ -529,14 +495,6 @@ class NodeTemplateBase(TemplateModelMixin):
             ('capability_templates', formatting.as_raw_list(self.capability_templates)),
             ('requirement_templates', formatting.as_raw_list(self.requirement_templates))))
 
-    def coerce_values(self, report_issues):
-        utils.coerce_dict_values(self.properties, report_issues)
-        utils.coerce_dict_values(self.attributes, report_issues)
-        utils.coerce_dict_values(self.interface_templates, report_issues)
-        utils.coerce_dict_values(self.artifact_templates, report_issues)
-        utils.coerce_dict_values(self.capability_templates, report_issues)
-        utils.coerce_list_values(self.requirement_templates, report_issues)
-
     @property
     def scaling(self):
         scaling = {}
@@ -737,10 +695,6 @@ class GroupTemplateBase(TemplateModelMixin):
             ('properties', formatting.as_raw_dict(self.properties)),
             ('interface_templates', formatting.as_raw_list(self.interface_templates))))
 
-    def coerce_values(self, report_issues):
-        utils.coerce_dict_values(self.properties, report_issues)
-        utils.coerce_dict_values(self.interface_templates, report_issues)
-
     def contains_node_template(self, name):
         for node_template in self.node_templates:
             if node_template.name == name:
@@ -853,9 +807,6 @@ class PolicyTemplateBase(TemplateModelMixin):
             ('type_name', self.type.name),
             ('properties', formatting.as_raw_dict(self.properties))))
 
-    def coerce_values(self, report_issues):
-        utils.coerce_dict_values(self.properties, report_issues)
-
     def is_for_node_template(self, name):
         for node_template in self.node_templates:
             if node_template.name == name:
@@ -932,9 +883,6 @@ class SubstitutionTemplateBase(TemplateModelMixin):
             ('node_type_name', self.node_type.name),
             ('mappings', formatting.as_raw_dict(self.mappings))))
 
-    def coerce_values(self, report_issues):
-        utils.coerce_dict_values(self.mappings, report_issues)
-
 
 class SubstitutionTemplateMappingBase(TemplateModelMixin):
     """
@@ -1014,9 +962,6 @@ class SubstitutionTemplateMappingBase(TemplateModelMixin):
         return collections.OrderedDict((
             ('name', self.name),))
 
-    def coerce_values(self, report_issues):
-        pass
-
 
 class RequirementTemplateBase(TemplateModelMixin):
     """
@@ -1220,10 +1165,6 @@ class RequirementTemplateBase(TemplateModelMixin):
             ('target_capability_name', self.target_capability_name),
             ('relationship_template', formatting.as_raw(self.relationship_template))))
 
-    def coerce_values(self, report_issues):
-        if self.relationship_template is not None:
-            self.relationship_template.coerce_values(report_issues)
-
 
 class RelationshipTemplateBase(TemplateModelMixin):
     """
@@ -1306,10 +1247,6 @@ class RelationshipTemplateBase(TemplateModelMixin):
             ('properties', formatting.as_raw_dict(self.properties)),
             ('interface_templates', formatting.as_raw_list(self.interface_templates))))
 
-    def coerce_values(self, report_issues):
-        utils.coerce_dict_values(self.properties, report_issues)
-        utils.coerce_dict_values(self.interface_templates, report_issues)
-
 
 class CapabilityTemplateBase(TemplateModelMixin):
     """
@@ -1446,9 +1383,6 @@ class CapabilityTemplateBase(TemplateModelMixin):
             ('valid_source_node_types', [v.name for v in self.valid_source_node_types]),
             ('properties', formatting.as_raw_dict(self.properties))))
 
-    def coerce_values(self, report_issues):
-        utils.coerce_dict_values(self.properties, report_issues)
-
 
 class InterfaceTemplateBase(TemplateModelMixin):
     """
@@ -1578,10 +1512,6 @@ class InterfaceTemplateBase(TemplateModelMixin):
             # TODO fix self.properties reference
             ('operation_templates', formatting.as_raw_list(self.operation_templates))))
 
-    def coerce_values(self, report_issues):
-        utils.coerce_dict_values(self.inputs, report_issues)
-        utils.coerce_dict_values(self.operation_templates, report_issues)
-
 
 class OperationTemplateBase(TemplateModelMixin):
     """
@@ -1740,10 +1670,6 @@ class OperationTemplateBase(TemplateModelMixin):
             ('dependencies', self.dependencies),
             ('inputs', formatting.as_raw_dict(self.inputs))))
 
-    def coerce_values(self, report_issues):
-        utils.coerce_dict_values(self.inputs, report_issues)
-        utils.coerce_dict_values(self.configurations, report_issues)
-
 
 class ArtifactTemplateBase(TemplateModelMixin):
     """
@@ -1856,8 +1782,6 @@ class ArtifactTemplateBase(TemplateModelMixin):
             ('repository_credential', formatting.as_agnostic(self.repository_credential)),
             ('properties', formatting.as_raw_dict(self.properties))))
 
-    def coerce_values(self, report_issues):
-        utils.coerce_dict_values(self.properties, report_issues)
 
 class PluginSpecificationBase(TemplateModelMixin):
     """
@@ -1925,6 +1849,3 @@ class PluginSpecificationBase(TemplateModelMixin):
             ('name', self.name),
             ('version', self.version),
             ('enabled', self.enabled)))
-
-    def coerce_values(self, report_issues):
-        pass

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a9640765/aria/modeling/utils.py
----------------------------------------------------------------------
diff --git a/aria/modeling/utils.py b/aria/modeling/utils.py
index 1002d5a..d15669f 100644
--- a/aria/modeling/utils.py
+++ b/aria/modeling/utils.py
@@ -140,19 +140,6 @@ def merge_parameter_values(parameter_values, declared_parameters, model_cls=None
     return parameters
 
 
-def coerce_dict_values(the_dict, report_issues=False):
-    if not the_dict:
-        return
-    coerce_list_values(the_dict.itervalues(), report_issues)
-
-
-def coerce_list_values(the_list, report_issues=False):
-    if not the_list:
-        return
-    for value in the_list:
-        value.coerce_values(report_issues)
-
-
 def parameters_as_values(the_dict):
     return dict((k, v.value) for k, v in the_dict.iteritems())
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a9640765/aria/orchestrator/topology/__init__.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/topology/__init__.py b/aria/orchestrator/topology/__init__.py
index 4737ac1..aa9e306 100644
--- a/aria/orchestrator/topology/__init__.py
+++ b/aria/orchestrator/topology/__init__.py
@@ -132,5 +132,23 @@ class Handler(object):
 
         return str(context)
 
+    def coerce(self, template, **kwargs):
+        if isinstance(template, dict):
+            return self.validate(template.values())
+        elif isinstance(template, list):
+            return all(self.validate(value) for value in template)
+        elif template is not None:
+            handler = self._handlers.get(template.__class__)
+            return handler(self, template).coerce(**kwargs)
+
+    def dump_types(self, context, service_template):
+        self.dump(service_template.node_types, context)
+        self.dump(service_template.group_types, context)
+        self.dump(service_template.capability_types, context)
+        self.dump(service_template.relationship_types, context)
+        self.dump(service_template.policy_types, context)
+        self.dump(service_template.artifact_types, context)
+        self.dump(service_template.interface_types, context)
+
 
 handler = Handler()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a9640765/aria/orchestrator/topology/common.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/topology/common.py b/aria/orchestrator/topology/common.py
index 48e3c07..9b00ce6 100644
--- a/aria/orchestrator/topology/common.py
+++ b/aria/orchestrator/topology/common.py
@@ -19,6 +19,10 @@ class _Handler(object):
         self._topology = topology
         self._template = template
 
+    def _coerce(self, *templates, **kwargs):
+        for template in templates:
+            self._topology.coerce(template)
+
     def coerce(self):
         raise NotImplementedError
 
@@ -38,6 +42,9 @@ class _TemplateHandler(_Handler):
     def instantiate(self, **kwargs):
         raise NotImplementedError
 
+    def coerce(self, **kwargs):
+        pass
+
 
 class _InstanceHandler(_Handler):
     pass

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a9640765/aria/orchestrator/topology/instance.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/topology/instance.py b/aria/orchestrator/topology/instance.py
index 7fb8c23..cb3f747 100644
--- a/aria/orchestrator/topology/instance.py
+++ b/aria/orchestrator/topology/instance.py
@@ -20,8 +20,9 @@ from aria.utils import formatting
 
 
 class Artifact(common._InstanceHandler):
-    def coerce(self):
-        pass
+
+    def coerce(self, **kwargs):
+        self._topology.coerce(self._template.properties, **kwargs)
 
     def validate(self, **kwargs):
         self._topology.validate(self._template.properties)
@@ -47,8 +48,8 @@ class Artifact(common._InstanceHandler):
             
 
 class Capability(common._InstanceHandler):
-    def coerce(self):
-        pass
+    def coerce(self, **kwargs):
+        self._topology.coerce(self._template.properties, **kwargs)
 
     def validate(self, **kwargs):
         self._topology.validate(self._template.properties)
@@ -67,8 +68,8 @@ class Capability(common._InstanceHandler):
 
 
 class Group(common._InstanceHandler):
-    def coerce(self):
-        pass
+    def coerce(self, **kwargs):
+        self._coerce(self._template.properties, self._template.interfaces, **kwargs)
 
     def validate(self, **kwargs):
         self._validate(self._template.properties,
@@ -88,8 +89,8 @@ class Group(common._InstanceHandler):
 
 
 class Interface(common._InstanceHandler):
-    def coerce(self):
-        pass
+    def coerce(self, **kwargs):
+        self._coerce(self._template.inputs, self._template.operations, **kwargs)
 
     def validate(self, **kwargs):
         self._validate(self._template.inputs,
@@ -106,8 +107,15 @@ class Interface(common._InstanceHandler):
 
 
 class Node(common._InstanceHandler):
-    def coerce(self):
-        pass
+    def coerce(self, **kwargs):
+        self._coerce(self._template.properties,
+                     self._template.attributes,
+                     self._template.interfaces,
+                     self._template.artifacts,
+                     self._template.capabilities,
+                     self._template.outbound_relationships,
+                     **kwargs)
+
 
     def validate(self, **kwargs):
         # TODO: fix the context
@@ -142,8 +150,11 @@ class Node(common._InstanceHandler):
 
 
 class Operation(common._InstanceHandler):
-    def coerce(self):
-        pass
+    def coerce(self, **kwargs):
+        self._coerce(self._template.inputs,
+                     self._template.configurations,
+                     self._template.arguments,
+                     **kwargs)
 
     def validate(self, **kwargs):
         self._validate(self._template.inputs,
@@ -180,8 +191,8 @@ class Operation(common._InstanceHandler):
 
 
 class Policy(common._InstanceHandler):
-    def coerce(self):
-        pass
+    def coerce(self, **kwargs):
+        self._topology.coerce(self._template.properties, **kwargs)
 
     def validate(self, **kwargs):
         self._topology.validate(self._template.properties)
@@ -204,8 +215,10 @@ class Policy(common._InstanceHandler):
 
 
 class Relationship(common._InstanceHandler):
-    def coerce(self):
-        pass
+    def coerce(self, **kwargs):
+        self._coerce(self._template.properties,
+                     self._template.interfaces,
+                     **kwargs)
 
     def validate(self, **kwargs):
         self._validate(self._template.properties,
@@ -233,8 +246,16 @@ class Relationship(common._InstanceHandler):
 
 
 class Service(common._InstanceHandler):
-    def coerce(self):
-        pass
+    def coerce(self, **kwargs):
+        self._coerce(self._template.meta_data,
+                     self._template.nodes,
+                     self._template.groups,
+                     self._template.policies,
+                     self._template.substitution,
+                     self._template.inputs,
+                     self._template.outputs,
+                     self._template.workflows,
+                     **kwargs)
 
     def validate(self, **kwargs):
         self._validate(self._template.meta_data,
@@ -264,8 +285,8 @@ class Service(common._InstanceHandler):
 
 
 class Substitution(common._InstanceHandler):
-    def coerce(self):
-        pass
+    def coerce(self, **kwargs):
+        self._topology.coerce(self._template.mappings, **kwargs)
 
     def validate(self, **kwargs):
         self._topology.validate(self._template.mappings)
@@ -278,8 +299,6 @@ class Substitution(common._InstanceHandler):
 
 
 class SubstitutionMapping(common._InstanceHandler):
-    def coerce(self):
-        pass
 
     def validate(self, **kwargs):
         # context = ConsumptionContext.get_thread_local()
@@ -336,9 +355,6 @@ class _Parameter(common._InstanceHandler):
         if self._template.description:
             context.write(context.style.meta(self._template.description))
 
-    def coerce(self):
-        pass
-
     def instantiate(self, instance_cls, **kwargs):
         return instance_cls(
             name=self._template.name,  # pylint: disable=unexpected-keyword-arg

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a9640765/aria/orchestrator/topology/template.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/topology/template.py b/aria/orchestrator/topology/template.py
index 5826a20..86619a9 100644
--- a/aria/orchestrator/topology/template.py
+++ b/aria/orchestrator/topology/template.py
@@ -36,8 +36,16 @@ class ServiceTemplate(common._TemplateHandler):
         self._topology.dump(self._template.outputs, context, 'Outputs')
         self._topology.dump(self._template.workflow_templates, context, 'Workflow templates')
 
-    def coerce(self):
-        pass
+    def coerce(self, **kwargs):
+        self._coerce(self._template.meta_data,
+                     self._template.node_templates,
+                     self._template.group_templates,
+                     self._template.policy_templates,
+                     self._template.substitution_template,
+                     self._template.inputs,
+                     self._template.outputs,
+                     self._template.workflow_templates,
+                     **kwargs)
 
     def instantiate(self, instance_cls, inputs=None):
         now = datetime.now()
@@ -113,8 +121,8 @@ class ArtifactTemplate(common._TemplateHandler):
                     context.style.literal(self._template.repository_credential)))
             self._topology.dump(self._template.properties, context, 'Properties')
 
-    def coerce(self):
-        pass
+    def coerce(self, **kwargs):
+        self._topology.coerce(self._template.properties, **kwargs)
 
     def instantiate(self, instance_cls):
         return instance_cls(
@@ -148,11 +156,10 @@ class CapabilityTemplate(common._TemplateHandler):
                 context.write('Valid source node types: {0}'.format(
                     ', '.join((str(context.style.type(v.name))
                                for v in self._template.valid_source_node_types))))
-            self._topology.dump(self._template.properties, contet, 'Properties')
-
+            self._topology.dump(self._template.properties, context, 'Properties')
 
     def coerce(self):
-        pass
+        self._topology.coerce(self._template.properties)
 
     def instantiate(self, instance_cls):
         return instance_cls(name=self._template.name,
@@ -195,8 +202,8 @@ class RequirementTemplate(common._TemplateHandler):
                 with context.style.indent:
                     self._template.relationship_template.dump()
 
-    def coerce(self):
-        pass
+    def coerce(self, **kwargs):
+        self._topology.coerce(self._template.relationship_template, **kwargs)
 
     def instantiate(self, instance_cls):
         return instance_cls(name=self._template.name,
@@ -223,8 +230,10 @@ class GroupTemplate(common._TemplateHandler):
                 context.write('Member node templates: {0}'.format(', '.join(
                     (str(context.style.node(v.name)) for v in self._template.node_templates))))
 
-    def coerce(self):
-        pass
+    def coerce(self, **kwargs):
+        self._coerce(self._template.properties,
+                     self._template.interface_templates,
+                     **kwargs)
 
     def instantiate(self, instance_cls):
         group = instance_cls(
@@ -254,8 +263,10 @@ class InterfaceTemplate(common._TemplateHandler):
             self._topology.dump(self._template.inputs, context, 'Inputs')
             self._topology.dump(self._template.operation_templates, context, 'Operation templates')
 
-    def coerce(self):
-        pass
+    def coerce(self, **kwargs):
+        self._coerce(self._template.inputs,
+                     self._template.operation_templates,
+                     **kwargs)
 
     def instantiate(self, instance_cls):
         interface = instance_cls(
@@ -286,8 +297,14 @@ class NodeTemplate(common._TemplateHandler):
             self._topology.dump(self._template.capability_templates, context, 'Capability
templates')
             self._topology.dump(self._template.requirement_templates, context, 'Requirement
templates')
 
-    def coerce(self):
-        pass
+    def coerce(self, **kwargs):
+        self._coerce(self._template.properties,
+                     self._template.attributes,
+                     self._template.interface_templates,
+                     self._template.artifact_templates,
+                     self._template.capability_templates,
+                     self._template.requirement_templates,
+                     **kwargs)
 
     def instantiate(self, instance_cls):
         node = instance_cls(
@@ -336,8 +353,9 @@ class PolicyTemplate(common._TemplateHandler):
             if self._template.group_templates:
                 context.write('Target group templates: {0}'.format(', '.join(
                     (str(context.style.node(v.name)) for v in self._template.group_templates))))
-    def coerce(self):
-        pass
+
+    def coerce(self, **kwargs):
+        self._topology.coerce(self._template.properties, **kwargs)
 
     def instantiate(self, instance_cls):
         policy = instance_cls(
@@ -367,8 +385,8 @@ class SubstitutionTemplate(common._TemplateHandler):
             context.write('Node type: {0}'.format(context.style.type(self._template.node_type.name)))
             self._topology.dump(self._template.mappings, context, 'Mappings')
 
-    def coerce(self):
-        pass
+    def coerce(self, **kwargs):
+        self._topology.coerce(self._template.mappings, **kwargs)
 
     def instantiate(self, instance_cls):
         return instance_cls(node_type=self._template.node_type,
@@ -452,8 +470,8 @@ class RelationshipTemplate(common._TemplateHandler):
             self._topology.dump(self._template.properties, context, 'Properties')
             self._topology.dump(self._template.interface_templates, context, 'Interface Templates')
 
-    def coerce(self):
-        pass
+    def coerce(self, **kwargs):
+        self._coerce(self._template.properties, self._template.interface_templates, **kwargs)
 
     def instantiate(self, instance_cls):
         relationship = instance_cls(
@@ -499,8 +517,10 @@ class OperationTemplate(common._TemplateHandler):
             if self._template.function is not None:
                 context.write('Function: {0}'.format(context.style.literal(self._template.function)))
 
-    def coerce(self):
-        pass
+    def coerce(self, **kwargs):
+        self._coerce(self._template.inputs,
+                     self._template.configurations,
+                     **kwargs)
 
     def instantiate(self, instance_cls):
         operation = instance_cls(
@@ -527,3 +547,11 @@ class OperationTemplate(common._TemplateHandler):
     def validate(self):
         self._validate(self._template.inputs,
                        self._template.configurations)
+
+
+class PluginSpecification(common._TemplateHandler):
+    def instantiate(self, **kwargs):
+        pass
+
+    def dump(self, context):
+        pass

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a9640765/aria/parser/consumption/modeling.py
----------------------------------------------------------------------
diff --git a/aria/parser/consumption/modeling.py b/aria/parser/consumption/modeling.py
index 569b506..2d4f271 100644
--- a/aria/parser/consumption/modeling.py
+++ b/aria/parser/consumption/modeling.py
@@ -45,7 +45,7 @@ class CoerceServiceTemplateValues(Consumer):
     """
 
     def consume(self):
-        self.context.modeling.template.coerce_values(True)
+        self.handler.coerce(self.context.modeling.template, report_issues=True)
 
 
 class ValidateServiceTemplate(Consumer):
@@ -95,7 +95,7 @@ class Types(Consumer):
             raw = self.context.modeling.types_as_raw
             self.context.write(json_dumps(raw, indent=indent))
         else:
-            self.context.modeling.template.dump_types()
+            self.handler.dump_types(self.context, self.context.modeling.template)
 
 
 class InstantiateServiceInstance(Consumer):
@@ -137,7 +137,7 @@ class CoerceServiceInstanceValues(Consumer):
     """
 
     def consume(self):
-        self.context.modeling.instance.coerce_values(True)
+        self.handler.coerce(self.context.modeling.instance, report_issues=True)
 
 
 class ValidateServiceInstance(Consumer):


Mime
View raw message