Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-174-Refactor-instantiation-phase 0f10ec758 -> 2a80b22ca (forced update)
review 1 - fixups 2 Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/2a80b22c Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/2a80b22c Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/2a80b22c Branch: refs/heads/ARIA-174-Refactor-instantiation-phase Commit: 2a80b22ca5e538aa0b0137f398fa68c327b01ce7 Parents: a33ba12 Author: max-orlov <[email protected]> Authored: Thu Aug 3 16:07:21 2017 +0300 Committer: max-orlov <[email protected]> Committed: Thu Aug 3 16:23:56 2017 +0300 ---------------------------------------------------------------------- aria/orchestrator/topology/common.py | 4 -- aria/orchestrator/topology/instance_handler.py | 23 +++++++---- aria/orchestrator/topology/template_handler.py | 45 ++++++++++++++------- aria/orchestrator/topology/topology.py | 1 - aria/parser/consumption/modeling.py | 1 - tests/parser/service_templates.py | 3 +- 6 files changed, 48 insertions(+), 29 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/2a80b22c/aria/orchestrator/topology/common.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/topology/common.py b/aria/orchestrator/topology/common.py index 7b02fd2..9090d49 100644 --- a/aria/orchestrator/topology/common.py +++ b/aria/orchestrator/topology/common.py @@ -43,10 +43,6 @@ class TemplateHandlerBase(HandlerBase): raise NotImplementedError -class InstanceHandlerBase(HandlerBase): - pass - - class ActorHandlerBase(HandlerBase): def configure_operations(self): raise NotImplementedError http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/2a80b22c/aria/orchestrator/topology/instance_handler.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/topology/instance_handler.py b/aria/orchestrator/topology/instance_handler.py index 833c3a3..1f2bac0 100644 --- a/aria/orchestrator/topology/instance_handler.py +++ b/aria/orchestrator/topology/instance_handler.py @@ -156,7 +156,8 @@ class Node(common.ActorHandlerBase): self._topology.dump(self._model.interfaces, out_stream, title='Interfaces') self._topology.dump(self._model.artifacts, out_stream, title='Artifacts') self._topology.dump(self._model.capabilities, out_stream, title='Capabilities') - self._topology.dump(self._model.outbound_relationships, out_stream, title='Relationships') + self._topology.dump(self._model.outbound_relationships, out_stream, + title='Relationships') def configure_operations(self): for interface in self._model.interfaces.values(): @@ -362,11 +363,12 @@ class Operation(common.ActorHandlerBase): out_stream.literal_style(self._model.implementation))) if self._model.dependencies: out_stream.write( - 'Dependencies: {0}'.format( - ', '.join((str(out_stream.literal_style(v)) for v in self._model.dependencies)))) + 'Dependencies: {0}'.format(', '.join((str(out_stream.literal_style(v)) + for v in self._model.dependencies)))) self._topology.dump(self._model.inputs, out_stream, title='Inputs') if self._model.executor is not None: - out_stream.write('Executor: {0}'.format(out_stream.literal_style(self._model.executor))) + out_stream.write('Executor: {0}'.format(out_stream.literal_style( + self._model.executor))) if self._model.max_attempts is not None: out_stream.write('Max attempts: {0}'.format(out_stream.literal_style( self._model.max_attempts))) @@ -378,7 +380,8 @@ class Operation(common.ActorHandlerBase): out_stream.literal_style(self._model.plugin.name))) self._topology.dump(self._model.configurations, out_stream, title='Configuration') if self._model.function is not None: - out_stream.write('Function: {0}'.format(out_stream.literal_style(self._model.function))) + out_stream.write('Function: {0}'.format(out_stream.literal_style( + self._model.function))) self._topology.dump(self._model.arguments, out_stream, title='Arguments') def configure_operations(self): @@ -461,7 +464,8 @@ class Relationship(common.ActorHandlerBase): else: out_stream.write('->') with out_stream.indent(): - out_stream.write('Node: {0}'.format(out_stream.node_style(self._model.target_node.name))) + out_stream.write('Node: {0}'.format(out_stream.node_style( + self._model.target_node.name))) if self._model.target_capability: out_stream.write('Capability: {0}'.format(out_stream.node_style( self._model.target_capability.name))) @@ -545,12 +549,16 @@ class Substitution(common.InstanceHandlerBase): def dump(self, out_stream): out_stream.write('Substitution:') with out_stream.indent(): - out_stream.write('Node type: {0}'.format(out_stream.type_style(self._model.node_type.name))) + out_stream.write('Node type: {0}'.format(out_stream.type_style( + self._model.node_type.name))) self._topology.dump(self._model.mappings, out_stream, title='Mappings') class SubstitutionMapping(common.InstanceHandlerBase): + def coerce(self, **kwargs): + pass + def validate(self, **_): if (self._model.capability is None) and (self._model.requirement_template is None): self._topology.report( @@ -623,6 +631,7 @@ class _Parameter(common.InstanceHandlerBase): # A final evaluation can safely replace the existing value self._model._value = evaluation.value + class Attribute(_Parameter): pass http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/2a80b22c/aria/orchestrator/topology/template_handler.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/topology/template_handler.py b/aria/orchestrator/topology/template_handler.py index 6d52e5d..8f57ace 100644 --- a/aria/orchestrator/topology/template_handler.py +++ b/aria/orchestrator/topology/template_handler.py @@ -94,8 +94,8 @@ class ServiceTemplate(common.TemplateHandlerBase): for plugin in plugins: if (plugin.name == plugin_specification.name and (plugin_specification.version is None or - versions.VersionString(plugin.package_version) >= - plugin_specification.version) + versions.VersionString(plugin.package_version) >= + plugin_specification.version) ): matching_plugins.append(plugin) plugin_specification.plugin = None @@ -151,8 +151,10 @@ class ArtifactTemplate(common.TemplateHandlerBase): if self._model.description: out_stream.write(out_stream.meta_style(self._model.description)) with out_stream.indent(): - out_stream.write('Artifact type: {0}'.format(out_stream.type_style(self._model.type_style.name))) - out_stream.write('Source path: {0}'.format(out_stream.literal_style(self._model.source_path))) + out_stream.write('Artifact type: {0}'.format(out_stream.type_style( + self._model.type_style.name))) + out_stream.write('Source path: {0}'.format(out_stream.literal_style( + self._model.source_path))) if self._model.target_path is not None: out_stream.write('Target path: {0}'.format(out_stream.literal_style( self._model.target_path))) @@ -263,7 +265,8 @@ class GroupTemplate(common.TemplateHandlerBase): with out_stream.indent(): out_stream.write('Type: {0}'.format(out_stream.type_style(self._model.type_style.name))) self._topology.dump(self._model.properties, out_stream, title='Properties') - self._topology.dump(self._model.interface_templates, out_stream, title='Interface Templates') + self._topology.dump(self._model.interface_templates, out_stream, + title='Interface Templates') if self._model.node_templates: out_stream.write('Member node templates: {0}'.format(', '.join( (str(out_stream.node_style(v.name)) for v in self._model.node_templates)))) @@ -298,9 +301,11 @@ class InterfaceTemplate(common.TemplateHandlerBase): if self._model.description: out_stream.write(out_stream.meta_style(self._model.description)) with out_stream.indent(): - out_stream.write('Interface type: {0}'.format(out_stream.type_style(self._model.type_style.name))) + out_stream.write('Interface type: {0}'.format(out_stream.type_style( + self._model.type_style.name))) self._topology.dump(self._model.inputs, out_stream, title='Inputs') - self._topology.dump(self._model.operation_templates, out_stream, title='Operation templates') + self._topology.dump(self._model.operation_templates, out_stream, + title='Operation templates') def coerce(self, **kwargs): self._coerce(self._model.inputs, @@ -425,7 +430,8 @@ class SubstitutionTemplate(common.TemplateHandlerBase): def dump(self, out_stream): out_stream.write('Substitution template:') with out_stream.indent(): - out_stream.write('Node type: {0}'.format(out_stream.type_style(self._model.node_type.name))) + out_stream.write('Node type: {0}'.format(out_stream.type_style( + self._model.node_type.name))) self._topology.dump(self._model.mappings, out_stream, title='Mappings') def coerce(self, **kwargs): @@ -450,8 +456,8 @@ class SubstitutionTemplateMapping(common.TemplateHandlerBase): out_stream.node_style(self._model.name), out_stream.node_style(node_template.name), out_stream.node_style(self._model.capability_template.name - if self._model.capability_template - else self._model.requirement_template.name))) + if self._model.capability_template + else self._model.requirement_template.name))) def coerce(self, **_): pass @@ -504,7 +510,8 @@ class RelationshipTemplate(common.TemplateHandlerBase): out_stream.write(out_stream.meta_style(self._model.description)) with out_stream.indent(): self._topology.dump(self._model.properties, out_stream, title='Properties') - self._topology.dump(self._model.interface_templates, out_stream, title='Interface Templates') + self._topology.dump(self._model.interface_templates, out_stream, + title='Interface Templates') def coerce(self, **kwargs): self._coerce(self._model.properties, self._model.interface_templates, **kwargs) @@ -534,11 +541,12 @@ class OperationTemplate(common.TemplateHandlerBase): out_stream.write('Implementation: {0}'.format( out_stream.literal_style(self._model.implementation))) if self._model.dependencies: - out_stream.write('Dependencies: {0}'.format( - ', '.join((str(out_stream.literal_style(v)) for v in self._model.dependencies)))) + out_stream.write('Dependencies: {0}'.format(', '.join( + (str(out_stream.literal_style(v)) for v in self._model.dependencies)))) self._topology.dump(self._model.inputs, out_stream, title='Inputs') if self._model.executor is not None: - out_stream.write('Executor: {0}'.format(out_stream.literal_style(self._model.executor))) + out_stream.write('Executor: {0}'.format( + out_stream.literal_style(self._model.executor))) if self._model.max_attempts is not None: out_stream.write('Max attempts: {0}'.format(out_stream.literal_style( self._model.max_attempts))) @@ -550,7 +558,8 @@ class OperationTemplate(common.TemplateHandlerBase): out_stream.literal_style(self._model.plugin_specification.name))) self._topology.dump(self._model.configurations, out_stream, title='Configuration') if self._model.function is not None: - out_stream.write('Function: {0}'.format(out_stream.literal_style(self._model.function))) + out_stream.write('Function: {0}'.format(out_stream.literal_style( + self._model.function))) def coerce(self, **kwargs): self._coerce(self._model.inputs, @@ -586,6 +595,12 @@ class OperationTemplate(common.TemplateHandlerBase): class PluginSpecification(common.TemplateHandlerBase): + def validate(self, **kwargs): + pass + + def coerce(self, **kwargs): + pass + def instantiate(self, **_): pass http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/2a80b22c/aria/orchestrator/topology/topology.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/topology/topology.py b/aria/orchestrator/topology/topology.py index b81f61d..96ee4f9 100644 --- a/aria/orchestrator/topology/topology.py +++ b/aria/orchestrator/topology/topology.py @@ -36,7 +36,6 @@ class Topology(issue.ReporterMixin): models.SubstitutionTemplate: models.Substitution, models.RelationshipTemplate: models.Relationship, models.OperationTemplate: models.Operation, - models.RequirementTemplate: None, models.SubstitutionTemplateMapping: models.SubstitutionMapping, # Common http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/2a80b22c/aria/parser/consumption/modeling.py ---------------------------------------------------------------------- diff --git a/aria/parser/consumption/modeling.py b/aria/parser/consumption/modeling.py index f27216b..221b308 100644 --- a/aria/parser/consumption/modeling.py +++ b/aria/parser/consumption/modeling.py @@ -15,7 +15,6 @@ from .consumer import Consumer, ConsumerChain from ...utils.formatting import json_dumps, yaml_dumps -from ... import exceptions class DeriveServiceTemplate(Consumer): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/2a80b22c/tests/parser/service_templates.py ---------------------------------------------------------------------- diff --git a/tests/parser/service_templates.py b/tests/parser/service_templates.py index ec41cd2..9e8fcae 100644 --- a/tests/parser/service_templates.py +++ b/tests/parser/service_templates.py @@ -27,7 +27,6 @@ def consume_literal(literal, consumer_class_name='instance', cache=True, no_issu context = create_context(LiteralLocation(literal)) consumer, dumper = create_consumer(context, consumer_class_name) consumer.consume() - consumer.dump() if no_issues: context.validation.dump_issues() assert not context.validation.has_issues @@ -48,6 +47,7 @@ def consume_use_case(use_case_name, consumer_class_name='instance', cache=True): assert not context.validation.has_issues return context, dumper + def consume_types_use_case(use_case_name, consumer_class_name='instance', cache=True): cachedmethod.ENABLED = cache uri = get_service_template_uri('tosca-simple-1.0', 'types', use_case_name, @@ -62,6 +62,7 @@ def consume_types_use_case(use_case_name, consumer_class_name='instance', cache= assert not context.validation.has_issues return context, dumper + def consume_node_cellar(consumer_class_name='instance', cache=True): consume_test_case( get_service_template_uri('tosca-simple-1.0', 'node-cellar', 'node-cellar.yaml'),
