Exemplo n.º 1
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)
Exemplo n.º 2
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)
Exemplo n.º 3
0
    def __init__(self, conf):
        super(OsloRPCClient, self).__init__(conf)
        self.topic = conf.topic

        serializer = auth_ctx.RpcContextSerializer()

        self._client = messaging.RPCClient(rpc.get_transport(),
                                           messaging.Target(topic=self.topic),
                                           serializer=serializer)
Exemplo n.º 4
0
    def run(self, executor='blocking'):
        target = messaging.Target(topic=self.topic, server=self.server_id)

        server = messaging.get_rpc_server(rpc.get_transport(),
                                          target,
                                          self.endpoints,
                                          executor=executor,
                                          serializer=ctx.RpcContextSerializer(
                                              ctx.JsonPayloadSerializer()))

        server.start()
        server.wait()
Exemplo n.º 5
0
    def __init__(self, conf):
        super(OsloRPCClient, self).__init__(conf)
        self.topic = conf.get('topic', '')

        serializer = auth_ctx.RpcContextSerializer(
            auth_ctx.JsonPayloadSerializer())

        self._client = messaging.RPCClient(
            rpc.get_transport(),
            messaging.Target(topic=self.topic),
            serializer=serializer
        )
Exemplo n.º 6
0
def setup_app(config=None):
    if not config:
        config = get_pecan_config()

    m_config.set_config_defaults()

    app_conf = dict(config.app)

    db_api_v2.setup_db()

    if not app_conf.pop('disable_cron_trigger_thread', False):
        periodic.setup()

    coordination.Service('api_group').register_membership()

    app = pecan.make_app(
        app_conf.pop('root'),
        hooks=lambda: [ctx.ContextHook(), ctx.AuthHook()],
        logging=getattr(config, 'logging', {}),
        **app_conf
    )

    # Set up access control.
    app = access_control.setup(app)

    # TODO(rakhmerov): need to get rid of this call.
    # Set up RPC related flags in config
    rpc.get_transport()

    # Set up profiler.
    if cfg.CONF.profiler.enabled:
        app = osprofiler.web.WsgiMiddleware(
            app,
            hmac_keys=cfg.CONF.profiler.hmac_keys,
            enabled=cfg.CONF.profiler.enabled
        )

    # Create a CORS wrapper, and attach mistral-specific defaults that must be
    # included in all CORS responses.
    return cors_middleware.CORS(app, cfg.CONF)
Exemplo n.º 7
0
def main():
    try:
        config.parse_args(get_properly_ordered_parameters())
        print_server_info()

        logging.setup(CONF, 'Mistral')

        # Please refer to the oslo.messaging documentation for transport
        # configuration. The default transport for oslo.messaging is
        # rabbitMQ. The available transport drivers are listed in the
        # setup.cfg file in oslo.messaging under the entry_points section for
        # oslo.messaging.drivers. The transport driver is specified using the
        # rpc_backend option in the default section of the oslo configuration
        # file. The expected value for the rpc_backend is one of the key
        # values available for the oslo.messaging.drivers (i.e. rabbit, fake).
        # There are additional options such as ssl and credential that can be
        # specified depending on the driver.  Please refer to the driver
        # implementation for those additional options. It's important to note
        # that the "fake" transport should only be used if "all" the Mistral
        # servers are launched on the same process. Otherwise, messages do not
        # get delivered if the Mistral servers are launched on different
        # processes because the "fake" transport is using an in process queue.
        rpc.get_transport()

        if cfg.CONF.server == ['all']:
            # Launch all servers.
            launch_any(LAUNCH_OPTIONS.keys())
        else:
            # Validate launch option.
            if set(cfg.CONF.server) - set(LAUNCH_OPTIONS.keys()):
                raise Exception('Valid options are all or any combination of '
                                ', '.join(LAUNCH_OPTIONS.keys()))

            # Launch distinct set of server(s).
            launch_any(set(cfg.CONF.server))

    except RuntimeError as excp:
        sys.stderr.write("ERROR: %s\n" % excp)
        sys.exit(1)
Exemplo n.º 8
0
def main():
    try:
        config.parse_args(get_properly_ordered_parameters())
        print_server_info()

        logging.setup(CONF, 'Mistral')

        # Please refer to the oslo.messaging documentation for transport
        # configuration. The default transport for oslo.messaging is
        # rabbitMQ. The available transport drivers are listed in the
        # setup.cfg file in oslo.messaging under the entry_points section for
        # oslo.messaging.drivers. The transport driver is specified using the
        # rpc_backend option in the default section of the oslo configuration
        # file. The expected value for the rpc_backend is one of the key
        # values available for the oslo.messaging.drivers (i.e. rabbit, fake).
        # There are additional options such as ssl and credential that can be
        # specified depending on the driver.  Please refer to the driver
        # implementation for those additional options. It's important to note
        # that the "fake" transport should only be used if "all" the Mistral
        # servers are launched on the same process. Otherwise, messages do not
        # get delivered if the Mistral servers are launched on different
        # processes because the "fake" transport is using an in process queue.
        rpc.get_transport()

        if cfg.CONF.server == ['all']:
            # Launch all servers.
            launch_any(LAUNCH_OPTIONS.keys())
        else:
            # Validate launch option.
            if set(cfg.CONF.server) - set(LAUNCH_OPTIONS.keys()):
                raise Exception('Valid options are all or any combination of '
                                'api, engine, and executor.')

            # Launch distinct set of server(s).
            launch_any(set(cfg.CONF.server))

    except RuntimeError as excp:
        sys.stderr.write("ERROR: %s\n" % excp)
        sys.exit(1)
Exemplo n.º 9
0
    def run(self, executor='blocking'):
        target = messaging.Target(topic=self.topic, server=self.server_id)

        # TODO(rakhmerov): rpc.get_transport() should be in oslo.messaging
        # related module.
        self.oslo_server = messaging.get_rpc_server(
            rpc.get_transport(),
            target,
            self.endpoints,
            executor=executor,
            serializer=ctx.RpcContextSerializer(ctx.JsonPayloadSerializer()))

        self.oslo_server.start()
Exemplo n.º 10
0
    def run(self):
        target = messaging.Target(
            topic=self.topic,
            server=self.server_id
        )

        server = messaging.get_rpc_server(
            rpc.get_transport(),
            target,
            self.endpoints,
            executor='eventlet',
            serializer=ctx.RpcContextSerializer(ctx.JsonPayloadSerializer())
        )

        server.start()
        server.wait()
Exemplo n.º 11
0
    def run(self, executor='blocking'):
        target = messaging.Target(
            topic=self.topic,
            server=self.server_id
        )

        # TODO(rakhmerov): rpc.get_transport() should be in oslo.messaging
        # related module.
        self.oslo_server = messaging.get_rpc_server(
            rpc.get_transport(),
            target,
            self.endpoints,
            executor=executor,
            serializer=ctx.RpcContextSerializer(ctx.JsonPayloadSerializer())
        )

        self.oslo_server.start()