[
https://issues.apache.org/jira/browse/ARIA-92?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15967448#comment-15967448
]
ASF GitHub Bot commented on ARIA-92:
------------------------------------
Github user ran-z commented on a diff in the pull request:
https://github.com/apache/incubator-ariatosca/pull/95#discussion_r111367789
--- Diff: extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
---
@@ -677,21 +698,47 @@ def pattern(node_type, container): # pylint:
disable=unused-argument
return None
-def parse_implementation_string(context, service_template, implementation):
- if not implementation:
- return None, ''
+def split_prefix(string):
+ """
+ Splits the prefix on the first unescaped ">".
+ """
- index = implementation.find('>')
- if index == -1:
- return None, implementation
- plugin_name = implementation[:index].strip()
-
- if plugin_name == 'execution':
- plugin_specification = None
- else:
- plugin_specification =
service_template.plugin_specifications.get(plugin_name)
- if plugin_specification is None:
- raise ValueError('unknown plugin: "{0}"'.format(plugin_name))
+ split = IMPLEMENTATION_PREFIX_REGEX.split(string, 2)
+ if len(split) < 2:
+ return None, string
+ return split[0].strip(), split[1].lstrip()
+
+
+def set_nested(the_dict, keys, value):
+ """
+ If the ``keys`` list has just one item, puts the value in the the
dict. If there are more items,
+ puts the value in a sub-dict, creating sub-dicts as necessary for each
key.
- implementation = implementation[index+1:].strip()
- return plugin_specification, implementation
+ For example, if ``the_dict`` is an empty dict, keys is ``['first',
'second', 'third']`` and
+ value is ``'value'``, then the_dict will be:
``{'first':{'second':{'third':'value'}}}``.
+
+ :param the_dict: Dict to change
+ :type the_dict: {}
+ :param keys: Keys
+ :type keys: [basestring]
+ :param value: Value
+ """
+ key = keys.pop(0)
+ if len(keys) == 0:
+ the_dict[key] = value
+ else:
+ if key not in the_dict:
+ the_dict[key] = StrictDict(key_class=basestring)
+ set_nested(the_dict[key], keys, value)
+
+
+def parse_implementation_string(context, service_template, presentation,
model, implementation):
+ plugin_name, model.implementation = split_prefix(implementation)
+ if plugin_name is not None:
+ model.plugin_specification =
service_template.plugin_specifications.get(plugin_name)
+ if model.plugin_specification is None:
+ context.validation.report(
+ 'no policy for plugin "%s" specified in operation
implementation: %s'
--- End diff --
use string format please :sweat_smile:
> Execution plugin operations default mappings
> --------------------------------------------
>
> Key: ARIA-92
> URL: https://issues.apache.org/jira/browse/ARIA-92
> Project: AriaTosca
> Issue Type: Story
> Reporter: Ran Ziv
> Assignee: Tal Liron
>
> The execution plugin serves as the default plugin, i.e. if no other plugin
> was specified, it'll be used to execute scripts in operations.
> These scripts will currently only execute locally. The execution plugin also
> supports running scripts on remote machines (via SSH).
> One option is to have the parser recognize whether the node in question is
> contained inside a host node, in which case the script should be executed
> remotely (by default, yet overridable by specifying the full plugin operation
> mapping), and if not then it should be executed locally.
> Another option is to have the user specify it using special syntax, e.g.:
> "local > script.sh" and "remote > script.sh"
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)