Beispiel #1
0
    def _render_publish_vars(action_node, action_parameters, execution_result,
                             previous_execution_results, chain_vars):
        """
        If no output is specified on the action_node the output is the entire execution_result.
        If any output is specified then only those variables are published as output of an
        execution of this action_node.
        The output variable can refer to a variable from the execution_result,
        previous_execution_results or chain_vars.
        """
        if not action_node.publish:
            return {}

        context = {}
        context.update(action_parameters)
        context.update({action_node.name: execution_result})
        context.update(previous_execution_results)
        context.update(chain_vars)
        context.update({RESULTS_KEY: previous_execution_results})
        context.update({SYSTEM_KV_PREFIX: KeyValueLookup()})

        try:
            rendered_result = jinja_utils.render_values(
                mapping=action_node.publish, context=context)
        except Exception as e:
            key = getattr(e, 'key', None)
            value = getattr(e, 'value', None)
            msg = (
                'Failed rendering value for publish parameter "%s" in task "%s" '
                '(template string=%s): %s' %
                (key, action_node.name, value, str(e)))
            raise ParameterRenderingFailedException(msg)

        return rendered_result
Beispiel #2
0
    def _resolve_params(action_node, original_parameters, results, chain_vars,
                        chain_context):
        # setup context with original parameters and the intermediate results.
        context = {}
        context.update(original_parameters)
        context.update(results)
        context.update(chain_vars)
        context.update({RESULTS_KEY: results})
        context.update({SYSTEM_SCOPE: KeyValueLookup(scope=SYSTEM_SCOPE)})
        context.update({
            DATASTORE_PARENT_SCOPE: {
                SYSTEM_SCOPE: KeyValueLookup(scope=FULL_SYSTEM_SCOPE)
            }
        })
        context.update({ACTION_CONTEXT_KV_PREFIX: chain_context})
        try:
            rendered_params = jinja_utils.render_values(
                mapping=action_node.get_parameters(), context=context)
        except Exception as e:
            LOG.exception('Jinja rendering for parameter "%s" failed.' %
                          (e.key))

            key = getattr(e, 'key', None)
            value = getattr(e, 'value', None)
            msg = (
                'Failed rendering value for action parameter "%s" in task "%s" '
                '(template string=%s): %s') % (key, action_node.name, value,
                                               str(e))
            raise ParameterRenderingFailedException(msg)
        LOG.debug('Rendered params: %s: Type: %s', rendered_params,
                  type(rendered_params))
        return rendered_params
Beispiel #3
0
 def _resolve_params(action_node, original_parameters, results, chain_vars, chain_context):
     # setup context with original parameters and the intermediate results.
     context = {}
     context.update(original_parameters)
     context.update(results)
     context.update(chain_vars)
     context.update({RESULTS_KEY: results})
     context.update({SYSTEM_KV_PREFIX: KeyValueLookup()})
     context.update({ACTION_KV_PREFIX: chain_context})
     try:
         rendered_params = jinja_utils.render_values(mapping=action_node.params,
                                                     context=context)
     except Exception as e:
         LOG.exception('Jinja rendering failed.')
         raise ParameterRenderingFailedException(e)
     LOG.debug('Rendered params: %s: Type: %s', rendered_params, type(rendered_params))
     return rendered_params