[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/incubator-ariatosca/pull/138


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119449922
  
--- Diff: aria/modeling/utils.py ---
@@ -51,74 +53,95 @@ def service_template(self):
 return self.container.service_template
 
 
-def create_inputs(inputs, template_inputs):
+def merge_parameter_values(parameter_values, declared_parameters, 
forbidden_names=None):
--- End diff --

:+1: 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119449742
  
--- Diff: aria/modeling/utils.py ---
@@ -52,84 +53,95 @@ def service_template(self):
 return self.container.service_template
 
 
-def create_parameters(parameters, declared_parameters):
+def merge_parameter_values(parameter_values, declared_parameters, 
forbidden_names=None):
--- End diff --

:+1: 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119449679
  
--- Diff: extensions/aria_extension_tosca/simple_v1_0/modeling/functions.py 
---
@@ -69,7 +69,7 @@ def __evaluate__(self, container_holder):
 e, final = evaluate(e, final, container_holder)
 if e is not None:
 value.write(unicode(e))
-value = value.getvalue()
+value = value.getvalue() or u''
--- End diff --

:+1:


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119449714
  
--- Diff: aria/orchestrator/workflow_runner.py ---
@@ -136,10 +137,11 @@ def _validate_no_active_executions(self, execution):
 active_executions = [e for e in self.service.executions if 
e.is_active()]
 if active_executions:
 raise exceptions.ActiveExecutionsError(
-"Can't start execution; Service {0} has an active 
execution with id {1}"
+"Can't start execution; Service {0} has an active 
execution with ID {1}"
 .format(self.service.name, active_executions[0].id))
 
-def _get_workflow_fn(self):
+@property
+def _workflow_fn(self):
--- End diff --

:+1: 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119449695
  
--- Diff: aria/orchestrator/workflows/events_logging.py ---
@@ -35,20 +35,20 @@ def _get_task_name(task):
 
 @events.start_task_signal.connect
 def _start_task_handler(task, **kwargs):
-# If the task has not implementation this is an empty task.
-if task.implementation:
+# If the task has no function this is an empty task.
+if task.function:
 suffix = 'started...'
 logger = task.context.logger.info
 else:
-suffix = 'has no implementation'
+suffix = 'has no function'
--- End diff --

:+1: 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119449551
  
--- Diff: tests/orchestrator/test_workflow_runner.py ---
@@ -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 {})
--- End diff --

right :+1: 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119449568
  
--- Diff: aria/modeling/exceptions.py ---
@@ -57,3 +57,9 @@ class UndeclaredParametersException(ParameterException):
 """
 ARIA modeling exception: Undeclared parameters have been provided.
 """
+
+
+class ForbiddenParameterNamesException(ParameterException):
--- End diff --

:+1: 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread tliron
Github user tliron commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119447056
  
--- Diff: aria/modeling/utils.py ---
@@ -51,74 +53,95 @@ def service_template(self):
 return self.container.service_template
 
 
-def create_inputs(inputs, template_inputs):
+def merge_parameter_values(parameter_values, declared_parameters, 
forbidden_names=None):
--- End diff --

The original code was superfluous and complex, doing unpacking and 
re-packing of values, and actually had a bug in one area of it. I think this 
code is much cleaner!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread tliron
Github user tliron commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119446847
  
--- Diff: tests/orchestrator/test_workflow_runner.py ---
@@ -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 {})
--- End diff --

No, not in the way this particular test works, since it creates an 
operation model directly and doesn't call `configure()`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread tliron
Github user tliron commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119446252
  
--- Diff: aria/modeling/exceptions.py ---
@@ -57,3 +57,9 @@ class UndeclaredParametersException(ParameterException):
 """
 ARIA modeling exception: Undeclared parameters have been provided.
 """
+
+
+class ForbiddenParameterNamesException(ParameterException):
--- End diff --

Changing to "Reserved".


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread tliron
Github user tliron commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119446194
  
--- Diff: extensions/aria_extension_tosca/simple_v1_0/modeling/functions.py 
---
@@ -69,7 +69,7 @@ def __evaluate__(self, container_holder):
 e, final = evaluate(e, final, container_holder)
 if e is not None:
 value.write(unicode(e))
-value = value.getvalue()
+value = value.getvalue() or u''
--- End diff --

We default to Unicode everywhere possible in values -- this avoids thorny 
problems later down the road with values.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119445992
  
--- Diff: aria/modeling/utils.py ---
@@ -51,74 +53,95 @@ def service_template(self):
 return self.container.service_template
 
 
