[
https://issues.apache.org/jira/browse/ARIA-149?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16021269#comment-16021269
]
ASF GitHub Bot commented on ARIA-149:
-------------------------------------
Github user ran-z commented on a diff in the pull request:
https://github.com/apache/incubator-ariatosca/pull/138#discussion_r118009534
--- 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 --
shouldn't the wrapping of configuration parameters simply take place where
this module is called from?
what about configuration parameters not meant for the execution plugin?
> Support instrinsic functions in "dependencies" operation configuration
> ----------------------------------------------------------------------
>
> Key: ARIA-149
> URL: https://issues.apache.org/jira/browse/ARIA-149
> Project: AriaTosca
> Issue Type: Story
> Reporter: Tal Liron
> Assignee: Tal Liron
>
> There are a few issues here. First, the following YAML is totally broken;
> {code}
> dependencies:
> - ssh.address > { get_attribute: virtual_ip.floating_ip }
> {code}
> The problem is that in YAML, due to the location of the ":", this gets parsed
> as a dict where the key is {code}ssh.address > { get_attribute{code} and the
> value is {code}virtual_ip.floating_ip }{code} which is not what we want at
> all.
> The solution is to encase the whole value in quotes to enforce parsing as a
> string:
> {code}
> dependencies:
> - "ssh.address > { get_attribute: virtual_ip.floating_ip }"
> {code}
> Note that the one attractive solution is to to change this ">" format to a
> real dict. So:
> {code}
> dependencies:
> - { ssh.address: { get_attribute: virtual_ip.floating_ip } }
> {code}
> But this will break other TOSCA parsers that expect a string here, so no go.
> :(
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)