Ejemplo n.º 1
0
def _run_actions():
    for action_ex, action_def, target in _get_queue():
        rpc.get_executor_client().run_action(
            action_ex.id,
            action_def.action_class,
            action_def.attributes or {},
            action_ex.input,
            target,
            safe_rerun=action_ex.runtime_context.get('safe_rerun', False))
Ejemplo n.º 2
0
def _run_actions():
    for action_ex, action_def, target in _get_queue():
        rpc.get_executor_client().run_action(
            action_ex.id,
            action_def.action_class,
            action_def.attributes or {},
            action_ex.input,
            target,
            safe_rerun=action_ex.runtime_context.get('safe_rerun', False)
        )
Ejemplo n.º 3
0
    def run(self, input_dict, target, index=0, desc='', save=True):
        assert not self.action_ex

        input_dict = self._prepare_input(input_dict)
        runtime_ctx = self._prepare_runtime_context(index)

        # Assign the action execution ID here to minimize database calls.
        # Otherwise, the input property of the action execution DB object needs
        # to be updated with the action execution ID after the action execution
        # DB object is created.
        action_ex_id = utils.generate_unicode_uuid()

        self._insert_action_context(action_ex_id, input_dict, save=save)

        if save:
            self._create_action_execution(
                input_dict,
                runtime_ctx,
                desc=desc,
                action_ex_id=action_ex_id
            )

        result = rpc.get_executor_client().run_action(
            self.action_ex.id if self.action_ex else None,
            self.action_def.action_class,
            self.action_def.attributes or {},
            input_dict,
            target,
            async=False
        )

        return self._prepare_output(result)
Ejemplo n.º 4
0
    def setUp(self):
        super(EngineTestCase, self).setUp()

        # Get transport here to let oslo.messaging setup default config
        # before changing the rpc_backend to the fake driver; otherwise,
        # oslo.messaging will throw exception.
        messaging.get_transport(cfg.CONF)

        # Set the transport to 'fake' for Engine tests.
        cfg.CONF.set_default('rpc_backend', 'fake')

        # Drop all RPC objects (transport, clients).
        rpc.cleanup()
        transport = rpc.get_transport()

        self.engine_client = rpc.get_engine_client()
        self.executor_client = rpc.get_executor_client()

        self.engine = def_eng.DefaultEngine(self.engine_client)
        self.executor = def_exec.DefaultExecutor(self.engine_client)

        LOG.info("Starting engine and executor threads...")

        self.threads = [
            eventlet.spawn(launch_engine_server, transport, self.engine),
            eventlet.spawn(launch_executor_server, transport, self.executor),
        ]

        self.addOnException(self.print_executions)

        # Start scheduler.
        scheduler_thread_group = scheduler.setup()

        self.addCleanup(self.kill_threads)
        self.addCleanup(scheduler_thread_group.stop)
Ejemplo n.º 5
0
    def run(self, input_dict, target, index=0, desc='', save=True,
            safe_rerun=False):
        assert not self.action_ex

        input_dict = self._prepare_input(input_dict)
        runtime_ctx = self._prepare_runtime_context(index, safe_rerun)

        # Assign the action execution ID here to minimize database calls.
        # Otherwise, the input property of the action execution DB object needs
        # to be updated with the action execution ID after the action execution
        # DB object is created.
        action_ex_id = utils.generate_unicode_uuid()

        self._insert_action_context(action_ex_id, input_dict, save=save)

        if save:
            self._create_action_execution(
                input_dict,
                runtime_ctx,
                desc=desc,
                action_ex_id=action_ex_id
            )

        result = rpc.get_executor_client().run_action(
            self.action_ex.id if self.action_ex else None,
            self.action_def.action_class,
            self.action_def.attributes or {},
            input_dict,
            target,
            async=False,
            safe_rerun=safe_rerun
        )

        return self._prepare_output(result)
Ejemplo n.º 6
0
    def setUp(self):
        super(EngineTestCase, self).setUp()

        # Get transport here to let oslo.messaging setup default config
        # before changing the rpc_backend to the fake driver; otherwise,
        # oslo.messaging will throw exception.
        messaging.get_transport(cfg.CONF)

        # Set the transport to 'fake' for Engine tests.
        cfg.CONF.set_default('rpc_backend', 'fake')

        # Drop all RPC objects (transport, clients).
        rpc.cleanup()
        transport = rpc.get_transport()

        self.engine_client = rpc.get_engine_client()
        self.executor_client = rpc.get_executor_client()

        self.engine = def_eng.DefaultEngine(self.engine_client)
        self.executor = def_exec.DefaultExecutor(self.engine_client)

        LOG.info("Starting engine and executor threads...")

        self.threads = [
            eventlet.spawn(launch_engine_server, transport, self.engine),
            eventlet.spawn(launch_executor_server, transport, self.executor),
        ]

        self.addOnException(self.print_executions)

        # Start scheduler.
        scheduler_thread_group = scheduler.setup()

        self.addCleanup(self.kill_threads)
        self.addCleanup(scheduler_thread_group.stop)
Ejemplo n.º 7
0
def _run_existing_action(action_ex_id, target):
    action_ex = db_api.get_action_execution(action_ex_id)
    action_def = db_api.get_action_definition(action_ex.name)

    result = rpc.get_executor_client().run_action(
        action_ex_id,
        action_def.action_class,
        action_def.attributes or {},
        action_ex.input,
        target,
        safe_rerun=action_ex.runtime_context.get('safe_rerun', False))

    return _get_action_output(result) if result else None
Ejemplo n.º 8
0
def _run_existing_action(action_ex_id, target):
    action_ex = db_api.get_action_execution(action_ex_id)
    action_def = db_api.get_action_definition(action_ex.name)

    result = rpc.get_executor_client().run_action(
        action_ex_id,
        action_def.action_class,
        action_def.attributes or {},
        action_ex.input,
        target
    )

    return _get_action_output(result) if result else None
Ejemplo n.º 9
0
def _run_existing_action(action_ex_id, target):
    action_ex = db_api.get_action_execution(action_ex_id)
    action_def = db_api.get_action_definition(action_ex.name)

    result = rpc.get_executor_client().run_action(
        action_ex_id,
        action_def.action_class,
        action_def.attributes or {},
        action_ex.input,
        target,
        safe_rerun=action_ex.runtime_context.get('safe_rerun', False)
    )

    return _get_action_output(result) if result else None
Ejemplo n.º 10
0
    def setUp(self):
        super(EngineTestCase, self).setUp()

        # Get transport here to let oslo.messaging setup default config
        # before changing the rpc_backend to the fake driver; otherwise,
        # oslo.messaging will throw exception.
        messaging.get_transport(cfg.CONF)

        # Set the transport to 'fake' for Engine tests.
        cfg.CONF.set_default('rpc_backend', 'fake')

        # Drop all RPC objects (transport, clients).
        rpc.cleanup()

        self.engine_client = rpc.get_engine_client()
        self.executor_client = rpc.get_executor_client()

        LOG.info("Starting engine and executor threads...")

        engine_service = engine_server.get_oslo_service(setup_profiler=False)
        executor_service = executor_server.get_oslo_service(
            setup_profiler=False)

        self.engine = engine_service.engine
        self.executor = executor_service.executor

        self.threads = [
            eventlet.spawn(launch_service, executor_service),
            eventlet.spawn(launch_service, engine_service)
        ]

        self.addOnException(self.print_executions)

        self.addCleanup(executor_service.stop, True)
        self.addCleanup(engine_service.stop, True)
        self.addCleanup(self.kill_threads)

        # Make sure that both services fully started, otherwise
        # the test may run too early.
        executor_service.wait_started()
        engine_service.wait_started()