-def create_inputs(inputs, template_inputs):
+def merge_parameter_values(parameter_values, declared_parameters, 
forbidden_names=None):
--- End diff --

what was the purpose of the changes to this method? im not sure i 
understand the benefit and it seems less readable now to me


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread tliron
Github user tliron commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119445999
  
--- Diff: aria/orchestrator/workflows/events_logging.py ---
@@ -35,20 +35,20 @@ def _get_task_name(task):
 
 @events.start_task_signal.connect
 def _start_task_handler(task, **kwargs):
-# If the task has not implementation this is an empty task.
-if task.implementation:
+# If the task has no function this is an empty task.
+if task.function:
 suffix = 'started...'
 logger = task.context.logger.info
 else:
-suffix = 'has no implementation'
+suffix = 'has no function'
--- End diff --

Changing back to "implementation".


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread tliron
Github user tliron commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119445955
  
--- Diff: aria/orchestrator/workflow_runner.py ---
@@ -136,10 +137,11 @@ def _validate_no_active_executions(self, execution):
 active_executions = [e for e in self.service.executions if 
e.is_active()]
 if active_executions:
 raise exceptions.ActiveExecutionsError(
-"Can't start execution; Service {0} has an active 
execution with id {1}"
+"Can't start execution; Service {0} has an active 
execution with ID {1}"
 .format(self.service.name, active_executions[0].id))
 
-def _get_workflow_fn(self):
+@property
+def _workflow_fn(self):
--- End diff --

Changing back to function.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread tliron
Github user tliron commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119445875
  
--- Diff: aria/orchestrator/execution_plugin/instantiation.py ---
@@ -16,107 +16,132 @@
 # TODO: this module will eventually be moved to a new "aria.instantiation" 
package
 
 from ...utils.type import full_type_name
-from ...utils.collections import OrderedDict
+from ...utils.formatting import safe_repr
 from ...parser import validation
 from ...parser.consumption import ConsumptionContext
+from ...modeling.functions import Function
 
 
 def configure_operation(operation):
-configuration = OrderedDict(operation.configuration) if 
operation.configuration else {}
-
-arguments = OrderedDict()
-arguments['script_path'] = operation.implementation
-arguments['process'] = _get_process(configuration.pop('process')) \
-if 'process' in configuration else dict()
-
 host = None
 interface = operation.interface
 if interface.node is not None:
 host = interface.node.host
 elif interface.relationship is not None:
 if operation.relationship_edge is True:
 host = interface.relationship.target_node.host
-else: # either False or None
+else: # either False or None (None meaning that edge was not 
specified)
 host = interface.relationship.source_node.host
 
+_configure_common(operation)
 if host is None:
 _configure_local(operation)
 else:
-_configure_remote(operation, configuration, arguments)
+_configure_remote(operation)
+
+# Any remaining un-handled configuration parameters will become extra 
arguments, available as
+# kwargs in either "run_script_locally" or "run_script_with_ssh"
+for key, value in operation.configuration.iteritems():
+if key not in ('process', 'ssh'):
+operation.arguments[key] = value.instantiate()
 
-# Any remaining unhandled configuration values will become extra 
arguments, available as kwargs
-# in either "run_script_locally" or "run_script_with_ssh"
-arguments.update(configuration)
 
-return arguments
+def _configure_common(operation):
+"""
+Local and remote operations.
+"""
+
+from ...modeling.models import Parameter
+operation.arguments['script_path'] = Parameter.wrap('script_path', 
operation.implementation,
+'Relative path to 
the executable file.')
+operation.arguments['process'] = Parameter.wrap('process', 
_get_process(operation),
+'Sub-process 
configuration.')
+
 
 def _configure_local(operation):
 """
 Local operation.
 """
+
 from . import operations
-operation.implementation = '{0}.{1}'.format(operations.__name__,
-
operations.run_script_locally.__name__)
+operation.function = '{0}.{1}'.format(operations.__name__,
+  
operations.run_script_locally.__name__)
 
 
-def _configure_remote(operation, configuration, arguments):
+def _configure_remote(operation):
 """
 Remote SSH operation via Fabric.
 """
+
+from ...modeling.models import Parameter
+from . import operations
+
+ssh = _get_ssh(operation)
+
+# Defaults
 # TODO: find a way to configure these generally in the service template
 default_user = ''
 default_password = ''
-
-ssh = _get_ssh(configuration.pop('ssh')) if 'ssh' in configuration 
else {}
 if 'user' not in ssh:
 ssh['user'] = default_user
 if ('password' not in ssh) and ('key' not in ssh) and ('key_filename' 
not in ssh):
 ssh['password'] = default_password
 
-arguments['use_sudo'] = ssh.get('use_sudo', False)
-arguments['hide_output'] = ssh.get('hide_output', [])
-arguments['fabric_env'] = {}
+operation.arguments['use_sudo'] = Parameter.wrap('use_sudo', 
ssh.get('use_sudo', False),
--- End diff --

If you notice I am also giving the parameters descriptions here. These are 
not mere dicts, but true parameters.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119445302
  
--- Diff: tests/orchestrator/test_workflow_runner.py ---
@@ -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 {})
--- End diff --

why is this needed? wouldn't arguments get auto-populated with inputs 
anyway?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119444625
  
--- Diff: 
tests/resources/service-templates/tosca-simple-1.0/node-cellar/node-cellar.yaml 
---
@@ -309,7 +311,7 @@ policy_types:
   client connections cleanly and shut down services. 
 derived_from: aria.Workflow
 properties:
-  implementation:
+  function:
--- End diff --

:+1: 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119444608
  
--- Diff: extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py 
---
@@ -384,18 +387,37 @@ def create_operation_template_model(context, 
service_template, operation):
 model.relationship_edge = True
 
 dependencies = implementation.dependencies
+configuration = OrderedDict()
 if dependencies:
 for dependency in dependencies:
 key, value = split_prefix(dependency)
 if key is not None:
-if model.configuration is None:
-model.configuration = {}
-set_nested(model.configuration, key.split('.'), value)
+# Parse as YAML
+try:
+value = yaml.load(value)
+except yaml.parser.MarkedYAMLError as e:
+context.validation.report(
+'YAML parser {0} in operation configuration: 
{1}'
+.format(e.problem, value),
+locator=implementation._locator,
+level=Issue.FIELD)
+continue
--- End diff --

:+1: 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119442939
  
--- Diff: aria/modeling/utils.py ---
@@ -52,84 +53,95 @@ def service_template(self):
 return self.container.service_template
 
 
-def create_parameters(parameters, declared_parameters):
+def merge_parameter_values(parameter_values, declared_parameters, 
forbidden_names=None):
--- End diff --

i thought we talked about the concept of validating "forbidden names" and 
we agreed it should be done in the parser / instantiation phases instead. I 
don't see in what scenario we'd like to inform the user of such validation 
errors only at this stage.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119443983
  
--- Diff: aria/modeling/exceptions.py ---
@@ -22,9 +22,9 @@ class ModelingException(AriaException):
 """
 
 
-class InputsException(ModelingException):
+class ParameterException(ModelingException):
--- End diff --

:+1: 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119444005
  
--- Diff: 
extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py ---
@@ -71,6 +72,7 @@ def get_assigned_and_defined_property_values(context, 
presentation, field_name='
 values = OrderedDict()
 
 the_type = presentation._get_type(context)
+field_name_plural = pluralize(field_name)
--- End diff --

:+1: 



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119443130
  
--- Diff: aria/modeling/exceptions.py ---
@@ -57,3 +57,9 @@ class UndeclaredParametersException(ParameterException):
 """
 ARIA modeling exception: Undeclared parameters have been provided.
 """
+
+
+class ForbiddenParameterNamesException(ParameterException):
--- End diff --

perhaps "Reserved" is more appropriate than "Forbidden"?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119427199
  
--- Diff: aria/orchestrator/workflow_runner.py ---
@@ -136,10 +137,11 @@ def _validate_no_active_executions(self, execution):
 active_executions = [e for e in self.service.executions if 
e.is_active()]
 if active_executions:
 raise exceptions.ActiveExecutionsError(
-"Can't start execution; Service {0} has an active 
execution with id {1}"
+"Can't start execution; Service {0} has an active 
execution with ID {1}"
 .format(self.service.name, active_executions[0].id))
 
-def _get_workflow_fn(self):
+@property
+def _workflow_fn(self):
--- End diff --

what's a `property` about this? it's a function with possible side effects, 
its private, and it isn't really meant to be used repeatedly, so i think it 
actually stands better as a function.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119428842
  
--- Diff: extensions/aria_extension_tosca/simple_v1_0/modeling/functions.py 
---
@@ -69,7 +69,7 @@ def __evaluate__(self, container_holder):
 e, final = evaluate(e, final, container_holder)
 if e is not None:
 value.write(unicode(e))
-value = value.getvalue()
+value = value.getvalue() or u''
--- End diff --

why do the value we return here need to be unicode again?
i understand the need to support unicode values which are set by the user, 
but why does it matter whether the value returned in case there never was a 
value is unicode or not?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119428083
  
--- Diff: aria/orchestrator/workflows/events_logging.py ---
@@ -35,20 +35,20 @@ def _get_task_name(task):
 
 @events.start_task_signal.connect
 def _start_task_handler(task, **kwargs):
-# If the task has not implementation this is an empty task.
-if task.implementation:
+# If the task has no function this is an empty task.
+if task.function:
 suffix = 'started...'
 logger = task.context.logger.info
 else:
-suffix = 'has no implementation'
+suffix = 'has no function'
--- End diff --

actually, in this specific instance, it should probably remain 
`implementation` - function is an implementation (sorry for the confusing term 
in this context :D) detail, but in practice what the message means is that the 
user didn't input (there i go with the terms again.. :D) any implementation for 
the operation (AKA empty operation)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #138: ARIA-149 Enhance operation configurat...

2017-05-31 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/138#discussion_r119443917
  
--- Diff: aria/orchestrator/execution_plugin/instantiation.py ---
@@ -16,107 +16,132 @@
 # TODO: this module will eventually be moved to a new "aria.instantiation" 
package
 
 from ...utils.type import full_type_name
-from ...utils.collections import OrderedDict
+from ...utils.formatting import safe_repr
 from ...parser import validation
 from ...parser.consumption import ConsumptionContext
+from ...modeling.functions import Function
 
 
 def configure_operation(operation):
-configuration = OrderedDict(operation.configuration) if 
operation.configuration else {}
-
-arguments = OrderedDict()
-arguments['script_path'] = operation.implementation
-arguments['process'] = _get_process(configuration.pop('process')) \
-if 'process' in configuration else dict()
-
 host = None
 interface = operation.interface
 if interface.node is not None:
 host = interface.node.host
 elif interface.relationship is not None:
 if operation.relationship_edge is True:
 host = interface.relationship.target_node.host
-else: # either False or None
+else: # either False or None (None meaning that edge was not 
specified)
 host = interface.relationship.source_node.host
 
+_configure_common(operation)
 if host is None:
 _configure_local(operation)
 else:
-_configure_remote(operation, configuration, arguments)
+_configure_remote(operation)
+
+# Any remaining un-handled configuration parameters will become extra 
arguments, available as
+# kwargs in either "run_script_locally" or "run_script_with_ssh"
+for key, value in operation.configuration.iteritems():
+if key not in ('process', 'ssh'):
+operation.arguments[key] = value.instantiate()
 
-# Any remaining unhandled configuration values will become extra 
arguments, available as kwargs
-# in either "run_script_locally" or "run_script_with_ssh"
-arguments.update(configuration)
 
-return arguments
+def _configure_common(operation):
+"""
+Local and remote operations.
+"""
+
+from ...modeling.models import Parameter
+operation.arguments['script_path'] = Parameter.wrap('script_path', 
operation.implementation,
+'Relative path to 
the executable file.')
+operation.arguments['process'] = Parameter.wrap('process', 
_get_process(operation),
+'Sub-process 
configuration.')
+
 
 def _configure_local(operation):
 """
 Local operation.
 """
+
 from . import operations
-operation.implementation = '{0}.{1}'.format(operations.__name__,
-
operations.run_script_locally.__name__)
+operation.function = '{0}.{1}'.format(operations.__name__,
+  
operations.run_script_locally.__name__)
 
 
-def _configure_remote(operation, configuration, arguments):
+def _configure_remote(operation):
 """
 Remote SSH operation via Fabric.
 """
+
+from ...modeling.models import Parameter
+from . import operations
+
+ssh = _get_ssh(operation)
+
+# Defaults
 # TODO: find a way to configure these generally in the service template
 default_user = ''
 default_password = ''
-
-ssh = _get_ssh(configuration.pop('ssh')) if 'ssh' in configuration 
else {}
 if 'user' not in ssh:
 ssh['user'] = default_user
 if ('password' not in ssh) and ('key' not in ssh) and ('key_filename' 
not in ssh):
 ssh['password'] = default_password
 
-arguments['use_sudo'] = ssh.get('use_sudo', False)
-arguments['hide_output'] = ssh.get('hide_output', [])
-arguments['fabric_env'] = {}
+operation.arguments['use_sudo'] = Parameter.wrap('use_sudo', 
ssh.get('use_sudo', False),
--- End diff --

It's true that configuration parameters are wrapped in another place when 
it's not intended for the execution plugin, but my question is why bother 
wrapping them at this stage at all - as opposed to working with dicts at this 
stage and then have the instantiation code which calls this module do the 
wrapping. it just makes more sense IMO.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is en