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: fixed alot of dump issues, and a tiny issue with execution resuming. The last place consumers are used is under the reading of the blueprint itself. Remodel the exception handling (and reporting) still remain
Date Tue, 25 Jul 2017 14:37:12 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-174-Refactor-instantiation-phase 4ae0e5f99 -> 50d4c1de5


fixed alot of dump issues, and a tiny issue with execution resuming. The last place consumers are used is under the reading of the blueprint itself. Remodel the exception handling (and reporting) still remain


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

Branch: refs/heads/ARIA-174-Refactor-instantiation-phase
Commit: 50d4c1de528ade07f3b64eff414d266026e66743
Parents: 4ae0e5f
Author: max-orlov <maxim@gigaspaces.com>
Authored: Tue Jul 25 17:37:07 2017 +0300
Committer: max-orlov <maxim@gigaspaces.com>
Committed: Tue Jul 25 17:37:07 2017 +0300

----------------------------------------------------------------------
 aria/cli/commands/executions.py        |   2 +-
 aria/cli/commands/service_templates.py |   5 +-
 aria/cli/commands/services.py          |   6 +-
 aria/core.py                           |  20 ++-
 aria/orchestrator/topology/__init__.py |  54 +++---
 aria/orchestrator/topology/common.py   |   2 +-
 aria/orchestrator/topology/instance.py | 266 ++++++++++++++--------------
 aria/orchestrator/topology/template.py | 253 +++++++++++++-------------
 aria/parser/consumption/modeling.py    |   1 -
 9 files changed, 308 insertions(+), 301 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/50d4c1de/aria/cli/commands/executions.py
----------------------------------------------------------------------
diff --git a/aria/cli/commands/executions.py b/aria/cli/commands/executions.py
index 4783442..f130d95 100644
--- a/aria/cli/commands/executions.py
+++ b/aria/cli/commands/executions.py
@@ -181,7 +181,7 @@ def resume(execution_id,
     executor = DryExecutor() if dry else None  # use WorkflowRunner's default executor
 
     execution = model_storage.execution.get(execution_id)
-    if execution.status != execution.status.CANCELLED:
+    if execution.status != execution.CANCELLED:
         logger.info("Can't resume execution {execution.id} - "
                     "execution is in status {execution.status}. "
                     "Can only resume executions in status {valid_status}"

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/50d4c1de/aria/cli/commands/service_templates.py
----------------------------------------------------------------------
diff --git a/aria/cli/commands/service_templates.py b/aria/cli/commands/service_templates.py
index c455eb3..d1a9479 100644
--- a/aria/cli/commands/service_templates.py
+++ b/aria/cli/commands/service_templates.py
@@ -73,10 +73,9 @@ def show(service_template_name, model_storage, mode_full, mode_types, format_jso
         elif format_yaml:
             console.puts(formatting.yaml_dumps(collections.prune(service_template.as_raw)))
         else:
-            service_template.dump()
+            logger.info(topology.handler.dump(service_template))
     elif mode_types:
-        context = consumption.ConsumptionContext()
-        topology.handler.dump_types(context, service_template)
+        logger.info(topology.handler.dump_types(service_template=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/50d4c1de/aria/cli/commands/services.py
----------------------------------------------------------------------
diff --git a/aria/cli/commands/services.py b/aria/cli/commands/services.py
index a99f5b3..43faf37 100644
--- a/aria/cli/commands/services.py
+++ b/aria/cli/commands/services.py
@@ -20,6 +20,7 @@ CLI ``services`` sub-commands.
 import os
 from StringIO import StringIO
 
+from aria.orchestrator import topology
 from . import service_templates
 from .. import helptexts
 from .. import table
@@ -73,10 +74,9 @@ def show(service_name, model_storage, mode_full, mode_graph, format_json, format
         elif format_yaml:
             console.puts(formatting.yaml_dumps(collections.prune(service.as_raw)))
         else:
-            service.dump()
+            logger.info(topology.handler.dump(service))
     elif mode_graph:
-        consumption.ConsumptionContext()
-        service.dump_graph()
+        logger.info(topology.handler.dump_graph(service))
     else:
         logger.info('Showing service {0}...'.format(service_name))
         service_dict = service.to_dict()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/50d4c1de/aria/core.py
----------------------------------------------------------------------
diff --git a/aria/core.py b/aria/core.py
index 9ae45b5..77ed3de 100644
--- a/aria/core.py
+++ b/aria/core.py
@@ -74,8 +74,22 @@ class Core(object):
         # setting no autoflush for the duration of instantiation - this helps avoid dependency
         # constraints as they're being set up
         with storage_session.no_autoflush:
-            service = topology.Handler(self.model_storage).instantiate(
-                service_template, inputs=inputs)
+
+            handler = topology.Handler(self.model_storage)
+            service = handler.instantiate(service_template, inputs=inputs)
+            handler.coerce(service)
+            handler.validate(service)
+            handler.satisfy_requirements(service)
+            handler.coerce(service)
+            handler.validate_capabilities(service)
+            handler.find_hosts(service)
+            handler.configure_operations(service)
+            handler.coerce(service)
+
+            # TODO: fix this
+            # if context.validation.dump_issues():
+            #     raise exceptions.InstantiationError('Failed to instantiate service template `{0}`'
+            #                                         .format(service_template.name))
 
         storage_session.flush()  # flushing so service.id would auto-populate
         service.name = service_name or '{0}_{1}'.format(service_template.name, service.id)
@@ -104,6 +118,8 @@ class Core(object):
     def _parse_service_template(service_template_path):
         context = consumption.ConsumptionContext()
         context.presentation.location = UriLocation(service_template_path)
+        # TODO: this is the last place which uses the consumer chains (since read is a proper Parser
+        # todo..based consumer, it has no place in the topology package).
         consumption.ConsumerChain(
             context,
             (

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/50d4c1de/aria/orchestrator/topology/__init__.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/topology/__init__.py b/aria/orchestrator/topology/__init__.py
index 9003c1e..5c7747b 100644
--- a/aria/orchestrator/topology/__init__.py
+++ b/aria/orchestrator/topology/__init__.py
@@ -12,10 +12,10 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-
 from StringIO import StringIO
 
 from ...modeling import models
+from ...utils import console
 from . import (
     template,
     instance,
@@ -51,12 +51,13 @@ class Handler(object):
     }
 
     class TopologyStylizer(object):
-        def __init__(self, context):
-            self._context = context
+        def __init__(self):
+            from aria.parser.consumption import style
+            self._style = style.Style()
             self._str = StringIO()
 
         def write(self, str_):
-            self._str.write(str_)
+            console.puts(str_, stream=self._str)
 
         def __repr__(self):
             return self._str.getvalue()
@@ -66,7 +67,7 @@ class Handler(object):
 
         def __getattr__(self, item):
             try:
-                return getattr(self._context, item)
+                return getattr(self._style, item)
             except AttributeError:
                 return super(Handler.TopologyStylizer, self).__getattribute__(item)
 
@@ -113,26 +114,26 @@ class Handler(object):
             handler = self._handlers.get(model.__class__)
             return handler(self, model).validate(**kwargs)
 
-    def dump(self, model, context, **kwargs):
-        if not isinstance(context, self.TopologyStylizer):
-            # Wrap the context to contain a stringIO object
-            context = self.TopologyStylizer(context)
+    def dump(self, model, console=None, section_name=None, **kwargs):
+        console = console or self.TopologyStylizer()
+
+        # if model is empty, no need to print out the section name
+        if model and section_name:
+            console.write('{0}:'.format(section_name))
 
         if isinstance(model, dict):
-            return self.dump(model.values(), context, **kwargs)
+            return self.dump(model.values(), console=console, **kwargs)
         elif isinstance(model, list):
-            context.write('%s:' % model)
-            with context.style.indent:
+            with console.indent:
                 for value in model:
-                    self.dump(value, context, **kwargs)
+                    self.dump(value, console=console, **kwargs)
         elif model is not None:
             handler = self._handlers.get(model.__class__)
-            handler(self, model).dump(context, **kwargs)
-
-        return str(context)
+            handler(self, model).dump(console=console, **kwargs)
+        return str(console)
 
     def dump_graph(self, context, service, **kwargs):
-        context = self.TopologyStylizer(context)
+        context = self.TopologyStylizer(context.style)
         for node in service.nodes.itervalues():
             if not node.inbound_relationships:
                 self._dump_graph_node(context, node)
@@ -165,14 +166,17 @@ class Handler(object):
             handler = self._handlers.get(model.__class__)
             return handler(self, model).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)
+    def dump_types(self, service_template, console=None):
+        console = console or self.TopologyStylizer(console.style)
+        console.write(self.dump(service_template.node_types, console))
+        console.write(self.dump(service_template.group_types, console))
+        console.write(self.dump(service_template.capability_types, console))
+        console.write(self.dump(service_template.relationship_types, console))
+        console.write(self.dump(service_template.policy_types, console))
+        console.write(self.dump(service_template.artifact_types, console))
+        console.write(self.dump(service_template.interface_types, console))
+
+        return str(console)
 
     def satisfy_requirements(self, model, **kwargs):
         if isinstance(model, dict):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/50d4c1de/aria/orchestrator/topology/common.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/topology/common.py b/aria/orchestrator/topology/common.py
index 9437d56..2be38cd 100644
--- a/aria/orchestrator/topology/common.py
+++ b/aria/orchestrator/topology/common.py
@@ -33,7 +33,7 @@ class _Handler(object):
         for template in templates:
             self._topology.validate(template)
 
-    def dump(self, context):
+    def dump(self, console):
         raise NotImplementedError
 
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/50d4c1de/aria/orchestrator/topology/instance.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/topology/instance.py b/aria/orchestrator/topology/instance.py
index 3040b3b..5990792 100644
--- a/aria/orchestrator/topology/instance.py
+++ b/aria/orchestrator/topology/instance.py
@@ -30,24 +30,24 @@ class Artifact(common._InstanceHandler):
     def validate(self, **kwargs):
         self._topology.validate(self._model.properties)
 
-    def dump(self, context):
-        context.write(context.style.node(self._model.name))
+    def dump(self, console):
+        console.write(console.node(self._model.name))
         if self._model.description:
-            context.write(context.style.meta(self._model.description))
-        with context.style.indent:
-            context.write('Artifact type: {0}'.format(context.style.type(self._model.type.name)))
-            context.write('Source path: {0}'.format(
-                context.style.literal(self._model.source_path)))
+            console.write(console.meta(self._model.description))
+        with console.indent:
+            console.write('Artifact type: {0}'.format(console.type(self._model.type.name)))
+            console.write('Source path: {0}'.format(
+                console.literal(self._model.source_path)))
             if self._model.target_path is not None:
-                context.write('Target path: {0}'.format(
-                    context.style.literal(self._model.target_path)))
+                console.write('Target path: {0}'.format(
+                    console.literal(self._model.target_path)))
             if self._model.repository_url is not None:
-                context.write('Repository URL: {0}'.format(
-                    context.style.literal(self._model.repository_url)))
+                console.write('Repository URL: {0}'.format(
+                    console.literal(self._model.repository_url)))
             if self._model.repository_credential:
-                context.write('Repository credential: {0}'.format(
-                    context.style.literal(self._model.repository_credential)))
-            self._topology.dump(self._model.properties, context, 'Properties')
+                console.write('Repository credential: {0}'.format(
+                    console.literal(self._model.repository_credential)))
+            self._topology.dump(self._model.properties, console, 'Properties')
             
 
 class Capability(common._InstanceHandler):
@@ -57,17 +57,17 @@ class Capability(common._InstanceHandler):
     def validate(self, **kwargs):
         self._topology.validate(self._model.properties)
 
-    def dump(self, context):
-        context.write(context.style.node(self._model.name))
-        with context.style.indent:
-            context.write('Type: {0}'.format(context.style.type(self._model.type.name)))
-            context.write('Occurrences: {0:d} ({1:d}{2})'.format(
+    def dump(self, console):
+        console.write(console.node(self._model.name))
+        with console.indent:
+            console.write('Type: {0}'.format(console.type(self._model.type.name)))
+            console.write('Occurrences: {0:d} ({1:d}{2})'.format(
                 self._model.occurrences,
                 self._model.min_occurrences or 0,
                 ' to {0:d}'.format(self._model.max_occurrences)
                 if self._model.max_occurrences is not None
                 else ' or more'))
-            self._topology.dump(self._model.properties, context, 'Properties')
+            self._topology.dump(self._model.properties, console, 'Properties')
 
 
 class Group(common._OperatorHolderHandler):
@@ -79,17 +79,17 @@ class Group(common._OperatorHolderHandler):
         self._validate(self._model.properties,
                        self._model.interfaces)
 
-    def dump(self, context):
-        context.write('Group: {0}'.format(context.style.node(self._model.name)))
-        with context.style.indent:
-            context.write('Type: {0}'.format(context.style.type(self._model.type.name)))
-            self._topology.dump(self._model.properties, context, 'Properties')
-            self._topology.dump(self._model.interfaces, context, 'Interfaces')
+    def dump(self, console):
+        console.write('Group: {0}'.format(console.node(self._model.name)))
+        with console.indent:
+            console.write('Type: {0}'.format(console.type(self._model.type.name)))
+            self._topology.dump(self._model.properties, console, 'Properties')
+            self._topology.dump(self._model.interfaces, console, 'Interfaces')
             if self._model.nodes:
-                context.write('Member nodes:')
-                with context.style.indent:
+                console.write('Member nodes:')
+                with console.indent:
                     for node in self._model.nodes:
-                        context.write(context.style.node(node.name))
+                        console.write(console.node(node.name))
 
     def configure_operations(self):
         for interface in self._model.interfaces.values():
@@ -104,14 +104,14 @@ class Interface(common._OperatorHolderHandler):
         self._validate(self._model.inputs,
                        self._model.operations)
 
-    def dump(self, context):
-        context.write(context.style.node(self._model.name))
+    def dump(self, console):
+        console.write(console.node(self._model.name))
         if self._model.description:
-            context.write(context.style.meta(self._model.description))
-        with context.style.indent:
-            context.write('Interface type: {0}'.format(context.style.type(self._model.type.name)))
-            self._topology.dump(self._model.inputs, context, 'Inputs')
-            self._topology.dump(self._model.operations, context, 'Operations')
+            console.write(console.meta(self._model.description))
+        with console.indent:
+            console.write('Interface type: {0}'.format(console.type(self._model.type.name)))
+            self._topology.dump(self._model.inputs, console, 'Inputs')
+            self._topology.dump(self._model.operations, console, 'Operations')
 
     def configure_operations(self):
         for operation in self._model.operations.values():
@@ -147,17 +147,17 @@ class Node(common._OperatorHolderHandler):
                        self._model.capabilities,
                        self._model.outbound_relationships)
 
-    def dump(self, context):
-        context.write('Node: {0}'.format(context.style.node(self._model.name)))
-        with context.style.indent:
-            context.write('Type: {0}'.format(context.style.type(self._model.type.name)))
-            context.write('Template: {0}'.format(context.style.node(self._model.node_template.name)))
-            self._topology.dump(self._model.properties, context, 'Properties')
-            self._topology.dump(self._model.attributes, context, 'Attributes')
-            self._topology.dump(self._model.interfaces, context, 'Interfaces')
-            self._topology.dump(self._model.artifacts, context, 'Artifacts')
-            self._topology.dump(self._model.capabilities, context, 'Capabilities')
-            self._topology.dump(self._model.outbound_relationships, context, 'Relationships')
+    def dump(self, console):
+        console.write('Node: {0}'.format(console.node(self._model.name)))
+        with console.indent:
+            console.write('Type: {0}'.format(console.type(self._model.type.name)))
+            console.write('Template: {0}'.format(console.node(self._model.node_template.name)))
+            self._topology.dump(self._model.properties, console, 'Properties')
+            self._topology.dump(self._model.attributes, console, 'Attributes')
+            self._topology.dump(self._model.interfaces, console, 'Interfaces')
+            self._topology.dump(self._model.artifacts, console, 'Artifacts')
+            self._topology.dump(self._model.capabilities, console, 'Capabilities')
+            self._topology.dump(self._model.outbound_relationships, console, 'Relationships')
 
     def configure_operations(self):
         for interface in self._model.interfaces.values():
@@ -273,7 +273,7 @@ class Node(common._OperatorHolderHandler):
             else:
                 target_node_capability = None
 
-            return self._model.node_template.target_node_template, target_node_capability
+            return requirement_template.target_node_template, target_node_capability
 
         # Find first node that matches the type
         elif requirement_template.target_node_type is not None:
@@ -304,7 +304,7 @@ class Node(common._OperatorHolderHandler):
         # Do we match the required capability type?
         if (requirement_template.target_capability_type and
             requirement_template.target_capability_type.get_descendant(
-                self._model.type.name) is None):
+                capability_template.type.name) is None):
             return False
 
         # Are we in valid_source_node_types?
@@ -336,33 +336,33 @@ class Operation(common._OperatorHolderHandler):
                        self._model.configurations,
                        self._model.arguments)
 
-    def dump(self, context):
-        context.write(context.style.node(self._model.name))
+    def dump(self, console):
+        console.write(console.node(self._model.name))
         if self._model.description:
-            context.write(context.style.meta(self._model.description))
-        with context.style.indent:
+            console.write(console.meta(self._model.description))
+        with console.indent:
             if self._model.implementation is not None:
-                context.write('Implementation: {0}'.format(
-                    context.style.literal(self._model.implementation)))
+                console.write('Implementation: {0}'.format(
+                    console.literal(self._model.implementation)))
             if self._model.dependencies:
-                context.write(
+                console.write(
                     'Dependencies: {0}'.format(
-                        ', '.join((str(context.style.literal(v)) for v in self._model.dependencies))))
-            self._topology.dump(self._model.inputs, context, 'Inputs')
+                        ', '.join((str(console.literal(v)) for v in self._model.dependencies))))
+            self._topology.dump(self._model.inputs, console, 'Inputs')
             if self._model.executor is not None:
-                context.write('Executor: {0}'.format(context.style.literal(self._model.executor)))
+                console.write('Executor: {0}'.format(console.literal(self._model.executor)))
             if self._model.max_attempts is not None:
-                context.write('Max attempts: {0}'.format(context.style.literal(self._model.max_attempts)))
+                console.write('Max attempts: {0}'.format(console.literal(self._model.max_attempts)))
             if self._model.retry_interval is not None:
-                context.write('Retry interval: {0}'.format(
-                    context.style.literal(self._model.retry_interval)))
+                console.write('Retry interval: {0}'.format(
+                    console.literal(self._model.retry_interval)))
             if self._model.plugin is not None:
-                context.write('Plugin: {0}'.format(
-                    context.style.literal(self._model.plugin.name)))
-            self._topology.dump(self._model.configurations, context, 'Configuration')
+                console.write('Plugin: {0}'.format(
+                    console.literal(self._model.plugin.name)))
+            self._topology.dump(self._model.configurations, console, 'Configuration')
             if self._model.function is not None:
-                context.write('Function: {0}'.format(context.style.literal(self._model.function)))
-            self._topology.dump(self._model.arguments, context, 'Arguments')
+                console.write('Function: {0}'.format(console.literal(self._model.function)))
+            self._topology.dump(self._model.arguments, console, 'Arguments')
 
     def configure_operations(self):
         if self._model.implementation is None and self._model.function is None:
@@ -412,21 +412,21 @@ class Policy(common._InstanceHandler):
     def validate(self, **kwargs):
         self._topology.validate(self._model.properties)
 
-    def dump(self, context):
-        context.write('Policy: {0}'.format(context.style.node(self._model.name)))
-        with context.style.indent:
-            context.write('Type: {0}'.format(context.style.type(self._model.type.name)))
-            self._topology.dump(self._model.properties, context, 'Properties')
+    def dump(self, console):
+        console.write('Policy: {0}'.format(console.node(self._model.name)))
+        with console.indent:
+            console.write('Type: {0}'.format(console.type(self._model.type.name)))
+            self._topology.dump(self._model.properties, console, 'Properties')
             if self._model.nodes:
-                context.write('Target nodes:')
-                with context.style.indent:
+                console.write('Target nodes:')
+                with console.indent:
                     for node in self._model.nodes:
-                        context.write(context.style.node(node.name))
+                        console.write(console.node(node.name))
             if self._model.groups:
-                context.write('Target groups:')
-                with context.style.indent:
+                console.write('Target groups:')
+                with console.indent:
                     for group in self._model.groups:
-                        context.write(context.style.node(group.name))
+                        console.write(console.node(group.name))
 
 
 class Relationship(common._OperatorHolderHandler):
@@ -439,25 +439,25 @@ class Relationship(common._OperatorHolderHandler):
         self._validate(self._model.properties,
                        self._model.interfaces)
 
-    def dump(self, context):
+    def dump(self, console):
         if self._model.name:
-            context.write('{0} ->'.format(context.style.node(self._model.name)))
+            console.write('{0} ->'.format(console.node(self._model.name)))
         else:
-            context.write('->')
-        with context.style.indent:
-            context.write('Node: {0}'.format(context.style.node(self._model.target_node.name)))
+            console.write('->')
+        with console.indent:
+            console.write('Node: {0}'.format(console.node(self._model.target_node.name)))
             if self._model.target_capability:
-                context.write('Capability: {0}'.format(context.style.node(
+                console.write('Capability: {0}'.format(console.node(
                     self._model.target_capability.name)))
             if self._model.type is not None:
-                context.write('Relationship type: {0}'.format(
-                    context.style.type(self._model.type.name)))
+                console.write('Relationship type: {0}'.format(
+                    console.type(self._model.type.name)))
             if (self._model.relationship_template is not None and
                 self._model.relationship_template.name):
-                context.write('Relationship template: {0}'.format(
-                    context.style.node(self._model.relationship_template.name)))
-            self._topology.dump(self._model.properties, context, 'Properties')
-            self._topology.dump(self._model.interfaces, context, 'Interfaces')
+                console.write('Relationship template: {0}'.format(
+                    console.node(self._model.relationship_template.name)))
+            self._topology.dump(self._model.properties, console, 'Properties')
+            self._topology.dump(self._model.interfaces, console, 'Interfaces')
 
     def configure_operations(self):
         for interface in self._model.interfaces.values():
@@ -486,21 +486,17 @@ class Service(common._OperatorHolderHandler):
                        self._model.outputs,
                        self._model.workflows)
 
-    def dump(self, context):
+    def dump(self, console):
         if self._model.description is not None:
-            context.write(context.style.meta(self._model.description))
-        self._topology.dump(self._model.meta_data, context, 'Metadata')
-        for node in self._model.nodes.itervalues():
-            node.dump()
-        for group in self._model.groups.itervalues():
-            group.dump()
-        for policy in self._model.policies.itervalues():
-            policy.dump()
-        if self._model.substitution is not None:
-            self._model.substitution.dump()
-        self._topology.dump(self._model.inputs, context, 'Inputs')
-        self._topology.dump(self._model.outputs, context, 'Outputs')
-        self._topology.dump(self._model.workflows, context, 'Workflows')
+            console.write(console.meta(self._model.description))
+        self._topology.dump(self._model.meta_data, console, 'Metadata')
+        self._topology.dump(self._model.nodes, console)
+        self._topology.dump(self._model.groups, console)
+        self._topology.dump(self._model.policies, console)
+        self._topology.dump(self._model.substitution, console)
+        self._topology.dump(self._model.inputs, console, 'Inputs')
+        self._topology.dump(self._model.outputs, console, 'Outputs')
+        self._topology.dump(self._model.workflows, console, 'Workflows')
 
     def configure_operations(self):
         for node in self._model.nodes.itervalues():
@@ -529,11 +525,11 @@ class Substitution(common._InstanceHandler):
     def validate(self, **kwargs):
         self._topology.validate(self._model.mappings)
 
-    def dump(self, context):
-        context.write('Substitution:')
-        with context.style.indent:
-            context.write('Node type: {0}'.format(context.style.type(self._model.node_type.name)))
-            self._topology.dump(self._model.mappings, context, 'Mappings')
+    def dump(self, console):
+        console.write('Substitution:')
+        with console.indent:
+            console.write('Node type: {0}'.format(console.type(self._model.node_type.name)))
+            self._topology.dump(self._model.mappings, console, 'Mappings')
 
 
 class SubstitutionMapping(common._InstanceHandler):
@@ -549,25 +545,25 @@ class SubstitutionMapping(common._InstanceHandler):
             #                               formatting.safe_repr(self.node.name)),
             #                           level=validation.Issue.BETWEEN_TYPES)
 
-    def dump(self, context):
+    def dump(self, console):
         if self._model.capability is not None:
-            context.write('{0} -> {1}.{2}'.format(
-                context.style.node(self._model.name),
-                context.style.node(self._model.capability.node.name),
-                context.style.node(self._model.capability.name)))
+            console.write('{0} -> {1}.{2}'.format(
+                console.node(self._model.name),
+                console.node(self._model.capability.node.name),
+                console.node(self._model.capability.name)))
         else:
-            context.write('{0} -> {1}.{2}'.format(
-                context.style.node(self._model.name),
-                context.style.node(self._model.node.name),
-                context.style.node(self._model.requirement_template.name)))
+            console.write('{0} -> {1}.{2}'.format(
+                console.node(self._model.name),
+                console.node(self._model.node.name),
+                console.node(self._model.requirement_template.name)))
 
 
 class Metadata(common._InstanceHandler):
 
-    def dump(self, context):
-        context.write('{0}: {1}'.format(
-            context.style.property(self._topology.name),
-            context.style.literal(self._topology.value)))
+    def dump(self, console):
+        console.write('{0}: {1}'.format(
+            console.property(self._topology.name),
+            console.literal(self._topology.value)))
 
     def coerce(self):
         pass
@@ -581,18 +577,18 @@ class Metadata(common._InstanceHandler):
 
 class _Parameter(common._InstanceHandler):
 
-    def dump(self, context):
+    def dump(self, console):
         if self._model.type_name is not None:
-            context.write('{0}: {1} ({2})'.format(
-                context.style.property(self._model.name),
-                context.style.literal(formatting.as_raw(self._model.value)),
-                context.style.type(self._model.type_name)))
+            console.write('{0}: {1} ({2})'.format(
+                console.property(self._model.name),
+                console.literal(formatting.as_raw(self._model.value)),
+                console.type(self._model.type_name)))
         else:
-            context.write('{0}: {1}'.format(
-                context.style.property(self._model.name),
-                context.style.literal(formatting.as_raw(self._model.value))))
+            console.write('{0}: {1}'.format(
+                console.property(self._model.name),
+                console.literal(formatting.as_raw(self._model.value))))
         if self._model.description:
-            context.write(context.style.meta(self._model.description))
+            console.write(console.meta(self._model.description))
 
     def instantiate(self, instance_cls, **kwargs):
         return instance_cls(
@@ -634,9 +630,9 @@ class Type(common._InstanceHandler):
     def coerce(self):
         pass
 
-    def dump(self, context):
+    def dump(self, console):
         if self._model.name:
-            context.write(context.style.type(self._model.name))
-        with context.style.indent:
+            console.write(console.type(self._model.name))
+        with console.indent:
             for child in self._model.children:
-                self._topology.dump(context, child)
+                self._topology.dump(child, console)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/50d4c1de/aria/orchestrator/topology/template.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/topology/template.py b/aria/orchestrator/topology/template.py
index 8b78c7a..2d1319a 100644
--- a/aria/orchestrator/topology/template.py
+++ b/aria/orchestrator/topology/template.py
@@ -20,21 +20,17 @@ from . import utils, common
 
 
 class ServiceTemplate(common._TemplateHandler):
-    def dump(self, context):
+    def dump(self, console):
         if self._model.description is not None:
-            context.write(context.style.meta(self._model.description))
-        self._topology.dump(self._model.meta_data, context, 'Metadata')
-        for node_template in self._model.node_templates.itervalues():
-            node_template.dump()
-        for group_template in self._model.group_templates.itervalues():
-            group_template.dump()
-        for policy_template in self._model.policy_templates.itervalues():
-            policy_template.dump()
-        if self._model.substitution_template is not None:
-            self._model.substitution_template.dump()
-        self._topology.dump(self._model.inputs, context, 'Inputs')
-        self._topology.dump(self._model.outputs, context, 'Outputs')
-        self._topology.dump(self._model.workflow_templates, context, 'Workflow templates')
+            console.write(console.meta(self._model.description))
+        self._topology.dump(self._model.meta_data, console, 'Metadata')
+        self._topology.dump(self._model.node_templates, console)
+        self._topology.dump(self._model.group_templates, console)
+        self._topology.dump(self._model.policy_templates, console)
+        self._topology.dump(self._model.substitution_template, console)
+        self._topology.dump(self._model.inputs, console, 'Inputs')
+        self._topology.dump(self._model.outputs, console, 'Outputs')
+        self._topology.dump(self._model.workflow_templates, console, 'Workflow templates')
 
     def coerce(self, **kwargs):
         self._coerce(self._model.meta_data,
@@ -162,22 +158,22 @@ class ServiceTemplate(common._TemplateHandler):
 
 
 class ArtifactTemplate(common._TemplateHandler):
-    def dump(self, context):
-        context.write(context.style.node(self._model.name))
+    def dump(self, console):
+        console.write(console.node(self._model.name))
         if self._model.description:
-            context.write(context.style.meta(self._model.description))
-        with context.style.indent:
-            context.write('Artifact type: {0}'.format(context.style.type(self._model.type.name)))
-            context.write('Source path: {0}'.format(context.style.literal(self._model.source_path)))
+            console.write(console.meta(self._model.description))
+        with console.indent:
+            console.write('Artifact type: {0}'.format(console.type(self._model.type.name)))
+            console.write('Source path: {0}'.format(console.literal(self._model.source_path)))
             if self._model.target_path is not None:
-                context.write('Target path: {0}'.format(context.style.literal(self._model.target_path)))
+                console.write('Target path: {0}'.format(console.literal(self._model.target_path)))
             if self._model.repository_url is not None:
-                context.write('Repository URL: {0}'.format(
-                    context.style.literal(self._model.repository_url)))
+                console.write('Repository URL: {0}'.format(
+                    console.literal(self._model.repository_url)))
             if self._model.repository_credential:
-                context.write('Repository credential: {0}'.format(
-                    context.style.literal(self._model.repository_credential)))
-            self._topology.dump(self._model.properties, context, 'Properties')
+                console.write('Repository credential: {0}'.format(
+                    console.literal(self._model.repository_credential)))
+            self._topology.dump(self._model.properties, console, 'Properties')
 
     def coerce(self, **kwargs):
         self._topology.coerce(self._model.properties, **kwargs)
@@ -198,23 +194,23 @@ class ArtifactTemplate(common._TemplateHandler):
 
 
 class CapabilityTemplate(common._TemplateHandler):
-    def dump(self, context):
-        context.write(context.style.node(self._model.name))
+    def dump(self, console):
+        console.write(console.node(self._model.name))
         if self._model.description:
-            context.write(context.style.meta(self._model.description))
-        with context.style.indent:
-            context.write('Type: {0}'.format(context.style.type(self._model.type.name)))
-            context.write(
+            console.write(console.meta(self._model.description))
+        with console.indent:
+            console.write('Type: {0}'.format(console.type(self._model.type.name)))
+            console.write(
                 'Occurrences: {0:d}{1}'.format(
                     self._model.min_occurrences or 0,
                     ' to {0:d}'.format(self._model.max_occurrences)
                     if self._model.max_occurrences is not None
                     else ' or more'))
             if self._model.valid_source_node_types:
-                context.write('Valid source node types: {0}'.format(
-                    ', '.join((str(context.style.type(v.name))
+                console.write('Valid source node types: {0}'.format(
+                    ', '.join((str(console.type(v.name))
                                for v in self._model.valid_source_node_types))))
-            self._topology.dump(self._model.properties, context, 'Properties')
+            self._topology.dump(self._model.properties, console, 'Properties')
 
     def coerce(self):
         self._topology.coerce(self._model.properties)
@@ -232,33 +228,33 @@ class CapabilityTemplate(common._TemplateHandler):
 
 
 class RequirementTemplate(common._TemplateHandler):
-    def dump(self, context):
+    def dump(self, console):
         if self._model.name:
-            context.write(context.style.node(self._model.name))
+            console.write(console.node(self._model.name))
         else:
-            context.write('Requirement:')
-        with context.style.indent:
+            console.write('Requirement:')
+        with console.indent:
             if self._model.target_node_type is not None:
-                context.write('Target node type: {0}'.format(
-                    context.style.type(self._model.target_node_type.name)))
+                console.write('Target node type: {0}'.format(
+                    console.type(self._model.target_node_type.name)))
             elif self._model.target_node_template is not None:
-                context.write('Target node template: {0}'.format(
-                    context.style.node(self._model.target_node_template.name)))
+                console.write('Target node template: {0}'.format(
+                    console.node(self._model.target_node_template.name)))
             if self._model.target_capability_type is not None:
-                context.write('Target capability type: {0}'.format(
-                    context.style.type(self._model.target_capability_type.name)))
+                console.write('Target capability type: {0}'.format(
+                    console.type(self._model.target_capability_type.name)))
             elif self._model.target_capability_name is not None:
-                context.write('Target capability name: {0}'.format(
-                    context.style.node(self._model.target_capability_name)))
+                console.write('Target capability name: {0}'.format(
+                    console.node(self._model.target_capability_name)))
             if self._model.target_node_template_constraints:
-                context.write('Target node template constraints:')
-                with context.style.indent:
+                console.write('Target node template constraints:')
+                with console.indent:
                     for constraint in self._model.target_node_template_constraints:
-                        context.write(context.style.literal(constraint))
+                        console.write(console.literal(constraint))
             if self._model.relationship_template:
-                context.write('Relationship:')
-                with context.style.indent:
-                    self._model.relationship_template.dump()
+                console.write('Relationship:')
+                with console.indent:
+                    self._topology.dump(self._model.relationship_template, console)
 
     def coerce(self, **kwargs):
         self._topology.coerce(self._model.relationship_template, **kwargs)
@@ -276,17 +272,17 @@ class RequirementTemplate(common._TemplateHandler):
 
 
 class GroupTemplate(common._TemplateHandler):
-    def dump(self, context):
-        context.write('Group template: {0}'.format(context.style.node(self._model.name)))
+    def dump(self, console):
+        console.write('Group template: {0}'.format(console.node(self._model.name)))
         if self._model.description:
-            context.write(context.style.meta(self._model.description))
-        with context.style.indent:
-            context.write('Type: {0}'.format(context.style.type(self._model.type.name)))
-            self._topology.dump(self._model.properties, context, 'Properties')
-            self._topology.dump(self._model.interface_templates, context, 'Interface Templates')
+            console.write(console.meta(self._model.description))
+        with console.indent:
+            console.write('Type: {0}'.format(console.type(self._model.type.name)))
+            self._topology.dump(self._model.properties, console, 'Properties')
+            self._topology.dump(self._model.interface_templates, console, 'Interface Templates')
             if self._model.node_templates:
-                context.write('Member node templates: {0}'.format(', '.join(
-                    (str(context.style.node(v.name)) for v in self._model.node_templates))))
+                console.write('Member node templates: {0}'.format(', '.join(
+                    (str(console.node(v.name)) for v in self._model.node_templates))))
 
     def coerce(self, **kwargs):
         self._coerce(self._model.properties,
@@ -312,14 +308,14 @@ class GroupTemplate(common._TemplateHandler):
 
 
 class InterfaceTemplate(common._TemplateHandler):
-    def dump(self, context):
-        context.write(context.style.node(self._model.name))
+    def dump(self, console):
+        console.write(console.node(self._model.name))
         if self._model.description:
-            context.write(context.style.meta(self._model.description))
-        with context.style.indent:
-            context.write('Interface type: {0}'.format(context.style.type(self._model.type.name)))
-            self._topology.dump(self._model.inputs, context, 'Inputs')
-            self._topology.dump(self._model.operation_templates, context, 'Operation templates')
+            console.write(console.meta(self._model.description))
+        with console.indent:
+            console.write('Interface type: {0}'.format(console.type(self._model.type.name)))
+            self._topology.dump(self._model.inputs, console, 'Inputs')
+            self._topology.dump(self._model.operation_templates, console, 'Operation templates')
 
     def coerce(self, **kwargs):
         self._coerce(self._model.inputs,
@@ -342,18 +338,17 @@ class InterfaceTemplate(common._TemplateHandler):
 
 
 class NodeTemplate(common._TemplateHandler):
-    def dump(self, context):
-        context.write('Node template: {0}'.format(context.style.node(self._model.name)))
+    def dump(self, console):
+        console.write('Node template: {0}'.format(console.node(self._model.name)))
         if self._model.description:
-            context.write(context.style.meta(self._model.description))
-        with context.style.indent:
-            context.write('Type: {0}'.format(context.style.type(self._model.type.name)))
-            self._topology.dump(self._model.properties, context, 'Properties')
-            self._topology.dump(self._model.attributes, context, 'Attributes')
-            self._topology.dump(self._model.interface_templates, context, 'Interface Templates')
-            self._topology.dump(self._model.artifact_templates, context, 'Artifact templates')
-            self._topology.dump(self._model.capability_templates, context, 'Capability templates')
-            self._topology.dump(self._model.requirement_templates, context, 'Requirement templates')
+            console.write(console.meta(self._model.description))
+        console.write('Type: {0}'.format(console.type(self._model.type.name)))
+        self._topology.dump(self._model.properties, console, 'Properties')
+        self._topology.dump(self._model.attributes, console, 'Attributes')
+        self._topology.dump(self._model.interface_templates, console, 'Interface Templates')
+        self._topology.dump(self._model.artifact_templates, console, 'Artifact Templates')
+        self._topology.dump(self._model.capability_templates, console, 'Capability Templates')
+        self._topology.dump(self._model.requirement_templates, console, 'Requirement Templates')
 
     def coerce(self, **kwargs):
         self._coerce(self._model.properties,
@@ -379,11 +374,9 @@ class NodeTemplate(common._TemplateHandler):
         node.capabilities = self._topology.instantiate(self._model.capability_templates)
 
         # Default attributes
-        if ('tosca_name' in node.attributes) \
-                and (node.attributes['tosca_name'].type_name == 'string'):
+        if 'tosca_name' in node.attributes and node.attributes['tosca_name'].type_name == 'string':
             node.attributes['tosca_name'].value = self._model.name
-        if 'tosca_id' in node.attributes \
-                and (node.attributes['tosca_id'].type_name == 'string'):
+        if 'tosca_id' in node.attributes and node.attributes['tosca_id'].type_name == 'string':
             node.attributes['tosca_id'].value = node.name
 
         return node
@@ -398,19 +391,19 @@ class NodeTemplate(common._TemplateHandler):
 
 
 class PolicyTemplate(common._TemplateHandler):
-    def dump(self, context):
-        context.write('Policy template: {0}'.format(context.style.node(self._model.name)))
+    def dump(self, console):
+        console.write('Policy template: {0}'.format(console.node(self._model.name)))
         if self._model.description:
-            context.write(context.style.meta(self._model.description))
-        with context.style.indent:
-            context.write('Type: {0}'.format(context.style.type(self._model.type.name)))
-            self._topology.dump(self._model.properties, context, 'Properties')
+            console.write(console.meta(self._model.description))
+        with console.indent:
+            console.write('Type: {0}'.format(console.type(self._model.type.name)))
+            self._topology.dump(self._model.properties, console, 'Properties')
             if self._model.node_templates:
-                context.write('Target node templates: {0}'.format(', '.join(
-                    (str(context.style.node(v.name)) for v in self._model.node_templates))))
+                console.write('Target node templates: {0}'.format(', '.join(
+                    (str(console.node(v.name)) for v in self._model.node_templates))))
             if self._model.group_templates:
-                context.write('Target group templates: {0}'.format(', '.join(
-                    (str(context.style.node(v.name)) for v in self._model.group_templates))))
+                console.write('Target group templates: {0}'.format(', '.join(
+                    (str(console.node(v.name)) for v in self._model.group_templates))))
 
     def coerce(self, **kwargs):
         self._topology.coerce(self._model.properties, **kwargs)
@@ -437,11 +430,11 @@ class PolicyTemplate(common._TemplateHandler):
 
 class SubstitutionTemplate(common._TemplateHandler):
 
-    def dump(self, context):
-        context.write('Substitution template:')
-        with context.style.indent:
-            context.write('Node type: {0}'.format(context.style.type(self._model.node_type.name)))
-            self._topology.dump(self._model.mappings, context, 'Mappings')
+    def dump(self, console):
+        console.write('Substitution template:')
+        with console.indent:
+            console.write('Node type: {0}'.format(console.type(self._model.node_type.name)))
+            self._topology.dump(self._model.mappings, console, 'Mappings')
 
     def coerce(self, **kwargs):
         self._topology.coerce(self._model.mappings, **kwargs)
@@ -456,15 +449,15 @@ class SubstitutionTemplate(common._TemplateHandler):
 
 class SubstitutionTemplateMapping(common._TemplateHandler):
 
-    def dump(self, context):
+    def dump(self, console):
         if self._topology.capability_template is not None:
             node_template = self._topology.capability_template.node_template
         else:
             node_template = self._topology.requirement_template.node_template
-        context.write('{0} -> {1}.{2}'.format(
-            context.style.node(self._topology.name),
-            context.style.node(node_template.name),
-            context.style.node(self._topology.capability_template.name
+        console.write('{0} -> {1}.{2}'.format(
+            console.node(self._topology.name),
+            console.node(node_template.name),
+            console.node(self._topology.capability_template.name
                                if self._topology.capability_template
                                else self._topology.requirement_template.name)))
 
@@ -516,17 +509,17 @@ class SubstitutionTemplateMapping(common._TemplateHandler):
 
 
 class RelationshipTemplate(common._TemplateHandler):
-    def dump(self, context):
+    def dump(self, console):
         if self._model.type is not None:
-            context.write('Relationship type: {0}'.format(context.style.type(self._model.type.name)))
+            console.write('Relationship type: {0}'.format(console.type(self._model.type.name)))
         else:
-            context.write('Relationship template: {0}'.format(
-                context.style.node(self._model.name)))
+            console.write('Relationship template: {0}'.format(
+                console.node(self._model.name)))
         if self._model.description:
-            context.write(context.style.meta(self._model.description))
-        with context.style.indent:
-            self._topology.dump(self._model.properties, context, 'Properties')
-            self._topology.dump(self._model.interface_templates, context, 'Interface Templates')
+            console.write(console.meta(self._model.description))
+        with console.indent:
+            self._topology.dump(self._model.properties, console, 'Properties')
+            self._topology.dump(self._model.interface_templates, console, 'Interface Templates')
 
     def coerce(self, **kwargs):
         self._coerce(self._model.properties, self._model.interface_templates, **kwargs)
@@ -549,31 +542,31 @@ class RelationshipTemplate(common._TemplateHandler):
 
 class OperationTemplate(common._TemplateHandler):
 
-    def dump(self, context):
-        context.write(context.style.node(self._model.name))
+    def dump(self, console):
+        console.write(console.node(self._model.name))
         if self._model.description:
-            context.write(context.style.meta(self._model.description))
-        with context.style.indent:
+            console.write(console.meta(self._model.description))
+        with console.indent:
             if self._model.implementation is not None:
-                context.write('Implementation: {0}'.format(
-                    context.style.literal(self._model.implementation)))
+                console.write('Implementation: {0}'.format(
+                    console.literal(self._model.implementation)))
             if self._model.dependencies:
-                context.write('Dependencies: {0}'.format(
-                    ', '.join((str(context.style.literal(v)) for v in self._model.dependencies))))
-            self._topology.dump(self._model.inputs, context, 'Inputs')
+                console.write('Dependencies: {0}'.format(
+                    ', '.join((str(console.literal(v)) for v in self._model.dependencies))))
+            self._topology.dump(self._model.inputs, console, 'Inputs')
             if self._model.executor is not None:
-                context.write('Executor: {0}'.format(context.style.literal(self._model.executor)))
+                console.write('Executor: {0}'.format(console.literal(self._model.executor)))
             if self._model.max_attempts is not None:
-                context.write('Max attempts: {0}'.format(context.style.literal(self._model.max_attempts)))
+                console.write('Max attempts: {0}'.format(console.literal(self._model.max_attempts)))
             if self._model.retry_interval is not None:
-                context.write('Retry interval: {0}'.format(
-                    context.style.literal(self._model.retry_interval)))
+                console.write('Retry interval: {0}'.format(
+                    console.literal(self._model.retry_interval)))
             if self._model.plugin_specification is not None:
-                context.write('Plugin specification: {0}'.format(
-                    context.style.literal(self._model.plugin_specification.name)))
-            self._topology.dump(self._model.configurations, context, 'Configuration')
+                console.write('Plugin specification: {0}'.format(
+                    console.literal(self._model.plugin_specification.name)))
+            self._topology.dump(self._model.configurations, console, 'Configuration')
             if self._model.function is not None:
-                context.write('Function: {0}'.format(context.style.literal(self._model.function)))
+                console.write('Function: {0}'.format(console.literal(self._model.function)))
 
     def coerce(self, **kwargs):
         self._coerce(self._model.inputs,
@@ -611,5 +604,5 @@ class PluginSpecification(common._TemplateHandler):
     def instantiate(self, **kwargs):
         pass
 
-    def dump(self, context):
+    def dump(self, console):
         pass

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/50d4c1de/aria/parser/consumption/modeling.py
----------------------------------------------------------------------
diff --git a/aria/parser/consumption/modeling.py b/aria/parser/consumption/modeling.py
index 5774630..8216816 100644
--- a/aria/parser/consumption/modeling.py
+++ b/aria/parser/consumption/modeling.py
@@ -112,7 +112,6 @@ class InstantiateServiceInstance(Consumer):
             self.context.modeling.template,
             inputs=dict(self.context.modeling.inputs)
         )
-
         ConsumerChain(
             self.context,
             (


Mime
View raw message