Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 00823200C8B for ; Mon, 22 May 2017 13:21:40 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id F32DC160BBF; Mon, 22 May 2017 11:21:39 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 76FFD160BA5 for ; Mon, 22 May 2017 13:21:38 +0200 (CEST) Received: (qmail 12816 invoked by uid 500); 22 May 2017 11:21:37 -0000 Mailing-List: contact dev-help@ariatosca.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ariatosca.incubator.apache.org Delivered-To: mailing list dev@ariatosca.incubator.apache.org Received: (qmail 12805 invoked by uid 99); 22 May 2017 11:21:37 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 May 2017 11:21:37 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 388C2190D38 for ; Mon, 22 May 2017 11:21:37 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.222 X-Spam-Level: X-Spam-Status: No, score=-4.222 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id iRJfDm9MvG2S for ; Mon, 22 May 2017 11:21:32 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id B0EB55FE02 for ; Mon, 22 May 2017 11:21:30 +0000 (UTC) Received: (qmail 12622 invoked by uid 99); 22 May 2017 11:21:29 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 May 2017 11:21:29 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A34D4E1892; Mon, 22 May 2017 11:21:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: avia@apache.org To: dev@ariatosca.incubator.apache.org Date: Mon, 22 May 2017 11:21:31 -0000 Message-Id: In-Reply-To: <5f8fb4dabc914838800824190b0ecc55@git.apache.org> References: <5f8fb4dabc914838800824190b0ecc55@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/4] incubator-ariatosca git commit: Add input model archived-at: Mon, 22 May 2017 11:21:40 -0000 Add input model Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/23afaf02 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/23afaf02 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/23afaf02 Branch: refs/heads/ARIA-180-convert-parameter-to-one-to-many Commit: 23afaf026c25e58bd0c13b0d677da391564f7633 Parents: 7e1d7eb Author: Avia Efrat Authored: Sun May 21 20:10:50 2017 +0300 Committer: Avia Efrat Committed: Mon May 22 14:06:27 2017 +0300 ---------------------------------------------------------------------- aria/modeling/models.py | 11 +- aria/modeling/orchestration.py | 8 +- aria/modeling/relationship.py | 6 +- aria/modeling/service_common.py | 202 ++++++++++++++++++- aria/modeling/service_instance.py | 18 +- aria/modeling/service_template.py | 16 +- aria/modeling/utils.py | 8 +- .../simple_v1_0/modeling/__init__.py | 29 +-- tests/mock/models.py | 2 +- tests/mock/topology.py | 8 +- tests/modeling/test_models.py | 4 +- tests/orchestrator/test_workflow_runner.py | 8 +- .../workflows/executor/test_executor.py | 2 +- 13 files changed, 265 insertions(+), 57 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/23afaf02/aria/modeling/models.py ---------------------------------------------------------------------- diff --git a/aria/modeling/models.py b/aria/modeling/models.py index f3acca6..d7b417b 100644 --- a/aria/modeling/models.py +++ b/aria/modeling/models.py @@ -73,6 +73,7 @@ __all__ = ( # Common service models 'Parameter', + 'Input' 'Output' 'Type', 'Metadata', @@ -211,10 +212,15 @@ class Parameter(aria_declarative_base, service_common.ParameterBase): pass +class Input(aria_declarative_base, service_common.InputBase): + # Temporarily, until we will separate the Parameter model into Input, Output, Property and + # Attribute, Parameter will represent only Property and Attribute. + pass + + class Output(aria_declarative_base, service_common.OutputBase): # Temporarily, until we will separate the Parameter model into Input, Output, Property and - # Attribute, Parameter will represent Input, Property and Attribute, and Output will represent - # the outputs. + # Attribute, Parameter will represent only Property and Attribute. pass @@ -285,6 +291,7 @@ models_to_register = [ # Common service models Parameter, + Input, Output, Type, Metadata, http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/23afaf02/aria/modeling/orchestration.py ---------------------------------------------------------------------- diff --git a/aria/modeling/orchestration.py b/aria/modeling/orchestration.py index ab9d34d..b65ca62 100644 --- a/aria/modeling/orchestration.py +++ b/aria/modeling/orchestration.py @@ -115,7 +115,7 @@ class ExecutionBase(ModelMixin): @declared_attr def inputs(cls): - return relationship.many_to_many(cls, 'parameter', prefix='inputs', dict_key='name') + return relationship.many_to_many(cls, 'input', dict_key='name') # region foreign keys @@ -230,8 +230,8 @@ class TaskBase(ModelMixin): :vartype relationship: :class:`Relationship` :ivar plugin: The implementing plugin (set to None for default execution plugin) :vartype plugin: :class:`Plugin` - :ivar inputs: Parameters that can be used by this task - :vartype inputs: {basestring: :class:`Parameter`} + :ivar inputs: Inputs that can be used by this task + :vartype inputs: {basestring: :class:`Input`} :ivar implementation: Python path to an ``@operation`` function :vartype implementation: basestring :ivar max_attempts: Maximum number of retries allowed in case of failure @@ -301,7 +301,7 @@ class TaskBase(ModelMixin): @declared_attr def inputs(cls): - return relationship.many_to_many(cls, 'parameter', prefix='inputs', dict_key='name') + return relationship.many_to_many(cls, 'input', dict_key='name') implementation = Column(String) max_attempts = Column(Integer, default=1) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/23afaf02/aria/modeling/relationship.py ---------------------------------------------------------------------- diff --git a/aria/modeling/relationship.py b/aria/modeling/relationship.py index c4f4cf3..8644d42 100644 --- a/aria/modeling/relationship.py +++ b/aria/modeling/relationship.py @@ -287,8 +287,10 @@ def many_to_many(model_class, if prefix is not None: secondary_table_name = '{0}_{1}'.format(prefix, secondary_table_name) - if other_property is None: - other_property = '{0}_{1}'.format(prefix, formatting.pluralize(this_table)) + if other_property is None: + other_property = '{0}_{1}'.format(prefix, formatting.pluralize(this_table)) + elif other_property is None: + other_property = '{0}_{1}'.format(other_table, formatting.pluralize(this_table)) secondary_table = _get_secondary_table( model_class.metadata, http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/23afaf02/aria/modeling/service_common.py ---------------------------------------------------------------------- diff --git a/aria/modeling/service_common.py b/aria/modeling/service_common.py index 05698b6..0652a5a 100644 --- a/aria/modeling/service_common.py +++ b/aria/modeling/service_common.py @@ -408,9 +408,9 @@ class OutputBase(TemplateModelMixin, caching.HasCachedMethods): """ Wraps an arbitrary value as a parameter. The type will be guessed via introspection. - :param name: Parameter name + :param name: Output name :type name: basestring - :param value: Parameter value + :param value: Output value :param description: Description (optional) :type description: basestring """ @@ -532,6 +532,204 @@ class TypeBase(InstanceModelMixin): return [self] + (self.parent.hierarchy if self.parent else []) +# TODO dry this code. currently it is a copy of ParameterBase +class InputBase(TemplateModelMixin, caching.HasCachedMethods): + """ + Represents a typed value. The value can contain nested intrinsic functions. + + This model can be used as the ``container_holder`` argument for :func:`functions.evaluate`. + + :ivar name: Name + :vartype name: basestring + :ivar type_name: Type name + :vartype type_name: basestring + :ivar value: Value + :ivar description: Description + :vartype description: basestring + """ + + __tablename__ = 'input' + + name = Column(Text) + type_name = Column(Text) + description = Column(Text) + _value = Column(PickleType) + + @property + def value(self): + value = self._value + if value is not None: + evaluation = functions.evaluate(value, self) + if evaluation is not None: + value = evaluation.value + return value + + @value.setter + def value(self, value): + self._value = value + + @property + @caching.cachedmethod + def owner(self): + """ + The sole owner of this parameter, which is another model that relates to it. + + *All* parameters should have an owner model. In case this property method fails to find + it, it will raise a ValueError, which should signify an abnormal, orphaned parameter. + """ + + # Find first non-null relationship + for the_relationship in self.__mapper__.relationships: + v = getattr(self, the_relationship.key) + if v: + return v[0] # because we are many-to-many, the back reference will be a list + + raise ValueError('orphaned input: does not have an owner: {0}'.format(self.name)) + + + @property + @caching.cachedmethod + def container(self): # pylint: disable=too-many-return-statements,too-many-branches + """ + The logical container for this parameter, which would be another model: service, node, + group, or policy (or their templates). + + The logical container is equivalent to the ``SELF`` keyword used by intrinsic functions in + TOSCA. + + *All* parameters should have a container model. In case this property method fails to find + it, it will raise a ValueError, which should signify an abnormal, orphaned parameter. + """ + + from . import models + + container = self.owner + + # Extract interface from operation + if isinstance(container, models.Operation): + container = container.interface + elif isinstance(container, models.OperationTemplate): + container = container.interface_template + + # Extract from other models + if isinstance(container, models.Interface): + container = container.node or container.group or container.relationship + elif isinstance(container, models.InterfaceTemplate): + container = container.node_template or container.group_template \ + or container.relationship_template + elif isinstance(container, models.Capability) or isinstance(container, models.Artifact): + container = container.node + elif isinstance(container, models.CapabilityTemplate) \ + or isinstance(container, models.ArtifactTemplate): + container = container.node_template + elif isinstance(container, models.Task): + container = container.actor + + # Extract node from relationship + if isinstance(container, models.Relationship): + container = container.source_node + elif isinstance(container, models.RelationshipTemplate): + container = container.requirement_template.node_template + + if container is not None: + return container + + raise ValueError('orphaned input: does not have a container: {0}'.format(self.name)) + + @property + @caching.cachedmethod + def service(self): + """ + The :class:`Service` containing this parameter, or None if not contained in a service. + """ + + from . import models + container = self.container + if isinstance(container, models.Service): + return container + elif hasattr(container, 'service'): + return container.service + return None + + @property + @caching.cachedmethod + def service_template(self): + """ + The :class:`ServiceTemplate` containing this parameter, or None if not contained in a + service template. + """ + + from . import models + container = self.container + if isinstance(container, models.ServiceTemplate): + return container + elif hasattr(container, 'service_template'): + return container.service_template + return None + + @property + def as_raw(self): + return collections.OrderedDict(( + ('name', self.name), + ('type_name', self.type_name), + ('value', self.value), + ('description', self.description))) + + def instantiate(self, container): + from . import models + return models.Input(name=self.name, # pylint: disable=unexpected-keyword-arg + type_name=self.type_name, + _value=self._value, + description=self.description) + + def coerce_values(self, report_issues): + value = self._value + if value is not None: + evaluation = functions.evaluate(value, self, report_issues) + if (evaluation is not None) and evaluation.final: + # A final evaluation can safely replace the existing value + self._value = evaluation.value + + def dump(self): + context = ConsumptionContext.get_thread_local() + if self.type_name is not None: + console.puts('{0}: {1} ({2})'.format( + context.style.property(self.name), + context.style.literal(formatting.as_raw(self.value)), + context.style.type(self.type_name))) + else: + console.puts('{0}: {1}'.format( + context.style.property(self.name), + context.style.literal(formatting.as_raw(self.value)))) + if self.description: + console.puts(context.style.meta(self.description)) + + def unwrap(self): + return self.name, self.value + + @classmethod + def wrap(cls, name, value, description=None): + """ + Wraps an arbitrary value as a parameter. The type will be guessed via introspection. + + :param name: Input name + :type name: basestring + :param value: Input value + :param description: Description (optional) + :type description: basestring + """ + + from . import models + type_name = canonical_type_name(value) + if type_name is None: + type_name = full_type_name(value) + return models.Input(name=name, # pylint: disable=unexpected-keyword-arg + type_name=type_name, + value=value, + description=description) + + + class MetadataBase(TemplateModelMixin): """ Custom values associated with the service. http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/23afaf02/aria/modeling/service_instance.py ---------------------------------------------------------------------- diff --git a/aria/modeling/service_instance.py b/aria/modeling/service_instance.py index 4236caa..f3f0f99 100644 --- a/aria/modeling/service_instance.py +++ b/aria/modeling/service_instance.py @@ -63,7 +63,7 @@ class ServiceBase(InstanceModelMixin): :ivar substitution: The entire service can appear as a node :vartype substitution: :class:`Substitution` :ivar inputs: Externally provided parameters - :vartype inputs: {basestring: :class:`Parameter`} + :vartype inputs: {basestring: :class:`Input`} :ivar outputs: These parameters are filled in after service installation :vartype outputs: {basestring: :class:`Output`} :ivar workflows: Custom workflows that can be performed on the service @@ -167,7 +167,7 @@ class ServiceBase(InstanceModelMixin): @declared_attr def inputs(cls): - return relationship.many_to_many(cls, 'parameter', prefix='inputs', dict_key='name') + return relationship.many_to_many(cls, 'input', dict_key='name') @declared_attr def outputs(cls): @@ -1490,8 +1490,8 @@ class InterfaceBase(InstanceModelMixin): :vartype type: :class:`Type` :ivar description: Human-readable description :vartype description: string - :ivar inputs: Parameters that can be used by all operations in the interface - :vartype inputs: {basestring: :class:`Parameter`} + :ivar inputs: Inputs that can be used by all operations in the interface + :vartype inputs: {basestring: :class:`Input`} :ivar operations: Operations :vartype operations: {basestring: :class:`Operation`} :ivar node: Containing node @@ -1583,7 +1583,7 @@ class InterfaceBase(InstanceModelMixin): @declared_attr def inputs(cls): - return relationship.many_to_many(cls, 'parameter', prefix='inputs', dict_key='name') + return relationship.many_to_many(cls, 'input', dict_key='name') # endregion @@ -1645,8 +1645,8 @@ class OperationBase(InstanceModelMixin): :vartype configuration: {basestring, object} :ivar dependencies: Dependency strings (interpreted by the plugin) :vartype dependencies: [basestring] - :ivar inputs: Parameters that can be used by this operation - :vartype inputs: {basestring: :class:`Parameter`} + :ivar inputs: Inputs that can be used by this operation + :vartype inputs: {basestring: :class:`Input`} :ivar executor: Name of executor to run the operation with :vartype executor: basestring :ivar max_attempts: Maximum number of attempts allowed in case of failure @@ -1726,7 +1726,7 @@ class OperationBase(InstanceModelMixin): @declared_attr def inputs(cls): - return relationship.many_to_many(cls, 'parameter', prefix='inputs', dict_key='name') + return relationship.many_to_many(cls, 'input', dict_key='name') # endregion @@ -1755,7 +1755,7 @@ class OperationBase(InstanceModelMixin): # Note: the arguments will *override* operation inputs of the same name if arguments: for k, v in arguments.iteritems(): - self.inputs[k] = models.Parameter.wrap(k, v) + self.inputs[k] = models.Input.wrap(k, v) @property def as_raw(self): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/23afaf02/aria/modeling/service_template.py ---------------------------------------------------------------------- diff --git a/aria/modeling/service_template.py b/aria/modeling/service_template.py index e253617..3341f5f 100644 --- a/aria/modeling/service_template.py +++ b/aria/modeling/service_template.py @@ -67,7 +67,7 @@ class ServiceTemplateBase(TemplateModelMixin): :ivar substitution_template: The entire service can appear as a node :vartype substitution_template: :class:`SubstitutionTemplate` :ivar inputs: Externally provided parameters - :vartype inputs: {basestring: :class:`Parameter`} + :vartype inputs: {basestring: :class:`Input`} :ivar outputs: These parameters are filled in after service installation :vartype outputs: {basestring: :class:`Output`} :ivar workflow_templates: Custom workflows that can be performed on the service @@ -249,7 +249,7 @@ class ServiceTemplateBase(TemplateModelMixin): @declared_attr def inputs(cls): - return relationship.many_to_many(cls, 'parameter', prefix='inputs', dict_key='name') + return relationship.many_to_many(cls, 'input', dict_key='name') @declared_attr def outputs(cls): @@ -1621,8 +1621,8 @@ class InterfaceTemplateBase(TemplateModelMixin): :vartype type: :class:`Type` :ivar description: Human-readable description :vartype description: basestring - :ivar inputs: Parameters that can be used by all operations in the interface - :vartype inputs: {basestring: :class:`Parameter`} + :ivar inputs: Inputs that can be used by all operations in the interface + :vartype inputs: {basestring: :class:`Input`} :ivar operation_templates: Operations :vartype operation_templates: {basestring: :class:`OperationTemplate`} :ivar node_template: Containing node template @@ -1712,7 +1712,7 @@ class InterfaceTemplateBase(TemplateModelMixin): @declared_attr def inputs(cls): - return relationship.many_to_many(cls, 'parameter', prefix='inputs', dict_key='name') + return relationship.many_to_many(cls, 'input', dict_key='name') # endregion @@ -1779,8 +1779,8 @@ class OperationTemplateBase(TemplateModelMixin): :vartype configuration: {basestring, object} :ivar dependencies: Dependency strings (interpreted by the plugin) :vartype dependencies: [basestring] - :ivar inputs: Parameters that can be used by this operation - :vartype inputs: {basestring: :class:`Parameter`} + :ivar inputs: Inputs that can be used by this operation + :vartype inputs: {basestring: :class:`Input`} :ivar executor: Name of executor to run the operation with :vartype executor: basestring :ivar max_attempts: Maximum number of attempts allowed in case of failure @@ -1857,7 +1857,7 @@ class OperationTemplateBase(TemplateModelMixin): @declared_attr def inputs(cls): - return relationship.many_to_many(cls, 'parameter', prefix='inputs', dict_key='name') + return relationship.many_to_many(cls, 'input', dict_key='name') # endregion http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/23afaf02/aria/modeling/utils.py ---------------------------------------------------------------------- diff --git a/aria/modeling/utils.py b/aria/modeling/utils.py index 0404fe4..ae62401 100644 --- a/aria/modeling/utils.py +++ b/aria/modeling/utils.py @@ -54,20 +54,20 @@ class NodeTemplateContainerHolder(object): def create_inputs(inputs, template_inputs): """ :param inputs: key-value dict - :param template_inputs: parameter name to parameter object dict - :return: dict of parameter name to Parameter models + :param template_inputs: input name to input object dict + :return: dict of input name to Input models """ merged_inputs = _merge_and_validate_inputs(inputs, template_inputs) from . import models input_models = [] for input_name, input_val in merged_inputs.iteritems(): - parameter = models.Parameter( # pylint: disable=unexpected-keyword-arg + input = models.Input( # pylint: disable=unexpected-keyword-arg name=input_name, type_name=template_inputs[input_name].type_name, description=template_inputs[input_name].description, value=input_val) - input_models.append(parameter) + input_models.append(input) return dict((inp.name, inp) for inp in input_models) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/23afaf02/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py index 1769ce5..47cb521 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py +++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py @@ -32,7 +32,7 @@ from aria.modeling.models import (Type, ServiceTemplate, NodeTemplate, RequirementTemplate, RelationshipTemplate, CapabilityTemplate, GroupTemplate, PolicyTemplate, SubstitutionTemplate, SubstitutionTemplateMapping, InterfaceTemplate, OperationTemplate, - ArtifactTemplate, Metadata, Parameter, Output, + ArtifactTemplate, Metadata, Parameter, Input, Output, PluginSpecification) from .constraints import (Equal, GreaterThan, GreaterOrEqual, LessThan, LessOrEqual, InRange, @@ -90,7 +90,8 @@ def create_service_template_model(context): # pylint: disable=too-many-locals,to topology_template = context.presentation.get('service_template', 'topology_template') if topology_template is not None: create_parameter_models_from_values(model.inputs, - topology_template._get_input_values(context)) + topology_template._get_input_values(context), + model_class=Input) create_parameter_models_from_values(model.outputs, topology_template._get_output_values(context), model_class=Output) @@ -354,10 +355,10 @@ def create_interface_template_model(context, service_template, interface): inputs = interface.inputs if inputs: for input_name, the_input in inputs.iteritems(): - model.inputs[input_name] = Parameter(name=input_name, # pylint: disable=unexpected-keyword-arg - type_name=the_input.value.type, - value=the_input.value.value, - description=the_input.value.description) + model.inputs[input_name] = Input(name=input_name, # pylint: disable=unexpected-keyword-arg + type_name=the_input.value.type, + value=the_input.value.value, + description=the_input.value.description) operations = interface.operations if operations: @@ -401,10 +402,10 @@ def create_operation_template_model(context, service_template, operation): inputs = operation.inputs if inputs: for input_name, the_input in inputs.iteritems(): - model.inputs[input_name] = Parameter(name=input_name, # pylint: disable=unexpected-keyword-arg - type_name=the_input.value.type, - value=the_input.value.value, - description=the_input.value.description) + model.inputs[input_name] = Input(name=input_name, # pylint: disable=unexpected-keyword-arg + type_name=the_input.value.type, + value=the_input.value.value, + description=the_input.value.description) return model @@ -497,10 +498,10 @@ def create_workflow_operation_template_model(context, service_template, policy): elif prop_name == 'dependencies': model.dependencies = prop.value else: - model.inputs[prop_name] = Parameter(name=prop_name, # pylint: disable=unexpected-keyword-arg - type_name=prop.type, - value=prop.value, - description=prop.description) + model.inputs[prop_name] = Input(name=prop_name, # pylint: disable=unexpected-keyword-arg + type_name=prop.type, + value=prop.value, + description=prop.description) return model http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/23afaf02/tests/mock/models.py ---------------------------------------------------------------------- diff --git a/tests/mock/models.py b/tests/mock/models.py index f066551..36929ad 100644 --- a/tests/mock/models.py +++ b/tests/mock/models.py @@ -230,7 +230,7 @@ def create_interface(service, interface_name, operation_name, operation_kwargs=N if operation_kwargs and operation_kwargs.get('inputs'): operation_kwargs['inputs'] = dict( - (input_name, models.Parameter.wrap(input_name, input_value)) + (input_name, models.Input.wrap(input_name, input_value)) for input_name, input_value in operation_kwargs['inputs'].iteritems() if input_value is not None) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/23afaf02/tests/mock/topology.py ---------------------------------------------------------------------- diff --git a/tests/mock/topology.py b/tests/mock/topology.py index bfb7b4e..fd29f8d 100644 --- a/tests/mock/topology.py +++ b/tests/mock/topology.py @@ -28,8 +28,8 @@ def create_simple_topology_single_node(model_storage, create_operation): 'Standard', 'create', operation_kwargs=dict( implementation=create_operation, - inputs={'key': aria_models.Parameter.wrap('key', 'create'), - 'value': aria_models.Parameter.wrap('value', True)}) + inputs={'key': aria_models.Input.wrap('key', 'create'), + 'value': aria_models.Input.wrap('value', True)}) ) node_template.interface_templates[interface_template.name] = interface_template # pylint: disable=unsubscriptable-object @@ -39,8 +39,8 @@ def create_simple_topology_single_node(model_storage, create_operation): 'Standard', 'create', operation_kwargs=dict( implementation=create_operation, - inputs={'key': aria_models.Parameter.wrap('key', 'create'), - 'value': aria_models.Parameter.wrap('value', True)}) + inputs={'key': aria_models.Input.wrap('key', 'create'), + 'value': aria_models.Input.wrap('value', True)}) ) node.interfaces[interface.name] = interface # pylint: disable=unsubscriptable-object http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/23afaf02/tests/modeling/test_models.py ---------------------------------------------------------------------- diff --git a/tests/modeling/test_models.py b/tests/modeling/test_models.py index 61034bd..17f2104 100644 --- a/tests/modeling/test_models.py +++ b/tests/modeling/test_models.py @@ -36,7 +36,7 @@ from aria.modeling.models import ( Relationship, NodeTemplate, Node, - Parameter, + Input, Type ) @@ -625,7 +625,7 @@ class TestNodeHostAddress(object): service_template=storage.service_template.list()[0] ) if host_address: - kwargs['properties'] = {'host_address': Parameter.wrap('host_address', host_address)} + kwargs['properties'] = {'host_address': Input.wrap('host_address', host_address)} node = NodeTemplate(**kwargs) storage.node_template.put(node) return node http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/23afaf02/tests/orchestrator/test_workflow_runner.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/test_workflow_runner.py b/tests/orchestrator/test_workflow_runner.py index 7374e50..2a01b63 100644 --- a/tests/orchestrator/test_workflow_runner.py +++ b/tests/orchestrator/test_workflow_runner.py @@ -171,7 +171,7 @@ def test_execution_inputs_override_workflow_inputs(request): wf_inputs = {'input1': 'value1', 'input2': 'value2', 'input3': 5} mock_workflow = _setup_mock_workflow_in_service( request, - inputs=dict((name, models.Parameter.wrap(name, val)) for name, val + inputs=dict((name, models.Input.wrap(name, val)) for name, val in wf_inputs.iteritems())) with mock.patch('aria.orchestrator.workflow_runner.Engine'): @@ -196,7 +196,7 @@ def test_execution_inputs_undeclared_inputs(request): def test_execution_inputs_missing_required_inputs(request): mock_workflow = _setup_mock_workflow_in_service( - request, inputs={'required_input': models.Parameter.wrap('required_input', value=None)}) + request, inputs={'required_input': models.Input.wrap('required_input', value=None)}) with pytest.raises(modeling_exceptions.MissingRequiredInputsException): _create_workflow_runner(request, mock_workflow, inputs={}) @@ -204,7 +204,7 @@ def test_execution_inputs_missing_required_inputs(request): def test_execution_inputs_wrong_type_inputs(request): mock_workflow = _setup_mock_workflow_in_service( - request, inputs={'input': models.Parameter.wrap('input', 'value')}) + request, inputs={'input': models.Input.wrap('input', 'value')}) with pytest.raises(modeling_exceptions.InputsOfWrongTypeException): _create_workflow_runner(request, mock_workflow, inputs={'input': 5}) @@ -225,7 +225,7 @@ def test_workflow_function_parameters(request, tmpdir): wf_inputs = {'output_path': output_path, 'input1': 'value1', 'input2': 'value2', 'input3': 5} mock_workflow = _setup_mock_workflow_in_service( - request, inputs=dict((name, models.Parameter.wrap(name, val)) for name, val + request, inputs=dict((name, models.Input.wrap(name, val)) for name, val in wf_inputs.iteritems())) _create_workflow_runner(request, mock_workflow, http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/23afaf02/tests/orchestrator/workflows/executor/test_executor.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/workflows/executor/test_executor.py b/tests/orchestrator/workflows/executor/test_executor.py index 29cb0e8..643acae 100644 --- a/tests/orchestrator/workflows/executor/test_executor.py +++ b/tests/orchestrator/workflows/executor/test_executor.py @@ -47,7 +47,7 @@ def execute_and_assert(executor, storage=None): successful_task = MockTask(_get_implementation(mock_successful_task), storage=storage) failing_task = MockTask(_get_implementation(mock_failing_task), storage=storage) task_with_inputs = MockTask(_get_implementation(mock_task_with_input), - inputs={'input': models.Parameter.wrap('input', 'value')}, + inputs={'input': models.Input.wrap('input', 'value')}, storage=storage) for task in [successful_task, failing_task, task_with_inputs]: