Example #1
0
def eventlet_rpc_server():
    LOG.info(_LI("Eventlet based AMQP RPC server starting..."))
    rpc_workers_launcher = common_service.ProcessLauncher(
        cfg.CONF, wait_interval=1.0
    )
    try:
        service.start_rpc_workers(rpc_workers_launcher)
    except NotImplementedError:
        LOG.info(_LI("RPC was already started in parent process by "
                     "plugin."))
    else:
        rpc_workers_launcher.wait()
Example #2
0
    def _serve_rpc(self, workers=1):
        """Start RPC server with a given number of workers."""

        # Mock start method to check that children are started again on
        # receiving SIGHUP.
        with mock.patch("neutron.service.RpcWorker.start") as start_method:
            with mock.patch(
                    "neutron.manager.NeutronManager.get_plugin"
            ) as get_plugin:
                start_method.side_effect = self._fake_start
                get_plugin.return_value = self.plugin

                CONF.set_override("rpc_workers", workers)
                # not interested in state report workers specifically
                CONF.set_override("rpc_state_report_workers", 0)

                rpc_workers_launcher = common_service.ProcessLauncher(CONF)
                service.start_rpc_workers(rpc_workers_launcher)
                rpc_workers_launcher.wait()
Example #3
0
def eventlet_rpc_server():
    LOG.info(_LI("Eventlet based AMQP RPC server starting..."))

    try:
        rpc_workers_launcher = service.start_rpc_workers()
    except NotImplementedError:
        LOG.info(_LI("RPC was already started in parent process by "
                     "plugin."))
    else:
        rpc_workers_launcher.wait()
def eventlet_rpc_server():
    LOG.info("Eventlet based AMQP RPC server starting...")

    try:
        manager.init()
        ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
        ext_mgr.extend_resources("2.0", attributes.RESOURCES)
        rpc_workers_launcher = service.start_rpc_workers()
    except NotImplementedError:
        LOG.info("RPC was already started in parent process by " "plugin.")
    else:
        rpc_workers_launcher.wait()
Example #5
0
def start_api_and_rpc_workers(neutron_api):
    try:
        plugin_workers_launcher = common_service.ProcessLauncher(
            cfg.CONF, wait_interval=1.0
        )
        service.start_rpc_workers(plugin_workers_launcher)

        pool = eventlet.GreenPool()
        api_thread = pool.spawn(neutron_api.wait)
        plugin_workers_thread = pool.spawn(plugin_workers_launcher.wait)

        # api and other workers should die together. When one dies,
        # kill the other.
        api_thread.link(lambda gt: plugin_workers_thread.kill())
        plugin_workers_thread.link(lambda gt: api_thread.kill())

        pool.waitall()
    except NotImplementedError:
        LOG.info(_LI("RPC was already started in parent process by "
                     "plugin."))

        neutron_api.wait()
Example #6
0
def eventlet_rpc_server():
    LOG.info("Eventlet based AMQP RPC server starting...")

    try:
        manager.init()
        ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
        ext_mgr.extend_resources("2.0", attributes.RESOURCES)
        rpc_workers_launcher = service.start_rpc_workers()
    except NotImplementedError:
        LOG.info("RPC was already started in parent process by "
                 "plugin.")
    else:
        rpc_workers_launcher.wait()
Example #7
0
    def _serve_rpc(self, workers=1):
        """Start RPC server with a given number of workers."""

        # Mock start method to check that children are started again on
        # receiving SIGHUP.
        with mock.patch("neutron.service.RpcWorker.start") as start_method:
            with mock.patch(
                    "neutron_lib.plugins.directory.get_plugin") as get_plugin:
                start_method.side_effect = self._fake_start
                get_plugin.return_value = self.plugin

                CONF.set_override("rpc_workers", workers)
                # not interested in state report workers specifically
                CONF.set_override("rpc_state_report_workers", 0)

                rpc_workers_launcher = service.start_rpc_workers()
                rpc_workers_launcher.wait()