コード例 #1
0
    def _clean_db(self):
        lookup_utils.clear_caches()

        contexts = [get_context(default=False), get_context(default=True)]

        for ctx in contexts:
            auth_context.set_ctx(ctx)

            with mock.patch('mistral.services.security.get_project_id',
                            new=mock.MagicMock(return_value=ctx.project_id)):
                with db_api.transaction():
                    db_api.delete_event_triggers()
                    db_api.delete_cron_triggers()
                    db_api.delete_workflow_executions()
                    db_api.delete_task_executions()
                    db_api.delete_action_executions()
                    db_api.delete_workbooks()
                    db_api.delete_workflow_definitions()
                    db_api.delete_environments()
                    db_api.delete_resource_members()
                    db_api.delete_delayed_calls()
                    db_api.delete_scheduled_jobs()

        sqlite_lock.cleanup()

        if not cfg.CONF.database.connection.startswith('sqlite'):
            db_sa_base.get_engine().dispose()
コード例 #2
0
    def rerun(self, task_ex, reset=True, env=None):
        """Rerun workflow from the given task.

        :param task_ex: Task execution that the workflow needs to rerun from.
        :param reset: If True, reset task state including deleting its action
            executions.
        :param env: Environment.
        """

        assert self.wf_ex

        # Since some lookup utils functions may use cache for completed tasks
        # we need to clean caches to make sure that stale objects can't be
        # retrieved.
        lookup_utils.clear_caches()

        wf_service.update_workflow_execution_env(self.wf_ex, env)

        self.set_state(states.RUNNING, recursive=True)

        wf_ctrl = wf_base.get_controller(self.wf_ex)

        # Calculate commands to process next.
        cmds = wf_ctrl.rerun_tasks([task_ex], reset=reset)

        if cmds:
            # Import the task_handler module here to avoid circular reference.
            from mistral.engine import policies

            policies.RetryPolicy.refresh_runtime_context(task_ex)

        self._continue_workflow(cmds)
コード例 #3
0
    def rerun(self, task_ex, reset=True, env=None):
        """Rerun workflow from the given task.

        :param task_ex: Task execution that the workflow needs to rerun from.
        :param reset: If True, reset task state including deleting its action
            executions.
        :param env: Environment.
        """

        assert self.wf_ex

        # Since some lookup utils functions may use cache for completed tasks
        # we need to clean caches to make sure that stale objects can't be
        # retrieved.
        lookup_utils.clear_caches()

        # Add default wf_ex.params['env'] for rerun, pass commands extensions.
        # It uses in update_workflow_execution_env method.
        #
        # task_input: customer manual input data
        # task_output: customer manual output data
        # task_action: rerun | pass
        if 'env' not in self.wf_ex.params:
            self.wf_ex.params['env'] = {}
        self._task_input_data = env.pop('task_input', None)
        self._task_action = env.pop('task_action', None)
        self._task_output_data = env.pop('task_output', None)

        wf_service.update_workflow_execution_env(self.wf_ex, env)

        self.set_state(states.RUNNING, recursive=True)

        wf_ctrl = wf_base.get_controller(self.wf_ex)

        # Calculate commands to process next.
        cmds = wf_ctrl.rerun_tasks([task_ex], reset=reset)

        # Add manual input field in task execution instance for delivering
        # input data to task handling level.
        for cmd in cmds:
            cmd.task_ex._manual_input = self._task_input_data
            cmd.task_ex._manual_action = self._task_action
            cmd.task_ex._manual_output = self._task_output_data

        self._continue_workflow(cmds)