예제 #1
0
def start_api_and_rpc_workers(neutron_api):
    pool = eventlet.GreenPool()

    api_thread = pool.spawn(neutron_api.wait)

    try:
        neutron_rpc = service.serve_rpc()
    except NotImplementedError:
        LOG.info(_LI("RPC was already started in parent process by "
                     "plugin."))
    else:
        rpc_thread = pool.spawn(neutron_rpc.wait)

        plugin_workers = service.start_plugin_workers()
        for worker in plugin_workers:
            pool.spawn(worker.wait)

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

    pool.waitall()
예제 #2
0
def main():
    # the configuration will be read into the cfg.CONF global data structure
    config.init(sys.argv[1:])
    if not cfg.CONF.config_file:
        sys.exit(
            _("ERROR: Unable to find configuration file via the default"
              " search paths (~/.neutron/, ~/, /etc/neutron/, /etc/) and"
              " the '--config-file' option!"))
    try:
        pool = eventlet.GreenPool()

        neutron_api = service.serve_wsgi(service.NeutronApiService)
        api_thread = pool.spawn(neutron_api.wait)

        try:
            neutron_rpc = service.serve_rpc()
        except NotImplementedError:
            LOG.info(
                _LI("RPC was already started in parent process by "
                    "plugin."))
        else:
            rpc_thread = pool.spawn(neutron_rpc.wait)

            plugin_workers = service.start_plugin_workers()
            for worker in plugin_workers:
                pool.spawn(worker.wait)

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

        pool.waitall()
    except KeyboardInterrupt:
        pass
    except RuntimeError as e:
        sys.exit(_("ERROR: %s") % e)
예제 #3
0
 def _start_plugin(self, workers=0):
     with mock.patch('neutron.manager.NeutronManager.get_plugin') as gp:
         gp.return_value = self.plugin
         launchers = service.start_plugin_workers()
         for launcher in launchers:
             launcher.wait()
예제 #4
0
 def _start_plugin(self, workers=0):
     with mock.patch('neutron.manager.NeutronManager.get_plugin') as gp:
         gp.return_value = self.plugin
         launchers = service.start_plugin_workers()
         for launcher in launchers:
             launcher.wait()
예제 #5
0
 def _start_plugin(self, workers=1):
     with mock.patch('neutron.manager.NeutronManager.get_plugin') as gp:
         gp.return_value = self.plugin
         plugin_workers_launcher = common_service.ProcessLauncher(CONF)
         service.start_plugin_workers(plugin_workers_launcher)
         plugin_workers_launcher.wait()