You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by av...@apache.org on 2017/06/01 14:10:22 UTC
[06/16] incubator-ariatosca git commit: ARIA-149 Enhance operation
configuration
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/extensions/aria_extension_tosca/simple_v1_0/modeling/capabilities.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/capabilities.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/capabilities.py
index 6df7177..a90a9fc 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/capabilities.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/capabilities.py
@@ -16,8 +16,9 @@
from aria.utils.collections import deepcopy_with_locators, OrderedDict
from aria.parser.validation import Issue
-from .properties import (convert_property_definitions_to_values, merge_raw_property_definitions,
- get_assigned_and_defined_property_values)
+from .parameters import (convert_parameter_definitions_to_values, merge_raw_parameter_definitions,
+ get_assigned_and_defined_parameter_values)
+
#
# CapabilityType
@@ -38,6 +39,7 @@ def get_inherited_valid_source_types(context, presentation):
return valid_source_types
+
#
# NodeType
#
@@ -92,6 +94,7 @@ def get_inherited_capability_definitions(context, presentation, for_presentation
return capability_definitions
+
#
# NodeTemplate
#
@@ -127,8 +130,9 @@ def get_template_capabilities(context, presentation):
capability_assignment = capability_assignments[capability_name]
# Assign properties
- values = get_assigned_and_defined_property_values(context,
- our_capability_assignment)
+ values = get_assigned_and_defined_parameter_values(context,
+ our_capability_assignment,
+ 'property')
if values:
capability_assignment._raw['properties'] = values
else:
@@ -139,6 +143,7 @@ def get_template_capabilities(context, presentation):
return capability_assignments
+
#
# Utils
#
@@ -150,24 +155,25 @@ def convert_capability_from_definition_to_assignment(context, presentation, cont
properties = presentation.properties
if properties is not None:
- raw['properties'] = convert_property_definitions_to_values(context, properties)
+ raw['properties'] = convert_parameter_definitions_to_values(context, properties)
# TODO attributes
return CapabilityAssignment(name=presentation._name, raw=raw, container=container)
+
def merge_capability_definition_from_type(context, presentation, capability_definition):
raw_properties = OrderedDict()
# Merge properties from type
the_type = capability_definition._get_type(context)
type_property_defintions = the_type._get_properties(context)
- merge_raw_property_definitions(context, presentation, raw_properties, type_property_defintions,
- 'properties')
+ merge_raw_parameter_definitions(context, presentation, raw_properties, type_property_defintions,
+ 'properties')
# Merge our properties
- merge_raw_property_definitions(context, presentation, raw_properties,
- capability_definition.properties, 'properties')
+ merge_raw_parameter_definitions(context, presentation, raw_properties,
+ capability_definition.properties, 'properties')
if raw_properties:
capability_definition._raw['properties'] = raw_properties
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/extensions/aria_extension_tosca/simple_v1_0/modeling/constraints.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/constraints.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/constraints.py
index 7c99eab..9a30cc1 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/constraints.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/constraints.py
@@ -15,7 +15,7 @@
import re
-from aria.modeling.contraints import NodeTemplateConstraint
+from aria.modeling.constraints import NodeTemplateConstraint
from aria.modeling.utils import NodeTemplateContainerHolder
from aria.modeling.functions import evaluate
from aria.parser import implements_specification
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/extensions/aria_extension_tosca/simple_v1_0/modeling/data_types.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/data_types.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/data_types.py
index 3952785..c0d79e5 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/data_types.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/data_types.py
@@ -26,6 +26,7 @@ from aria.parser.validation import Issue
from .functions import get_function
from ..presentation.types import get_type_by_full_or_shorthand_name
+
#
# DataType
#
@@ -50,6 +51,7 @@ def get_inherited_constraints(context, presentation):
return constraints
+
def coerce_data_type_value(context, presentation, data_type, entry_schema, constraints, value, # pylint: disable=unused-argument
aspect):
"""
@@ -121,6 +123,7 @@ def coerce_data_type_value(context, presentation, data_type, entry_schema, const
return value
+
def validate_data_type_name(context, presentation):
"""
Makes sure the complex data type's name is not that of a built-in type.
@@ -132,6 +135,7 @@ def validate_data_type_name(context, presentation):
% safe_repr(name),
locator=presentation._locator, level=Issue.BETWEEN_TYPES)
+
#
# PropertyDefinition, AttributeDefinition, EntrySchema, DataType
#
@@ -172,6 +176,7 @@ def get_data_type(context, presentation, field_name, allow_none=False):
# Try primitive data type
return get_primitive_data_type(type_name)
+
#
# PropertyDefinition, EntrySchema
#
@@ -195,6 +200,7 @@ def get_property_constraints(context, presentation):
return constraints
+
#
# ConstraintClause
#
@@ -310,6 +316,7 @@ def apply_constraint_to_value(context, presentation, constraint_clause, value):
return True
+
#
# Repository
#
@@ -326,6 +333,7 @@ def get_data_type_value(context, presentation, field_name, type_name):
locator=presentation._locator, level=Issue.BETWEEN_TYPES)
return None
+
#
# Utils
#
@@ -345,6 +353,7 @@ PRIMITIVE_DATA_TYPES = {
'boolean': bool,
'null': None.__class__}
+
@implements_specification('3.2.1-3', 'tosca-simple-1.0')
def get_primitive_data_type(type_name):
"""
@@ -358,6 +367,7 @@ def get_primitive_data_type(type_name):
return PRIMITIVE_DATA_TYPES.get(type_name)
+
def get_data_type_name(the_type):
"""
Returns the name of the type, whether it's a DataType, a primitive type, or another class.
@@ -365,6 +375,7 @@ def get_data_type_name(the_type):
return the_type._name if hasattr(the_type, '_name') else full_type_name(the_type)
+
def coerce_value(context, presentation, the_type, entry_schema, constraints, value, aspect=None): # pylint: disable=too-many-return-statements
"""
Returns the value after it's coerced to its type, reporting validation errors if it cannot be
@@ -410,6 +421,7 @@ def coerce_value(context, presentation, the_type, entry_schema, constraints, val
# Coerce to primitive type
return coerce_to_primitive(context, presentation, the_type, constraints, value, aspect)
+
def coerce_to_primitive(context, presentation, primitive_type, constraints, value, aspect=None):
"""
Returns the value after it's coerced to a primitive type, translating exceptions to validation
@@ -435,6 +447,7 @@ def coerce_to_primitive(context, presentation, primitive_type, constraints, valu
return value
+
def coerce_to_data_type_class(context, presentation, cls, entry_schema, constraints, value,
aspect=None):
"""
@@ -463,6 +476,7 @@ def coerce_to_data_type_class(context, presentation, cls, entry_schema, constrai
return value
+
def apply_constraints_to_value(context, presentation, constraints, value):
"""
Applies all constraints to the value. If the value conforms, returns the value. If it does not
@@ -478,6 +492,7 @@ def apply_constraints_to_value(context, presentation, constraints, value):
value = None
return value
+
def get_container_data_type(presentation):
if presentation is None:
return None
@@ -485,6 +500,7 @@ def get_container_data_type(presentation):
return presentation
return get_container_data_type(presentation._container)
+
def report_issue_for_bad_format(context, presentation, the_type, value, aspect, e):
if aspect == 'default':
aspect = '"default" value'
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/extensions/aria_extension_tosca/simple_v1_0/modeling/functions.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/functions.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/functions.py
index 7089ed9..7025213 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/functions.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/functions.py
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from cStringIO import StringIO
+from StringIO import StringIO # Note: cStringIO does not support Unicode
import re
from aria.utils.collections import FrozenList
@@ -69,7 +69,7 @@ class Concat(Function):
e, final = evaluate(e, final, container_holder)
if e is not None:
value.write(unicode(e))
- value = value.getvalue()
+ value = value.getvalue() or u''
return Evaluation(value, final)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py
index 3e6aa6f..e04ac4a 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py
@@ -13,11 +13,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from aria.utils.collections import merge, deepcopy_with_locators, OrderedDict
+from aria.utils.collections import (merge, deepcopy_with_locators, OrderedDict)
from aria.parser.presentation import get_locator
from aria.parser.validation import Issue
-from .properties import (coerce_property_value, convert_property_definitions_to_values)
+from .parameters import (coerce_parameter_value, convert_parameter_definitions_to_values)
+
#
# InterfaceType
@@ -45,6 +46,7 @@ def get_inherited_operations(context, presentation):
return operations
+
#
# InterfaceDefinition
#
@@ -73,6 +75,7 @@ def get_and_override_input_definitions_from_type(context, presentation):
return inputs
+
def get_and_override_operation_definitions_from_type(context, presentation):
"""
Returns our operation definitions added on top of those of the interface type, if specified.
@@ -96,6 +99,7 @@ def get_and_override_operation_definitions_from_type(context, presentation):
return operations
+
#
# NodeType, RelationshipType, GroupType
#
@@ -124,6 +128,7 @@ def get_inherited_interface_definitions(context, presentation, type_name, for_pr
return interfaces
+
#
# NodeTemplate, RelationshipTemplate, GroupTemplate
#
@@ -186,6 +191,7 @@ def get_template_interfaces(context, presentation, type_name):
return template_interfaces
+
#
# Utils
#
@@ -200,13 +206,14 @@ def convert_interface_definition_from_type_to_template(context, presentation, co
raw = convert_interface_definition_from_type_to_raw_template(context, presentation)
return InterfaceAssignment(name=presentation._name, raw=raw, container=container)
+
def convert_interface_definition_from_type_to_raw_template(context, presentation): # pylint: disable=invalid-name
raw = OrderedDict()
# Copy default values for inputs
inputs = presentation._get_inputs(context)
if inputs is not None:
- raw['inputs'] = convert_property_definitions_to_values(context, inputs)
+ raw['inputs'] = convert_parameter_definitions_to_values(context, inputs)
# Copy operations
operations = presentation._get_operations(context)
@@ -221,11 +228,12 @@ def convert_interface_definition_from_type_to_raw_template(context, presentation
raw[operation_name]['implementation'] = deepcopy_with_locators(implementation._raw)
inputs = operation.inputs
if inputs is not None:
- raw[operation_name]['inputs'] = convert_property_definitions_to_values(context,
- inputs)
+ raw[operation_name]['inputs'] = convert_parameter_definitions_to_values(context,
+ inputs)
return raw
+
def convert_requirement_interface_definitions_from_type_to_raw_template(context, raw_requirement, # pylint: disable=invalid-name
interface_definitions):
if not interface_definitions:
@@ -240,6 +248,7 @@ def convert_requirement_interface_definitions_from_type_to_raw_template(context,
else:
raw_requirement['interfaces'][interface_name] = raw_interface
+
def merge_interface(context, presentation, interface_assignment, our_interface_assignment,
interface_definition, interface_name):
# Assign/merge interface inputs
@@ -282,6 +291,7 @@ def merge_interface(context, presentation, interface_assignment, our_interface_a
our_input_assignments, input_definitions, interface_name,
operation_name, presentation)
+
def merge_raw_input_definition(context, the_raw_input, our_input, interface_name, operation_name,
presentation, type_name):
# Check if we changed the type
@@ -305,6 +315,7 @@ def merge_raw_input_definition(context, the_raw_input, our_input, interface_name
# Merge
merge(the_raw_input, our_input._raw)
+
def merge_input_definitions(context, inputs, our_inputs, interface_name, operation_name,
presentation, type_name):
for input_name, our_input in our_inputs.iteritems():
@@ -314,6 +325,7 @@ def merge_input_definitions(context, inputs, our_inputs, interface_name, operati
else:
inputs[input_name] = our_input._clone(presentation)
+
def merge_raw_input_definitions(context, raw_inputs, our_inputs, interface_name, operation_name,
presentation, type_name):
for input_name, our_input in our_inputs.iteritems():
@@ -323,6 +335,7 @@ def merge_raw_input_definitions(context, raw_inputs, our_inputs, interface_name,
else:
raw_inputs[input_name] = deepcopy_with_locators(our_input._raw)
+
def merge_raw_operation_definition(context, raw_operation, our_operation, interface_name,
presentation, type_name):
if not isinstance(our_operation._raw, dict):
@@ -353,6 +366,7 @@ def merge_raw_operation_definition(context, raw_operation, our_operation, interf
raw_operation['implementation'] = \
deepcopy_with_locators(our_operation._raw['implementation'])
+
def merge_operation_definitions(context, operations, our_operations, interface_name, presentation,
type_name):
if not our_operations:
@@ -364,6 +378,7 @@ def merge_operation_definitions(context, operations, our_operations, interface_n
else:
operations[operation_name] = our_operation._clone(presentation)
+
def merge_raw_operation_definitions(context, raw_operations, our_operations, interface_name,
presentation, type_name):
for operation_name, our_operation in our_operations.iteritems():
@@ -378,6 +393,7 @@ def merge_raw_operation_definitions(context, raw_operations, our_operations, int
else:
raw_operations[operation_name] = deepcopy_with_locators(our_operation._raw)
+
# From either an InterfaceType or an InterfaceDefinition:
def merge_interface_definition(context, interface, our_source, presentation, type_name):
if hasattr(our_source, 'type'):
@@ -408,6 +424,7 @@ def merge_interface_definition(context, interface, our_source, presentation, typ
merge_raw_operation_definitions(context, interface._raw, our_operations, our_source._name,
presentation, type_name)
+
def merge_interface_definitions(context, interfaces, our_interfaces, presentation,
for_presentation=None):
if not our_interfaces:
@@ -419,12 +436,14 @@ def merge_interface_definitions(context, interfaces, our_interfaces, presentatio
else:
interfaces[name] = our_interface._clone(for_presentation)
+
def merge_interface_definitions_from_their_types(context, interfaces, presentation):
for interface in interfaces.itervalues():
the_type = interface._get_type(context) # InterfaceType
if the_type is not None:
merge_interface_definition(context, interface, the_type, presentation, 'type')
+
def assign_raw_inputs(context, values, assignments, definitions, interface_name, operation_name,
presentation):
if not assignments:
@@ -454,8 +473,9 @@ def assign_raw_inputs(context, values, assignments, definitions, interface_name,
# Note: default value has already been assigned
# Coerce value
- values['inputs'][input_name] = coerce_property_value(context, assignment, definition,
- assignment.value)
+ values['inputs'][input_name] = coerce_parameter_value(context, assignment, definition,
+ assignment.value)
+
def validate_required_inputs(context, presentation, assignment, definition, original_assignment,
interface_name, operation_name=None):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py
new file mode 100644
index 0000000..c910956
--- /dev/null
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py
@@ -0,0 +1,211 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# 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 aria.utils.collections import (merge, deepcopy_with_locators, OrderedDict)
+from aria.utils.formatting import pluralize
+from aria.parser.presentation import Value
+from aria.parser.validation import Issue
+
+from .data_types import coerce_value
+
+
+#
+# ArtifactType, DataType, CapabilityType, RelationshipType, NodeType, GroupType, PolicyType
+#
+
+def get_inherited_parameter_definitions(context, presentation, field_name, for_presentation=None):
+ """
+ Returns our parameter definitions added on top of those of our parent, if we have one
+ (recursively).
+
+ Allows overriding all aspects of parent properties except data type.
+ """
+
+ # Get definitions from parent
+ # If we inherit from a primitive, it does not have a parent:
+ parent = presentation._get_parent(context) if hasattr(presentation, '_get_parent') else None
+ definitions = get_inherited_parameter_definitions(context, parent, field_name,
+ for_presentation=presentation) \
+ if parent is not None else OrderedDict()
+
+ # Add/merge our definitions
+ # If we inherit from a primitive, it does not have our field
+ our_definitions = getattr(presentation, field_name, None)
+ if our_definitions:
+ our_definitions_clone = OrderedDict()
+ for name, our_definition in our_definitions.iteritems():
+ our_definitions_clone[name] = our_definition._clone(for_presentation)
+ our_definitions = our_definitions_clone
+ merge_parameter_definitions(context, presentation, definitions, our_definitions, field_name)
+
+ for definition in definitions.itervalues():
+ definition._reset_method_cache()
+
+ return definitions
+
+
+#
+# NodeTemplate, RelationshipTemplate, GroupTemplate, PolicyTemplate
+#
+
+def get_assigned_and_defined_parameter_values(context, presentation, field_name):
+ """
+ Returns the assigned property values while making sure they are defined in our type.
+
+ The property definition's default value, if available, will be used if we did not assign it.
+
+ Makes sure that required properties indeed end up with a value.
+ """
+
+ values = OrderedDict()
+
+ the_type = presentation._get_type(context)
+ field_name_plural = pluralize(field_name)
+ assignments = getattr(presentation, field_name_plural)
+ get_fn_name = '_get_{0}'.format(field_name_plural)
+ definitions = getattr(the_type, get_fn_name)(context) if the_type is not None else None
+
+ # Fill in our assignments, but make sure they are defined
+ if assignments:
+ for name, value in assignments.iteritems():
+ if (definitions is not None) and (name in definitions):
+ definition = definitions[name]
+ values[name] = coerce_parameter_value(context, value, definition, value.value)
+ else:
+ context.validation.report('assignment to undefined {0} "{1}" in "{2}"'
+ .format(field_name, name, presentation._fullname),
+ locator=value._locator, level=Issue.BETWEEN_TYPES)
+
+ # Fill in defaults from the definitions
+ if definitions:
+ for name, definition in definitions.iteritems():
+ if values.get(name) is None:
+ values[name] = coerce_parameter_value(context, presentation, definition,
+ definition.default)
+
+ validate_required_values(context, presentation, values, definitions)
+
+ return values
+
+
+#
+# TopologyTemplate
+#
+
+def get_parameter_values(context, presentation, field_name):
+ values = OrderedDict()
+
+ parameters = getattr(presentation, field_name)
+
+ # Fill in defaults and values
+ if parameters:
+ for name, parameter in parameters.iteritems():
+ if values.get(name) is None:
+ if hasattr(parameter, 'value') and (parameter.value is not None):
+ # For parameters only:
+ values[name] = coerce_parameter_value(context, presentation, parameter,
+ parameter.value)
+ else:
+ default = parameter.default if hasattr(parameter, 'default') else None
+ values[name] = coerce_parameter_value(context, presentation, parameter, default)
+
+ return values
+
+
+#
+# Utils
+#
+
+def validate_required_values(context, presentation, values, definitions):
+ """
+ Check if required properties have not been assigned.
+ """
+
+ if not definitions:
+ return
+ for name, definition in definitions.iteritems():
+ if getattr(definition, 'required', False) \
+ and ((values is None) or (values.get(name) is None)):
+ context.validation.report('required property "%s" is not assigned a value in "%s"'
+ % (name, presentation._fullname),
+ locator=presentation._get_child_locator('properties'),
+ level=Issue.BETWEEN_TYPES)
+
+
+def merge_raw_parameter_definition(context, presentation, raw_property_definition,
+ our_property_definition, field_name, property_name):
+ # Check if we changed the type
+ # TODO: allow a sub-type?
+ type1 = raw_property_definition.get('type')
+ type2 = our_property_definition.type
+ if type1 != type2:
+ context.validation.report(
+ 'override changes type from "%s" to "%s" for property "%s" in "%s"'
+ % (type1, type2, property_name, presentation._fullname),
+ locator=presentation._get_child_locator(field_name, property_name),
+ level=Issue.BETWEEN_TYPES)
+
+ merge(raw_property_definition, our_property_definition._raw)
+
+
+def merge_raw_parameter_definitions(context, presentation, raw_property_definitions,
+ our_property_definitions, field_name):
+ if not our_property_definitions:
+ return
+ for property_name, our_property_definition in our_property_definitions.iteritems():
+ if property_name in raw_property_definitions:
+ raw_property_definition = raw_property_definitions[property_name]
+ merge_raw_parameter_definition(context, presentation, raw_property_definition,
+ our_property_definition, field_name, property_name)
+ else:
+ raw_property_definitions[property_name] = \
+ deepcopy_with_locators(our_property_definition._raw)
+
+
+def merge_parameter_definitions(context, presentation, property_definitions,
+ our_property_definitions, field_name):
+ if not our_property_definitions:
+ return
+ for property_name, our_property_definition in our_property_definitions.iteritems():
+ if property_name in property_definitions:
+ property_definition = property_definitions[property_name]
+ merge_raw_parameter_definition(context, presentation, property_definition._raw,
+ our_property_definition, field_name, property_name)
+ else:
+ property_definitions[property_name] = our_property_definition
+
+
+# Works on properties, inputs, and parameters
+def coerce_parameter_value(context, presentation, definition, value, aspect=None):
+ the_type = definition._get_type(context) if definition is not None else None
+ entry_schema = definition.entry_schema if definition is not None else None
+ constraints = definition._get_constraints(context) \
+ if ((definition is not None) and hasattr(definition, '_get_constraints')) else None
+ value = coerce_value(context, presentation, the_type, entry_schema, constraints, value, aspect)
+ if (the_type is not None) and hasattr(the_type, '_name'):
+ type_name = the_type._name
+ else:
+ type_name = getattr(definition, 'type', None)
+ description = getattr(definition, 'description', None)
+ description = description.value if description is not None else None
+ return Value(type_name, value, description)
+
+
+def convert_parameter_definitions_to_values(context, definitions):
+ values = OrderedDict()
+ for name, definition in definitions.iteritems():
+ default = definition.default
+ values[name] = coerce_parameter_value(context, definition, definition, default)
+ return values
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/extensions/aria_extension_tosca/simple_v1_0/modeling/policies.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/policies.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/policies.py
index fba1972..7dd803b 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/policies.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/policies.py
@@ -15,6 +15,7 @@
from ..presentation.types import convert_shorthand_to_full_type_name
+
#
# PolicyType
#
@@ -49,6 +50,7 @@ def get_inherited_targets(context, presentation):
return node_types, group_types
+
#
# PolicyTemplate
#
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/extensions/aria_extension_tosca/simple_v1_0/modeling/properties.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/properties.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/properties.py
deleted file mode 100644
index 9c3ea42..0000000
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/properties.py
+++ /dev/null
@@ -1,202 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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 aria.utils.collections import merge, deepcopy_with_locators, OrderedDict
-from aria.parser.presentation import Value
-from aria.parser.validation import Issue
-
-from .data_types import coerce_value
-
-#
-# ArtifactType, DataType, CapabilityType, RelationshipType, NodeType, GroupType, PolicyType
-#
-
-# Works on properties, parameters, inputs, and attributes
-def get_inherited_property_definitions(context, presentation, field_name, for_presentation=None):
- """
- Returns our property definitions added on top of those of our parent, if we have one
- (recursively).
-
- Allows overriding all aspects of parent properties except data type.
- """
-
- # Get definitions from parent
- # If we inherit from a primitive, it does not have a parent:
- parent = presentation._get_parent(context) if hasattr(presentation, '_get_parent') else None
- definitions = get_inherited_property_definitions(context, parent, field_name,
- for_presentation=presentation) \
- if parent is not None else OrderedDict()
-
- # Add/merge our definitions
- # If we inherit from a primitive, it does not have our field
- our_definitions = getattr(presentation, field_name, None)
- if our_definitions:
- our_definitions_clone = OrderedDict()
- for name, our_definition in our_definitions.iteritems():
- our_definitions_clone[name] = our_definition._clone(for_presentation)
- our_definitions = our_definitions_clone
- merge_property_definitions(context, presentation, definitions, our_definitions, field_name)
-
- for definition in definitions.itervalues():
- definition._reset_method_cache()
-
- return definitions
-
-#
-# NodeTemplate, RelationshipTemplate, GroupTemplate, PolicyTemplate
-#
-
-def get_assigned_and_defined_property_values(context, presentation, field_name='property',
- field_name_plural='properties'):
- """
- Returns the assigned property values while making sure they are defined in our type.
-
- The property definition's default value, if available, will be used if we did not assign it.
-
- Makes sure that required properties indeed end up with a value.
- """
-
- values = OrderedDict()
-
- the_type = presentation._get_type(context)
- assignments = getattr(presentation, field_name_plural)
- get_fn_name = '_get_{0}'.format(field_name_plural)
- definitions = getattr(the_type, get_fn_name)(context) if the_type is not None else None
-
- # Fill in our assignments, but make sure they are defined
- if assignments:
- for name, value in assignments.iteritems():
- if (definitions is not None) and (name in definitions):
- definition = definitions[name]
- values[name] = coerce_property_value(context, value, definition, value.value)
- else:
- context.validation.report('assignment to undefined {0} "{1}" in "{2}"'
- .format(field_name, name, presentation._fullname),
- locator=value._locator, level=Issue.BETWEEN_TYPES)
-
- # Fill in defaults from the definitions
- if definitions:
- for name, definition in definitions.iteritems():
- if values.get(name) is None:
- values[name] = coerce_property_value(context, presentation, definition,
- definition.default)
-
- validate_required_values(context, presentation, values, definitions)
-
- return values
-
-#
-# TopologyTemplate
-#
-
-def get_parameter_values(context, presentation, field_name):
- values = OrderedDict()
-
- parameters = getattr(presentation, field_name)
-
- # Fill in defaults and values
- if parameters:
- for name, parameter in parameters.iteritems():
- if values.get(name) is None:
- if hasattr(parameter, 'value') and (parameter.value is not None):
- # For parameters only:
- values[name] = coerce_property_value(context, presentation, parameter,
- parameter.value)
- else:
- default = parameter.default if hasattr(parameter, 'default') else None
- values[name] = coerce_property_value(context, presentation, parameter, default)
-
- return values
-
-#
-# Utils
-#
-
-def validate_required_values(context, presentation, values, definitions):
- """
- Check if required properties have not been assigned.
- """
-
- if not definitions:
- return
- for name, definition in definitions.iteritems():
- if getattr(definition, 'required', False) \
- and ((values is None) or (values.get(name) is None)):
- context.validation.report('required property "%s" is not assigned a value in "%s"'
- % (name, presentation._fullname),
- locator=presentation._get_child_locator('properties'),
- level=Issue.BETWEEN_TYPES)
-
-def merge_raw_property_definition(context, presentation, raw_property_definition,
- our_property_definition, field_name, property_name):
- # Check if we changed the type
- # TODO: allow a sub-type?
- type1 = raw_property_definition.get('type')
- type2 = our_property_definition.type
- if type1 != type2:
- context.validation.report(
- 'override changes type from "%s" to "%s" for property "%s" in "%s"'
- % (type1, type2, property_name, presentation._fullname),
- locator=presentation._get_child_locator(field_name, property_name),
- level=Issue.BETWEEN_TYPES)
-
- merge(raw_property_definition, our_property_definition._raw)
-
-def merge_raw_property_definitions(context, presentation, raw_property_definitions,
- our_property_definitions, field_name):
- if not our_property_definitions:
- return
- for property_name, our_property_definition in our_property_definitions.iteritems():
- if property_name in raw_property_definitions:
- raw_property_definition = raw_property_definitions[property_name]
- merge_raw_property_definition(context, presentation, raw_property_definition,
- our_property_definition, field_name, property_name)
- else:
- raw_property_definitions[property_name] = \
- deepcopy_with_locators(our_property_definition._raw)
-
-def merge_property_definitions(context, presentation, property_definitions,
- our_property_definitions, field_name):
- if not our_property_definitions:
- return
- for property_name, our_property_definition in our_property_definitions.iteritems():
- if property_name in property_definitions:
- property_definition = property_definitions[property_name]
- merge_raw_property_definition(context, presentation, property_definition._raw,
- our_property_definition, field_name, property_name)
- else:
- property_definitions[property_name] = our_property_definition
-
-# Works on properties, inputs, and parameters
-def coerce_property_value(context, presentation, definition, value, aspect=None):
- the_type = definition._get_type(context) if definition is not None else None
- entry_schema = definition.entry_schema if definition is not None else None
- constraints = definition._get_constraints(context) \
- if ((definition is not None) and hasattr(definition, '_get_constraints')) else None
- value = coerce_value(context, presentation, the_type, entry_schema, constraints, value, aspect)
- if (the_type is not None) and hasattr(the_type, '_name'):
- type_name = the_type._name
- else:
- type_name = getattr(definition, 'type', None)
- description = getattr(definition, 'description', None)
- description = description.value if description is not None else None
- return Value(type_name, value, description)
-
-def convert_property_definitions_to_values(context, definitions):
- values = OrderedDict()
- for name, definition in definitions.iteritems():
- default = definition.default
- values[name] = coerce_property_value(context, definition, definition, default)
- return values
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py
index 2a68da2..6bdb5b1 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py
@@ -14,13 +14,14 @@
# limitations under the License.
from aria.parser.validation import Issue
-from aria.utils.collections import deepcopy_with_locators, OrderedDict
+from aria.utils.collections import (deepcopy_with_locators, OrderedDict)
-from .properties import (convert_property_definitions_to_values, validate_required_values,
- coerce_property_value)
+from .parameters import (convert_parameter_definitions_to_values, validate_required_values,
+ coerce_parameter_value)
from .interfaces import (convert_requirement_interface_definitions_from_type_to_raw_template,
merge_interface_definitions, merge_interface, validate_required_inputs)
+
#
# NodeType
#
@@ -49,6 +50,7 @@ def get_inherited_requirement_definitions(context, presentation):
return requirement_definitions
+
#
# NodeTemplate
#
@@ -127,6 +129,7 @@ def get_template_requirements(context, presentation):
return requirement_assignments
+
#
# Utils
#
@@ -195,8 +198,8 @@ def convert_requirement_from_definition_to_assignment(context, requirement_defin
if relationship_property_definitions:
# Convert property definitions to values
raw['relationship']['properties'] = \
- convert_property_definitions_to_values(context,
- relationship_property_definitions)
+ convert_parameter_definitions_to_values(context,
+ relationship_property_definitions)
# These are our interface definitions
# InterfaceDefinition:
@@ -229,6 +232,7 @@ def convert_requirement_from_definition_to_assignment(context, requirement_defin
relationship_property_definitions, \
relationship_interface_definitions
+
def add_requirement_assignments(context, presentation, requirement_assignments,
requirement_definitions, our_requirement_assignments):
for requirement_name, our_requirement_assignment in our_requirement_assignments:
@@ -258,6 +262,7 @@ def add_requirement_assignments(context, presentation, requirement_assignments,
locator=our_requirement_assignment._locator,
level=Issue.BETWEEN_TYPES)
+
def merge_requirement_assignment(context, relationship_property_definitions,
relationship_interface_definitions, requirement, our_requirement):
our_capability = our_requirement.capability
@@ -283,6 +288,7 @@ def merge_requirement_assignment(context, relationship_property_definitions,
relationship_interface_definitions,
requirement, our_relationship)
+
def merge_requirement_assignment_relationship(context, presentation, property_definitions,
interface_definitions, requirement, our_relationship):
our_relationship_properties = our_relationship._raw.get('properties')
@@ -296,7 +302,7 @@ def merge_requirement_assignment_relationship(context, presentation, property_de
if property_name in property_definitions:
definition = property_definitions[property_name]
requirement._raw['relationship']['properties'][property_name] = \
- coerce_property_value(context, presentation, definition, prop)
+ coerce_parameter_value(context, presentation, definition, prop)
else:
context.validation.report(
'relationship property "%s" not declared at definition of requirement "%s"'
@@ -330,6 +336,7 @@ def merge_requirement_assignment_relationship(context, presentation, property_de
presentation._container._container._fullname),
locator=our_relationship._locator, level=Issue.BETWEEN_TYPES)
+
def validate_requirement_assignment(context, presentation, requirement_assignment,
relationship_property_definitions,
relationship_interface_definitions):
@@ -348,6 +355,7 @@ def validate_requirement_assignment(context, presentation, requirement_assignmen
validate_required_inputs(context, presentation, interface_assignment,
relationship_interface_definition, None, interface_name)
+
def get_first_requirement(requirement_definitions, name):
if requirement_definitions is not None:
for requirement_name, requirement_definition in requirement_definitions:
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/extensions/aria_extension_tosca/simple_v1_0/modeling/substitution_mappings.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/substitution_mappings.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/substitution_mappings.py
index c1e21de..8f7ec4c 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/substitution_mappings.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/substitution_mappings.py
@@ -16,6 +16,7 @@
from aria.utils.formatting import safe_repr
from aria.parser.validation import Issue
+
def validate_subtitution_mappings_requirement(context, presentation):
if not validate_format(context, presentation, 'requirement'):
return
@@ -57,6 +58,7 @@ def validate_subtitution_mappings_requirement(context, presentation):
locator=presentation._locator, level=Issue.BETWEEN_TYPES)
return
+
def validate_subtitution_mappings_capability(context, presentation):
if not validate_format(context, presentation, 'capability'):
return
@@ -99,6 +101,7 @@ def validate_subtitution_mappings_capability(context, presentation):
% (capability_type._name, presentation._name, type_capability_type._name),
locator=presentation._locator, level=Issue.BETWEEN_TYPES)
+
#
# Utils
#
@@ -114,6 +117,7 @@ def validate_format(context, presentation, name):
return False
return True
+
def get_node_template(context, presentation, name):
node_template_name = presentation._raw[0]
node_template = context.presentation.get_from_dict('service_template', 'topology_template',
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/extensions/aria_extension_tosca/simple_v1_0/templates.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/templates.py b/extensions/aria_extension_tosca/simple_v1_0/templates.py
index ce6b5d9..123a00e 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/templates.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/templates.py
@@ -26,7 +26,7 @@ from .assignments import (PropertyAssignment, AttributeAssignment, RequirementAs
from .definitions import ParameterDefinition
from .filters import NodeFilter
from .misc import (Description, MetaData, Repository, Import, SubstitutionMappings)
-from .modeling.properties import (get_assigned_and_defined_property_values, get_parameter_values)
+from .modeling.parameters import (get_assigned_and_defined_parameter_values, get_parameter_values)
from .modeling.interfaces import get_template_interfaces
from .modeling.requirements import get_template_requirements
from .modeling.capabilities import get_template_capabilities
@@ -157,12 +157,11 @@ class NodeTemplate(ExtensiblePresentation):
@cachedmethod
def _get_property_values(self, context):
- return FrozenDict(get_assigned_and_defined_property_values(context, self))
+ return FrozenDict(get_assigned_and_defined_parameter_values(context, self, 'property'))
@cachedmethod
def _get_attribute_default_values(self, context):
- return FrozenDict(get_assigned_and_defined_property_values(context, self,
- 'attribute', 'attributes'))
+ return FrozenDict(get_assigned_and_defined_parameter_values(context, self, 'attribute'))
@cachedmethod
def _get_requirements(self, context):
@@ -281,7 +280,7 @@ class RelationshipTemplate(ExtensiblePresentation):
@cachedmethod
def _get_property_values(self, context):
- return FrozenDict(get_assigned_and_defined_property_values(context, self))
+ return FrozenDict(get_assigned_and_defined_parameter_values(context, self, 'property'))
@cachedmethod
def _get_interfaces(self, context):
@@ -363,7 +362,7 @@ class GroupTemplate(ExtensiblePresentation):
@cachedmethod
def _get_property_values(self, context):
- return FrozenDict(get_assigned_and_defined_property_values(context, self))
+ return FrozenDict(get_assigned_and_defined_parameter_values(context, self, 'property'))
@cachedmethod
def _get_interfaces(self, context):
@@ -427,7 +426,7 @@ class PolicyTemplate(ExtensiblePresentation):
@cachedmethod
def _get_property_values(self, context):
- return FrozenDict(get_assigned_and_defined_property_values(context, self))
+ return FrozenDict(get_assigned_and_defined_parameter_values(context, self, 'property'))
@cachedmethod
def _get_targets(self, context):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/extensions/aria_extension_tosca/simple_v1_0/types.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/types.py b/extensions/aria_extension_tosca/simple_v1_0/types.py
index bc80eb9..d97b89c 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/types.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/types.py
@@ -33,9 +33,9 @@ from .modeling.capabilities import (get_inherited_valid_source_types,
get_inherited_capability_definitions)
from .modeling.data_types import (get_data_type, get_inherited_constraints, coerce_data_type_value,
validate_data_type_name)
-from .modeling.interfaces import get_inherited_interface_definitions, get_inherited_operations
+from .modeling.interfaces import (get_inherited_interface_definitions, get_inherited_operations)
from .modeling.policies import get_inherited_targets
-from .modeling.properties import get_inherited_property_definitions
+from .modeling.parameters import get_inherited_parameter_definitions
from .modeling.requirements import get_inherited_requirement_definitions
from .presentation.extensible import ExtensiblePresentation
from .presentation.field_getters import data_type_class_getter
@@ -115,7 +115,7 @@ class ArtifactType(ExtensiblePresentation):
@cachedmethod
def _get_properties(self, context):
- return FrozenDict(get_inherited_property_definitions(context, self, 'properties'))
+ return FrozenDict(get_inherited_parameter_definitions(context, self, 'properties'))
def _validate(self, context):
super(ArtifactType, self)._validate(context)
@@ -201,7 +201,7 @@ class DataType(ExtensiblePresentation):
@cachedmethod
def _get_properties(self, context):
- return FrozenDict(get_inherited_property_definitions(context, self, 'properties'))
+ return FrozenDict(get_inherited_parameter_definitions(context, self, 'properties'))
@cachedmethod
def _get_constraints(self, context):
@@ -307,7 +307,7 @@ class CapabilityType(ExtensiblePresentation):
@cachedmethod
def _get_properties(self, context):
- return FrozenDict(get_inherited_property_definitions(context, self, 'properties'))
+ return FrozenDict(get_inherited_parameter_definitions(context, self, 'properties'))
@cachedmethod
def _get_valid_source_types(self, context):
@@ -385,7 +385,7 @@ class InterfaceType(ExtensiblePresentation):
@cachedmethod
def _get_inputs(self, context):
- return FrozenDict(get_inherited_property_definitions(context, self, 'inputs'))
+ return FrozenDict(get_inherited_parameter_definitions(context, self, 'inputs'))
@cachedmethod
def _get_operations(self, context):
@@ -493,11 +493,11 @@ class RelationshipType(ExtensiblePresentation):
@cachedmethod
def _get_properties(self, context):
- return FrozenDict(get_inherited_property_definitions(context, self, 'properties'))
+ return FrozenDict(get_inherited_parameter_definitions(context, self, 'properties'))
@cachedmethod
def _get_attributes(self, context):
- return FrozenDict(get_inherited_property_definitions(context, self, 'attributes'))
+ return FrozenDict(get_inherited_parameter_definitions(context, self, 'attributes'))
@cachedmethod
def _get_interfaces(self, context):
@@ -624,11 +624,11 @@ class NodeType(ExtensiblePresentation):
@cachedmethod
def _get_properties(self, context):
- return FrozenDict(get_inherited_property_definitions(context, self, 'properties'))
+ return FrozenDict(get_inherited_parameter_definitions(context, self, 'properties'))
@cachedmethod
def _get_attributes(self, context):
- return FrozenDict(get_inherited_property_definitions(context, self, 'attributes'))
+ return FrozenDict(get_inherited_parameter_definitions(context, self, 'attributes'))
@cachedmethod
def _get_requirements(self, context):
@@ -760,7 +760,7 @@ class GroupType(ExtensiblePresentation):
@cachedmethod
def _get_properties(self, context):
- return FrozenDict(get_inherited_property_definitions(context, self, 'properties'))
+ return FrozenDict(get_inherited_parameter_definitions(context, self, 'properties'))
@cachedmethod
def _get_interfaces(self, context):
@@ -848,7 +848,7 @@ class PolicyType(ExtensiblePresentation):
@cachedmethod
def _get_properties(self, context):
- return FrozenDict(get_inherited_property_definitions(context, self, 'properties'))
+ return FrozenDict(get_inherited_parameter_definitions(context, self, 'properties'))
@cachedmethod
def _get_targets(self, context):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/tests/cli/test_services.py
----------------------------------------------------------------------
diff --git a/tests/cli/test_services.py b/tests/cli/test_services.py
index b1a6ee4..e5717cc 100644
--- a/tests/cli/test_services.py
+++ b/tests/cli/test_services.py
@@ -19,7 +19,7 @@ import mock
from aria.cli.env import _Environment
from aria.core import Core
from aria.exceptions import DependentActiveExecutionsError, DependentAvailableNodesError
-from aria.modeling.exceptions import InputsException
+from aria.modeling.exceptions import ParameterException
from aria.storage import exceptions as storage_exceptions
from .base_test import ( # pylint: disable=unused-import
@@ -120,11 +120,11 @@ class TestServicesCreate(TestCliBase):
monkeypatch.setattr(_Environment, 'model_storage', mock_storage)
monkeypatch.setattr(Core,
'create_service',
- raise_exception(InputsException))
+ raise_exception(ParameterException))
assert_exception_raised(
self.invoke('services create -t with_inputs test_s'),
- expected_exception=InputsException)
+ expected_exception=ParameterException)
assert "Service created. The service's name is test_s" not in self.logger_output_string
@@ -152,8 +152,8 @@ class TestServicesDelete(TestCliBase):
assert_exception_raised(
self.invoke('services delete test_s'),
expected_exception=DependentActiveExecutionsError,
- expected_msg="Can't delete service {name} - there is an active execution "
- "for this service. Active execution id: 1".format(
+ expected_msg="Can't delete service `{name}` - there is an active execution "
+ "for this service. Active execution ID: 1".format(
name=mock_models.SERVICE_NAME))
def test_delete_available_nodes_error(self, monkeypatch, mock_storage):
@@ -161,8 +161,8 @@ class TestServicesDelete(TestCliBase):
assert_exception_raised(
self.invoke('services delete test_s'),
expected_exception=DependentAvailableNodesError,
- expected_msg="Can't delete service {name} - there are available nodes "
- "for this service. Available node ids: 1".format(
+ expected_msg="Can't delete service `{name}` - there are available nodes "
+ "for this service. Available node IDs: 1".format(
name=mock_models.SERVICE_NAME))
def test_delete_available_nodes_error_with_force(self, monkeypatch, mock_storage):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/tests/mock/models.py
----------------------------------------------------------------------
diff --git a/tests/mock/models.py b/tests/mock/models.py
index 98703d5..50aa340 100644
--- a/tests/mock/models.py
+++ b/tests/mock/models.py
@@ -225,11 +225,11 @@ def create_interface(service, interface_name, operation_name, operation_kwargs=N
interface_kwargs=None):
the_type = service.service_template.interface_types.get_descendant('test_interface_type')
- if operation_kwargs and operation_kwargs.get('inputs'):
- operation_kwargs['inputs'] = dict(
- (input_name, models.Parameter.wrap(input_name, input_value))
- for input_name, input_value in operation_kwargs['inputs'].iteritems()
- if input_value is not None)
+ if operation_kwargs and operation_kwargs.get('arguments'):
+ operation_kwargs['arguments'] = dict(
+ (argument_name, models.Parameter.wrap(argument_name, argument_value))
+ for argument_name, argument_value in operation_kwargs['arguments'].iteritems()
+ if argument_value is not None)
operation = models.Operation(
name=operation_name,
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/tests/mock/topology.py
----------------------------------------------------------------------
diff --git a/tests/mock/topology.py b/tests/mock/topology.py
index bfb7b4e..ab08dbd 100644
--- a/tests/mock/topology.py
+++ b/tests/mock/topology.py
@@ -27,9 +27,9 @@ def create_simple_topology_single_node(model_storage, create_operation):
service_template,
'Standard', 'create',
operation_kwargs=dict(
- implementation=create_operation,
- inputs={'key': aria_models.Parameter.wrap('key', 'create'),
- 'value': aria_models.Parameter.wrap('value', True)})
+ function=create_operation,
+ arguments={'key': aria_models.Parameter.wrap('key', 'create'),
+ 'value': aria_models.Parameter.wrap('value', True)})
)
node_template.interface_templates[interface_template.name] = interface_template # pylint: disable=unsubscriptable-object
@@ -38,9 +38,9 @@ def create_simple_topology_single_node(model_storage, create_operation):
service,
'Standard', 'create',
operation_kwargs=dict(
- implementation=create_operation,
- inputs={'key': aria_models.Parameter.wrap('key', 'create'),
- 'value': aria_models.Parameter.wrap('value', True)})
+ function=create_operation,
+ arguments={'key': aria_models.Parameter.wrap('key', 'create'),
+ 'value': aria_models.Parameter.wrap('value', True)})
)
node.interfaces[interface.name] = interface # pylint: disable=unsubscriptable-object
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/tests/modeling/test_models.py
----------------------------------------------------------------------
diff --git a/tests/modeling/test_models.py b/tests/modeling/test_models.py
index 57511dd..df3aebd 100644
--- a/tests/modeling/test_models.py
+++ b/tests/modeling/test_models.py
@@ -755,7 +755,7 @@ class TestTask(object):
@pytest.mark.parametrize(
'is_valid, status, due_at, started_at, ended_at, max_attempts, attempts_count, '
- 'retry_interval, ignore_failure, name, operation_mapping, inputs, plugin_id',
+ 'retry_interval, ignore_failure, name, operation_mapping, arguments, plugin_id',
[
(False, m_cls, now, now, now, 1, 1, 1, True, 'name', 'map', {}, '1'),
(False, Task.STARTED, m_cls, now, now, 1, 1, 1, True, 'name', 'map', {}, '1'),
@@ -784,7 +784,7 @@ class TestTask(object):
)
def test_task_model_creation(self, execution_storage, is_valid, status, due_at, started_at,
ended_at, max_attempts, attempts_count, retry_interval,
- ignore_failure, name, operation_mapping, inputs, plugin_id):
+ ignore_failure, name, operation_mapping, arguments, plugin_id):
task = _test_model(
is_valid=is_valid,
storage=execution_storage,
@@ -800,8 +800,8 @@ class TestTask(object):
retry_interval=retry_interval,
ignore_failure=ignore_failure,
name=name,
- implementation=operation_mapping,
- inputs=inputs,
+ function=operation_mapping,
+ arguments=arguments,
plugin_fk=plugin_id,
))
if is_valid:
@@ -813,8 +813,8 @@ class TestTask(object):
def create_task(max_attempts):
Task(execution_fk='eid',
name='name',
- implementation='',
- inputs={},
+ function='',
+ arguments={},
max_attempts=max_attempts)
create_task(max_attempts=1)
create_task(max_attempts=2)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/tests/orchestrator/context/test_operation.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/test_operation.py b/tests/orchestrator/context/test_operation.py
index 5d193bc..3dcfaa2 100644
--- a/tests/orchestrator/context/test_operation.py
+++ b/tests/orchestrator/context/test_operation.py
@@ -78,14 +78,14 @@ def test_node_operation_task_execution(ctx, thread_executor, dataholder):
interface_name = 'Standard'
operation_name = 'create'
- inputs = {'putput': True, 'holder_path': dataholder.path}
+ arguments = {'putput': True, 'holder_path': dataholder.path}
node = ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME)
interface = mock.models.create_interface(
node.service,
interface_name,
operation_name,
- operation_kwargs=dict(implementation=op_path(basic_node_operation, module_path=__name__),
- inputs=inputs)
+ operation_kwargs=dict(function=op_path(basic_node_operation, module_path=__name__),
+ arguments=arguments)
)
node.interfaces[interface.name] = interface
ctx.model.node.update(node)
@@ -97,7 +97,7 @@ def test_node_operation_task_execution(ctx, thread_executor, dataholder):
node,
interface_name=interface_name,
operation_name=operation_name,
- inputs=inputs
+ arguments=arguments
)
)
@@ -115,8 +115,8 @@ def test_node_operation_task_execution(ctx, thread_executor, dataholder):
)
operations = interface.operations
assert len(operations) == 1
- assert dataholder['implementation'] == operations.values()[0].implementation # pylint: disable=no-member
- assert dataholder['inputs']['putput'] is True
+ assert dataholder['function'] == operations.values()[0].function # pylint: disable=no-member
+ assert dataholder['arguments']['putput'] is True
# Context based attributes (sugaring)
assert dataholder['template_name'] == node.node_template.name
@@ -127,15 +127,14 @@ def test_relationship_operation_task_execution(ctx, thread_executor, dataholder)
interface_name = 'Configure'
operation_name = 'post_configure'
- inputs = {'putput': True, 'holder_path': dataholder.path}
+ arguments = {'putput': True, 'holder_path': dataholder.path}
relationship = ctx.model.relationship.list()[0]
interface = mock.models.create_interface(
relationship.source_node.service,
interface_name,
operation_name,
- operation_kwargs=dict(implementation=op_path(basic_relationship_operation,
- module_path=__name__),
- inputs=inputs),
+ operation_kwargs=dict(function=op_path(basic_relationship_operation, module_path=__name__),
+ arguments=arguments),
)
relationship.interfaces[interface.name] = interface
@@ -148,7 +147,7 @@ def test_relationship_operation_task_execution(ctx, thread_executor, dataholder)
relationship,
interface_name=interface_name,
operation_name=operation_name,
- inputs=inputs
+ arguments=arguments
)
)
@@ -160,8 +159,8 @@ def test_relationship_operation_task_execution(ctx, thread_executor, dataholder)
assert dataholder['actor_name'] == relationship.name
assert interface_name in dataholder['task_name']
operations = interface.operations
- assert dataholder['implementation'] == operations.values()[0].implementation # pylint: disable=no-member
- assert dataholder['inputs']['putput'] is True
+ assert dataholder['function'] == operations.values()[0].function # pylint: disable=no-member
+ assert dataholder['arguments']['putput'] is True
# Context based attributes (sugaring)
dependency_node_template = ctx.model.node_template.get_by_name(
@@ -197,8 +196,8 @@ def test_invalid_task_operation_id(ctx, thread_executor, dataholder):
node.service,
interface_name=interface_name,
operation_name=operation_name,
- operation_kwargs=dict(implementation=op_path(get_node_id, module_path=__name__),
- inputs={'holder_path': dataholder.path})
+ operation_kwargs=dict(function=op_path(get_node_id, module_path=__name__),
+ arguments={'holder_path': dataholder.path})
)
node.interfaces[interface.name] = interface
ctx.model.node.update(node)
@@ -234,15 +233,15 @@ def test_plugin_workdir(ctx, thread_executor, tmpdir):
node = ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME)
filename = 'test_file'
content = 'file content'
- inputs = {'filename': filename, 'content': content}
+ arguments = {'filename': filename, 'content': content}
interface = mock.models.create_interface(
node.service,
interface_name,
operation_name,
operation_kwargs=dict(
- implementation='{0}.{1}'.format(__name__, _test_plugin_workdir.__name__),
+ function='{0}.{1}'.format(__name__, _test_plugin_workdir.__name__),
plugin=plugin,
- inputs=inputs)
+ arguments=arguments)
)
node.interfaces[interface.name] = interface
ctx.model.node.update(node)
@@ -253,7 +252,7 @@ def test_plugin_workdir(ctx, thread_executor, tmpdir):
node,
interface_name=interface_name,
operation_name=operation_name,
- inputs=inputs))
+ arguments=arguments))
execute(workflow_func=basic_workflow, workflow_context=ctx, executor=thread_executor)
expected_file = tmpdir.join('workdir', 'plugins', str(ctx.service.id),
@@ -280,7 +279,7 @@ def test_node_operation_logging(ctx, executor):
node = ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME)
- inputs = {
+ arguments = {
'op_start': 'op_start',
'op_end': 'op_end',
}
@@ -289,8 +288,8 @@ def test_node_operation_logging(ctx, executor):
interface_name,
operation_name,
operation_kwargs=dict(
- implementation=op_path(logged_operation, module_path=__name__),
- inputs=inputs)
+ function=op_path(logged_operation, module_path=__name__),
+ arguments=arguments)
)
node.interfaces[interface.name] = interface
ctx.model.node.update(node)
@@ -302,19 +301,19 @@ def test_node_operation_logging(ctx, executor):
node,
interface_name=interface_name,
operation_name=operation_name,
- inputs=inputs
+ arguments=arguments
)
)
execute(workflow_func=basic_workflow, workflow_context=ctx, executor=executor)
- _assert_loggins(ctx, inputs)
+ _assert_loggins(ctx, arguments)
def test_relationship_operation_logging(ctx, executor):
interface_name, operation_name = mock.operations.RELATIONSHIP_OPERATIONS_INSTALL[0]
relationship = ctx.model.relationship.list()[0]
- inputs = {
+ arguments = {
'op_start': 'op_start',
'op_end': 'op_end',
}
@@ -322,8 +321,8 @@ def test_relationship_operation_logging(ctx, executor):
relationship.source_node.service,
interface_name,
operation_name,
- operation_kwargs=dict(implementation=op_path(logged_operation, module_path=__name__),
- inputs=inputs)
+ operation_kwargs=dict(function=op_path(logged_operation, module_path=__name__),
+ arguments=arguments)
)
relationship.interfaces[interface.name] = interface
ctx.model.relationship.update(relationship)
@@ -335,12 +334,12 @@ def test_relationship_operation_logging(ctx, executor):
relationship,
interface_name=interface_name,
operation_name=operation_name,
- inputs=inputs
+ arguments=arguments
)
)
execute(workflow_func=basic_workflow, workflow_context=ctx, executor=executor)
- _assert_loggins(ctx, inputs)
+ _assert_loggins(ctx, arguments)
def test_attribute_consumption(ctx, executor, dataholder):
@@ -349,15 +348,15 @@ def test_attribute_consumption(ctx, executor, dataholder):
source_node = ctx.model.node.get_by_name(mock.models.DEPENDENT_NODE_NAME)
- inputs = {'dict_': {'key': 'value'},
- 'set_test_dict': {'key2': 'value2'}}
+ arguments = {'dict_': {'key': 'value'},
+ 'set_test_dict': {'key2': 'value2'}}
interface = mock.models.create_interface(
source_node.service,
node_int_name,
node_op_name,
operation_kwargs=dict(
- implementation=op_path(attribute_altering_operation, module_path=__name__),
- inputs=inputs)
+ function=op_path(attribute_altering_operation, module_path=__name__),
+ arguments=arguments)
)
source_node.interfaces[interface.name] = interface
ctx.model.node.update(source_node)
@@ -372,8 +371,8 @@ def test_attribute_consumption(ctx, executor, dataholder):
rel_int_name,
rel_op_name,
operation_kwargs=dict(
- implementation=op_path(attribute_consuming_operation, module_path=__name__),
- inputs={'holder_path': dataholder.path}
+ function=op_path(attribute_consuming_operation, module_path=__name__),
+ arguments={'holder_path': dataholder.path}
)
)
relationship.interfaces[interface.name] = interface
@@ -387,7 +386,7 @@ def test_attribute_consumption(ctx, executor, dataholder):
source_node,
interface_name=node_int_name,
operation_name=node_op_name,
- inputs=inputs
+ arguments=arguments
),
api.task.OperationTask(
relationship,
@@ -411,8 +410,7 @@ def test_attribute_consumption(ctx, executor, dataholder):
dataholder['key2'] == 'value2'
-def _assert_loggins(ctx, inputs):
-
+def _assert_loggins(ctx, arguments):
# The logs should contain the following: Workflow Start, Operation Start, custom operation
# log string (op_start), custom operation log string (op_end), Operation End, Workflow End.
@@ -432,11 +430,11 @@ def _assert_loggins(ctx, inputs):
assert all(l.execution == execution for l in logs)
assert all(l in logs and l.task == task for l in task.logs)
- op_start_log = [l for l in logs if inputs['op_start'] in l.msg and l.level.lower() == 'info']
+ op_start_log = [l for l in logs if arguments['op_start'] in l.msg and l.level.lower() == 'info']
assert len(op_start_log) == 1
op_start_log = op_start_log[0]
- op_end_log = [l for l in logs if inputs['op_end'] in l.msg and l.level.lower() == 'debug']
+ op_end_log = [l for l in logs if arguments['op_end'] in l.msg and l.level.lower() == 'debug']
assert len(op_end_log) == 1
op_end_log = op_end_log[0]
@@ -445,10 +443,10 @@ def _assert_loggins(ctx, inputs):
@operation
def logged_operation(ctx, **_):
- ctx.logger.info(ctx.task.inputs['op_start'].value)
+ ctx.logger.info(ctx.task.arguments['op_start'].value)
# enables to check the relation between the created_at field properly
time.sleep(1)
- ctx.logger.debug(ctx.task.inputs['op_end'].value)
+ ctx.logger.debug(ctx.task.arguments['op_end'].value)
@operation
@@ -477,8 +475,8 @@ def operation_common(ctx, holder):
holder['actor_name'] = ctx.task.actor.name
holder['task_name'] = ctx.task.name
- holder['implementation'] = ctx.task.implementation
- holder['inputs'] = dict(i.unwrap() for i in ctx.task.inputs.values())
+ holder['function'] = ctx.task.function
+ holder['arguments'] = dict(i.unwrapped for i in ctx.task.arguments.values())
@operation
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/tests/orchestrator/context/test_serialize.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/test_serialize.py b/tests/orchestrator/context/test_serialize.py
index 8a5db6f..4db7bf4 100644
--- a/tests/orchestrator/context/test_serialize.py
+++ b/tests/orchestrator/context/test_serialize.py
@@ -47,7 +47,7 @@ def _mock_workflow(ctx, graph):
node.service,
'test',
'op',
- operation_kwargs=dict(implementation=_operation_mapping(),
+ operation_kwargs=dict(function=_operation_mapping(),
plugin=plugin)
)
node.interfaces[interface.name] = interface
@@ -60,8 +60,8 @@ def _mock_workflow(ctx, graph):
def _mock_operation(ctx):
# We test several things in this operation
# ctx.task, ctx.node, etc... tell us that the model storage was properly re-created
- # a correct ctx.task.implementation tells us we kept the correct task_id
- assert ctx.task.implementation == _operation_mapping()
+ # a correct ctx.task.function tells us we kept the correct task_id
+ assert ctx.task.function == _operation_mapping()
# a correct ctx.node.name tells us we kept the correct actor_id
assert ctx.node.name == mock.models.DEPENDENCY_NODE_NAME
# a correct ctx.name tells us we kept the correct name
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/tests/orchestrator/context/test_toolbelt.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/test_toolbelt.py b/tests/orchestrator/context/test_toolbelt.py
index fc34907..326ce83 100644
--- a/tests/orchestrator/context/test_toolbelt.py
+++ b/tests/orchestrator/context/test_toolbelt.py
@@ -86,12 +86,12 @@ def test_host_ip(workflow_context, executor, dataholder):
interface_name = 'Standard'
operation_name = 'create'
_, dependency_node, _, _, _ = _get_elements(workflow_context)
- inputs = {'putput': True, 'holder_path': dataholder.path}
+ arguments = {'putput': True, 'holder_path': dataholder.path}
interface = mock.models.create_interface(
dependency_node.service,
interface_name=interface_name,
operation_name=operation_name,
- operation_kwargs=dict(implementation=op_path(host_ip, module_path=__name__), inputs=inputs)
+ operation_kwargs=dict(function=op_path(host_ip, module_path=__name__), arguments=arguments)
)
dependency_node.interfaces[interface.name] = interface
dependency_node.attributes['ip'] = models.Parameter.wrap('ip', '1.1.1.1')
@@ -105,7 +105,7 @@ def test_host_ip(workflow_context, executor, dataholder):
dependency_node,
interface_name=interface_name,
operation_name=operation_name,
- inputs=inputs
+ arguments=arguments
)
)
@@ -118,13 +118,13 @@ def test_relationship_tool_belt(workflow_context, executor, dataholder):
interface_name = 'Configure'
operation_name = 'post_configure'
_, _, _, _, relationship = _get_elements(workflow_context)
- inputs = {'putput': True, 'holder_path': dataholder.path}
+ arguments = {'putput': True, 'holder_path': dataholder.path}
interface = mock.models.create_interface(
relationship.source_node.service,
interface_name=interface_name,
operation_name=operation_name,
- operation_kwargs=dict(implementation=op_path(relationship_operation, module_path=__name__),
- inputs=inputs)
+ operation_kwargs=dict(function=op_path(relationship_operation, module_path=__name__),
+ arguments=arguments)
)
relationship.interfaces[interface.name] = interface
workflow_context.model.relationship.update(relationship)
@@ -136,7 +136,7 @@ def test_relationship_tool_belt(workflow_context, executor, dataholder):
relationship,
interface_name=interface_name,
operation_name=operation_name,
- inputs=inputs
+ arguments=arguments
)
)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/tests/orchestrator/execution_plugin/test_local.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/execution_plugin/test_local.py b/tests/orchestrator/execution_plugin/test_local.py
index d9115e1..d792a57 100644
--- a/tests/orchestrator/execution_plugin/test_local.py
+++ b/tests/orchestrator/execution_plugin/test_local.py
@@ -199,7 +199,7 @@ if __name__ == '__main__':
props = self._run(
executor, workflow_context,
script_path=script_path,
- inputs={'key': 'value'})
+ arguments={'key': 'value'})
assert props['key'].value == 'value'
@pytest.mark.parametrize(
@@ -460,10 +460,10 @@ if __name__ == '__main__':
script_path,
process=None,
env_var='value',
- inputs=None):
+ arguments=None):
local_script_path = script_path
script_path = os.path.basename(local_script_path) if local_script_path else ''
- inputs = inputs or {}
+ arguments = arguments or {}
process = process or {}
if script_path:
workflow_context.resource.service.upload(
@@ -471,7 +471,7 @@ if __name__ == '__main__':
source=local_script_path,
path=script_path)
- inputs.update({
+ arguments.update({
'script_path': script_path,
'process': process,
'input_as_env_var': env_var
@@ -485,17 +485,17 @@ if __name__ == '__main__':
'test',
'op',
operation_kwargs=dict(
- implementation='{0}.{1}'.format(
+ function='{0}.{1}'.format(
operations.__name__,
operations.run_script_locally.__name__),
- inputs=inputs)
+ arguments=arguments)
)
node.interfaces[interface.name] = interface
graph.add_tasks(api.task.OperationTask(
node,
interface_name='test',
operation_name='op',
- inputs=inputs))
+ arguments=arguments))
return graph
tasks_graph = mock_workflow(ctx=workflow_context) # pylint: disable=no-value-for-parameter
eng = engine.Engine(
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/tests/orchestrator/execution_plugin/test_ssh.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/execution_plugin/test_ssh.py b/tests/orchestrator/execution_plugin/test_ssh.py
index 92d250e..899a007 100644
--- a/tests/orchestrator/execution_plugin/test_ssh.py
+++ b/tests/orchestrator/execution_plugin/test_ssh.py
@@ -217,7 +217,7 @@ class TestWithActualSSHServer(object):
@workflow
def mock_workflow(ctx, graph):
node = ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME)
- inputs = {
+ arguments = {
'script_path': script_path,
'fabric_env': _FABRIC_ENV,
'process': process,
@@ -226,30 +226,30 @@ class TestWithActualSSHServer(object):
'test_operation': '',
}
if hide_output:
- inputs['hide_output'] = hide_output
+ arguments['hide_output'] = hide_output
if commands:
- inputs['commands'] = commands
+ arguments['commands'] = commands
interface = mock.models.create_interface(
node.service,
'test',
'op',
operation_kwargs=dict(
- implementation='{0}.{1}'.format(
+ function='{0}.{1}'.format(
operations.__name__,
operation.__name__),
- inputs=inputs)
+ arguments=arguments)
)
node.interfaces[interface.name] = interface
ops = []
for test_operation in test_operations:
- op_inputs = inputs.copy()
- op_inputs['test_operation'] = test_operation
+ op_arguments = arguments.copy()
+ op_arguments['test_operation'] = test_operation
ops.append(api.task.OperationTask(
node,
interface_name='test',
operation_name='op',
- inputs=op_inputs))
+ arguments=op_arguments))
graph.sequence(*ops)
return graph
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9174f946/tests/orchestrator/test_workflow_runner.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/test_workflow_runner.py b/tests/orchestrator/test_workflow_runner.py
index 7374e50..3646339 100644
--- a/tests/orchestrator/test_workflow_runner.py
+++ b/tests/orchestrator/test_workflow_runner.py
@@ -48,8 +48,7 @@ def test_missing_workflow_implementation(service, request):
workflow = models.Operation(
name='test_workflow',
service=service,
- implementation='nonexistent.workflow.implementation',
- inputs={})
+ function='nonexistent.workflow.implementation')
service.workflows['test_workflow'] = workflow
with pytest.raises(exceptions.WorkflowImplementationNotFoundError):
@@ -190,7 +189,7 @@ def test_execution_inputs_override_workflow_inputs(request):
def test_execution_inputs_undeclared_inputs(request):
mock_workflow = _setup_mock_workflow_in_service(request)
- with pytest.raises(modeling_exceptions.UndeclaredInputsException):
+ with pytest.raises(modeling_exceptions.UndeclaredParametersException):
_create_workflow_runner(request, mock_workflow, inputs={'undeclared_input': 'value'})
@@ -198,7 +197,7 @@ 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)})
- with pytest.raises(modeling_exceptions.MissingRequiredInputsException):
+ with pytest.raises(modeling_exceptions.MissingRequiredParametersException):
_create_workflow_runner(request, mock_workflow, inputs={})
@@ -206,13 +205,13 @@ def test_execution_inputs_wrong_type_inputs(request):
mock_workflow = _setup_mock_workflow_in_service(
request, inputs={'input': models.Parameter.wrap('input', 'value')})
- with pytest.raises(modeling_exceptions.InputsOfWrongTypeException):
+ with pytest.raises(modeling_exceptions.ParametersOfWrongTypeException):
_create_workflow_runner(request, mock_workflow, inputs={'input': 5})
def test_execution_inputs_builtin_workflow_with_inputs(request):
# built-in workflows don't have inputs
- with pytest.raises(modeling_exceptions.UndeclaredInputsException):
+ with pytest.raises(modeling_exceptions.UndeclaredParametersException):
_create_workflow_runner(request, 'install', inputs={'undeclared_input': 'value'})
@@ -259,8 +258,9 @@ def _setup_mock_workflow_in_service(request, inputs=None):
workflow = models.Operation(
name=mock_workflow_name,
service=service,
- implementation='workflow.mock_workflow',
- inputs=inputs or {})
+ function='workflow.mock_workflow',
+ inputs=inputs or {},
+ arguments=inputs or {})
service.workflows[mock_workflow_name] = workflow
return mock_workflow_name