def _schedule_execution(self, action_alias_db, params, notify, context, requester_user,
                            show_secrets):
        action_ref = action_alias_db.action_ref
        action_db = action_utils.get_action_by_ref(action_ref)

        if not action_db:
            raise StackStormDBObjectNotFoundError('Action with ref "%s" not found ' % (action_ref))

        assert_user_has_resource_db_permission(user_db=requester_user, resource_db=action_db,
                                               permission_type=PermissionType.ACTION_EXECUTE)

        try:
            # prior to shipping off the params cast them to the right type.
            params = action_param_utils.cast_params(action_ref=action_alias_db.action_ref,
                                                    params=params,
                                                    cast_overrides=CAST_OVERRIDES)
            if not context:
                context = {
                    'action_alias_ref': reference.get_ref_from_model(action_alias_db),
                    'user': get_system_username()
                }
            liveaction = LiveActionDB(action=action_alias_db.action_ref, context=context,
                                      parameters=params, notify=notify)
            _, action_execution_db = action_service.request(liveaction)
            mask_secrets = self._get_mask_secrets(requester_user, show_secrets=show_secrets)
            return ActionExecutionAPI.from_model(action_execution_db, mask_secrets=mask_secrets)
        except ValueError as e:
            LOG.exception('Unable to execute action.')
            abort(http_client.BAD_REQUEST, str(e))
        except jsonschema.ValidationError as e:
            LOG.exception('Unable to execute action. Parameter validation failed.')
            abort(http_client.BAD_REQUEST, str(e))
        except Exception as e:
            LOG.exception('Unable to execute action. Unexpected error encountered.')
            abort(http_client.INTERNAL_SERVER_ERROR, str(e))
示例#2
0
    def _run_action(self, action_node, parent_execution_id, params, wait_for_completion=True):
        liveaction = LiveActionDB(action=action_node.ref)
        liveaction.parameters = action_param_utils.cast_params(action_ref=action_node.ref,
                                                               params=params)

        # Setup notify for task in chain.
        notify = self._get_notify(action_node)
        if notify:
            liveaction.notify = notify
            LOG.debug('%s: Task notify set to: %s', action_node.name, liveaction.notify)

        liveaction.context = {
            'parent': str(parent_execution_id),
            'chain': vars(action_node)
        }

        liveaction, _ = action_service.request(liveaction)

        while (wait_for_completion and
               liveaction.status != LIVEACTION_STATUS_SUCCEEDED and
               liveaction.status != LIVEACTION_STATUS_FAILED):
            eventlet.sleep(1)
            liveaction = action_db_util.get_liveaction_by_id(liveaction.id)

        return liveaction
示例#3
0
 def _schedule_execution(self, action_alias_db, params, notify, context):
     try:
         # prior to shipping off the params cast them to the right type.
         params = action_param_utils.cast_params(
             action_ref=action_alias_db.action_ref,
             params=params,
             cast_overrides=CAST_OVERRIDES)
         if not context:
             context = {
                 'action_alias_ref':
                 reference.get_ref_from_model(action_alias_db),
                 'user':
                 get_system_username()
             }
         liveaction = LiveActionDB(action=action_alias_db.action_ref,
                                   context=context,
                                   parameters=params,
                                   notify=notify)
         _, action_execution_db = action_service.request(liveaction)
         return action_execution_db
     except ValueError as e:
         LOG.exception('Unable to execute action.')
         pecan.abort(http_client.BAD_REQUEST, str(e))
     except jsonschema.ValidationError as e:
         LOG.exception(
             'Unable to execute action. Parameter validation failed.')
         pecan.abort(http_client.BAD_REQUEST, str(e))
     except Exception as e:
         LOG.exception(
             'Unable to execute action. Unexpected error encountered.')
         pecan.abort(http_client.INTERNAL_SERVER_ERROR, str(e))
示例#4
0
    def _run_action(self,
                    action_node,
                    parent_execution_id,
                    params,
                    wait_for_completion=True):
        liveaction = LiveActionDB(action=action_node.ref)
        liveaction.parameters = action_param_utils.cast_params(
            action_ref=action_node.ref, params=params)
        if action_node.notify:
            liveaction.notify = NotificationsHelper.to_model(
                action_node.notify)

        liveaction.context = {
            'parent': str(parent_execution_id),
            'chain': vars(action_node)
        }

        liveaction, _ = action_service.schedule(liveaction)

        while (wait_for_completion
               and liveaction.status != LIVEACTION_STATUS_SUCCEEDED
               and liveaction.status != LIVEACTION_STATUS_FAILED):
            eventlet.sleep(1)
            liveaction = action_db_util.get_liveaction_by_id(liveaction.id)

        return liveaction
示例#5
0
    def _schedule_execution(self, action_alias_db, params, notify, context):
        action_ref = action_alias_db.action_ref
        action_db = action_utils.get_action_by_ref(action_ref)

        if not action_db:
            raise StackStormDBObjectNotFoundError('Action with ref "%s" not found ' % (action_ref))

        assert_request_user_has_resource_db_permission(request=pecan.request, resource_db=action_db,
            permission_type=PermissionType.ACTION_EXECUTE)

        try:
            # prior to shipping off the params cast them to the right type.
            params = action_param_utils.cast_params(action_ref=action_alias_db.action_ref,
                                                    params=params,
                                                    cast_overrides=CAST_OVERRIDES)
            if not context:
                context = {
                    'action_alias_ref': reference.get_ref_from_model(action_alias_db),
                    'user': get_system_username()
                }
            liveaction = LiveActionDB(action=action_alias_db.action_ref, context=context,
                                      parameters=params, notify=notify)
            _, action_execution_db = action_service.request(liveaction)
            return ActionExecutionAPI.from_model(action_execution_db)
        except ValueError as e:
            LOG.exception('Unable to execute action.')
            pecan.abort(http_client.BAD_REQUEST, str(e))
        except jsonschema.ValidationError as e:
            LOG.exception('Unable to execute action. Parameter validation failed.')
            pecan.abort(http_client.BAD_REQUEST, str(e))
        except Exception as e:
            LOG.exception('Unable to execute action. Unexpected error encountered.')
            pecan.abort(http_client.INTERNAL_SERVER_ERROR, str(e))
示例#6
0
    def _run_action(self,
                    action_node,
                    parent_execution_id,
                    params,
                    wait_for_completion=True):
        liveaction = LiveActionDB(action=action_node.ref)
        liveaction.parameters = action_param_utils.cast_params(
            action_ref=action_node.ref, params=params)

        # Setup notify for task in chain.
        notify = self._get_notify(action_node)
        if notify:
            liveaction.notify = notify
            LOG.debug('%s: Task notify set to: %s', action_node.name,
                      liveaction.notify)

        liveaction.context = {
            'parent': str(parent_execution_id),
            'chain': vars(action_node)
        }

        liveaction, _ = action_service.request(liveaction)

        while (wait_for_completion
               and liveaction.status != LIVEACTION_STATUS_SUCCEEDED
               and liveaction.status != LIVEACTION_STATUS_FAILED):
            eventlet.sleep(1)
            liveaction = action_db_util.get_liveaction_by_id(liveaction.id)

        return liveaction
示例#7
0
 def _invoke_action(action, params, context=None):
     action_ref = action['ref']
     # prior to shipping off the params cast them to the right type.
     params = action_param_utils.cast_params(action_ref, params)
     liveaction = LiveActionDB(action=action_ref,
                               context=context,
                               parameters=params)
     liveaction, _ = action_service.schedule(liveaction)
     return ({
         'id': str(liveaction.id)
     } if liveaction.status == LIVEACTION_STATUS_SCHEDULED else None)
示例#8
0
    def _run_action(action_node, parent_execution_id, params, wait_for_completion=True):
        execution = LiveActionDB(action=action_node.ref)
        execution.parameters = action_param_utils.cast_params(action_ref=action_node.ref,
                                                              params=params)
        execution.context = {
            'parent': str(parent_execution_id),
            'chain': vars(action_node)
        }

        liveaction, _ = action_service.schedule(execution)
        while (wait_for_completion and
               liveaction.status != LIVEACTION_STATUS_SUCCEEDED and
               liveaction.status != LIVEACTION_STATUS_FAILED):
            eventlet.sleep(1)
            liveaction = action_db_util.get_liveaction_by_id(liveaction.id)
        return liveaction
示例#9
0
    def _build_liveaction_object(self, action_node, resolved_params, parent_context):
        liveaction = LiveActionDB(action=action_node.ref)

        # Setup notify for task in chain.
        notify = self._get_notify(action_node)
        if notify:
            liveaction.notify = notify
            LOG.debug('%s: Task notify set to: %s', action_node.name, liveaction.notify)

        liveaction.context = {
            'parent': parent_context,
            'chain': vars(action_node)
        }
        liveaction.parameters = action_param_utils.cast_params(action_ref=action_node.ref,
                                                               params=resolved_params)
        return liveaction
示例#10
0
    def _build_liveaction_object(self, action_node, resolved_params, parent_context):
        liveaction = LiveActionDB(action=action_node.ref)

        # Setup notify for task in chain.
        notify = self._get_notify(action_node)
        if notify:
            liveaction.notify = notify
            LOG.debug('%s: Task notify set to: %s', action_node.name, liveaction.notify)

        liveaction.context = {
            'parent': parent_context,
            'chain': vars(action_node)
        }
        liveaction.parameters = action_param_utils.cast_params(action_ref=action_node.ref,
                                                               params=resolved_params)
        return liveaction
示例#11
0
 def _schedule_execution(self, action_alias_db, params, notify):
     try:
         # prior to shipping off the params cast them to the right type.
         params = action_param_utils.cast_params(action_ref=action_alias_db.action_ref,
                                                 params=params)
         liveaction = LiveActionDB(action=action_alias_db.action_ref, context={},
                                   parameters=params, notify=notify)
         _, action_execution_db = action_service.request(liveaction)
         return action_execution_db
     except ValueError as e:
         LOG.exception('Unable to execute action.')
         pecan.abort(http_client.BAD_REQUEST, str(e))
     except jsonschema.ValidationError as e:
         LOG.exception('Unable to execute action. Parameter validation failed.')
         pecan.abort(http_client.BAD_REQUEST, str(e))
     except Exception as e:
         LOG.exception('Unable to execute action. Unexpected error encountered.')
         pecan.abort(http_client.INTERNAL_SERVER_ERROR, str(e))
示例#12
0
 def _run_action(action_node,
                 parent_execution_id,
                 params,
                 wait_for_completion=True):
     execution = LiveActionDB(action=action_node.ref)
     execution.parameters = action_param_utils.cast_params(
         action_ref=action_node.ref, params=params)
     execution.context = {
         'parent': str(parent_execution_id),
         'chain': vars(action_node)
     }
     execution, _ = action_service.schedule(execution)
     while (wait_for_completion
            and execution.status != LIVEACTION_STATUS_SUCCEEDED
            and execution.status != LIVEACTION_STATUS_FAILED):
         eventlet.sleep(1)
         execution = action_db_util.get_liveaction_by_id(execution.id)
     return execution
示例#13
0
 def _schedule_execution(self, action_alias_db, params, notify):
     try:
         # prior to shipping off the params cast them to the right type.
         params = action_param_utils.cast_params(action_ref=action_alias_db.action_ref,
                                                 params=params)
         liveaction = LiveActionDB(action=action_alias_db.action_ref, context={},
                                   parameters=params, notify=notify)
         _, action_execution_db = action_service.schedule(liveaction)
         return action_execution_db
     except ValueError as e:
         LOG.exception('Unable to execute action.')
         pecan.abort(http_client.BAD_REQUEST, str(e))
     except jsonschema.ValidationError as e:
         LOG.exception('Unable to execute action. Parameter validation failed.')
         pecan.abort(http_client.BAD_REQUEST, str(e))
     except Exception as e:
         LOG.exception('Unable to execute action. Unexpected error encountered.')
         pecan.abort(http_client.INTERNAL_SERVER_ERROR, str(e))
示例#14
0
    def _invoke_action(action_exec_spec, params, context=None):
        """
        Schedule an action execution.

        :type action_exec_spec: :class:`ActionExecutionSpecDB`

        :param params: Parameters to execute the action with.
        :type params: ``dict``

        :rtype: :class:`LiveActionDB` on successful schedueling, None otherwise.
        """
        action_ref = action_exec_spec['ref']

        # prior to shipping off the params cast them to the right type.
        params = action_param_utils.cast_params(action_ref, params)
        liveaction = LiveActionDB(action=action_ref, context=context, parameters=params)
        liveaction, execution = action_service.request(liveaction)

        return execution
示例#15
0
    def _invoke_action(action, params, context=None):
        """
        Schedule an action execution.

        :rtype: :class:`LiveActionDB` on successful schedueling, None otherwise.
        """
        action_ref = action['ref']

        # prior to shipping off the params cast them to the right type.
        params = action_param_utils.cast_params(action_ref, params)
        liveaction = LiveActionDB(action=action_ref,
                                  context=context,
                                  parameters=params)
        liveaction, _ = action_service.schedule(liveaction)

        if liveaction.status == LIVEACTION_STATUS_SCHEDULED:
            return liveaction
        else:
            return None
示例#16
0
    def _invoke_action(action_exec_spec, params, context=None):
        """
        Schedule an action execution.

        :type action_exec_spec: :class:`ActionExecutionSpecDB`

        :param params: Parameters to execute the action with.
        :type params: ``dict``

        :rtype: :class:`LiveActionDB` on successful schedueling, None otherwise.
        """
        action_ref = action_exec_spec['ref']

        # prior to shipping off the params cast them to the right type.
        params = action_param_utils.cast_params(action_ref, params)
        liveaction = LiveActionDB(action=action_ref,
                                  context=context,
                                  parameters=params)
        liveaction, execution = action_service.request(liveaction)

        return execution
示例#17
0
 def _schedule_execution(self, action_alias_db, params, notify, context):
     try:
         # prior to shipping off the params cast them to the right type.
         params = action_param_utils.cast_params(action_ref=action_alias_db.action_ref,
                                                 params=params,
                                                 cast_overrides=CAST_OVERRIDES)
         if not context:
             context = {
                 'action_alias_ref': reference.get_ref_from_model(action_alias_db),
                 'user': get_system_username()
             }
         liveaction = LiveActionDB(action=action_alias_db.action_ref, context=context,
                                   parameters=params, notify=notify)
         _, action_execution_db = action_service.request(liveaction)
         return action_execution_db
     except ValueError as e:
         LOG.exception('Unable to execute action.')
         pecan.abort(http_client.BAD_REQUEST, str(e))
     except jsonschema.ValidationError as e:
         LOG.exception('Unable to execute action. Parameter validation failed.')
         pecan.abort(http_client.BAD_REQUEST, str(e))
     except Exception as e:
         LOG.exception('Unable to execute action. Unexpected error encountered.')
         pecan.abort(http_client.INTERNAL_SERVER_ERROR, str(e))