Merge "Don't decide web_framework before config parse"
This commit is contained in:
commit
b80d77ddfe
@ -12,27 +12,22 @@
|
|||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
|
from neutron import server
|
||||||
from neutron.server import rpc_eventlet
|
from neutron.server import rpc_eventlet
|
||||||
from neutron.server import wsgi_eventlet
|
from neutron.server import wsgi_eventlet
|
||||||
from neutron.server import wsgi_pecan
|
from neutron.server import wsgi_pecan
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
server.boot_server(_main_neutron_server)
|
||||||
|
|
||||||
|
|
||||||
|
def _main_neutron_server():
|
||||||
if cfg.CONF.web_framework == 'legacy':
|
if cfg.CONF.web_framework == 'legacy':
|
||||||
main_wsgi_eventlet()
|
wsgi_eventlet.eventlet_wsgi_server()
|
||||||
else:
|
else:
|
||||||
main_wsgi_pecan()
|
wsgi_pecan.pecan_wsgi_server()
|
||||||
|
|
||||||
|
|
||||||
def main_wsgi_eventlet():
|
|
||||||
wsgi_eventlet.main()
|
|
||||||
|
|
||||||
|
|
||||||
# Eventlet patching is not required for Pecan, but some plugins still spawn
|
|
||||||
# eventlet threads
|
|
||||||
def main_wsgi_pecan():
|
|
||||||
wsgi_pecan.main()
|
|
||||||
|
|
||||||
|
|
||||||
def main_rpc_eventlet():
|
def main_rpc_eventlet():
|
||||||
rpc_eventlet.main()
|
server.boot_server(rpc_eventlet.eventlet_rpc_server)
|
||||||
|
@ -22,13 +22,12 @@ import eventlet
|
|||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
|
||||||
from neutron._i18n import _LI
|
from neutron._i18n import _LI
|
||||||
from neutron import server
|
|
||||||
from neutron import service
|
from neutron import service
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def _eventlet_rpc_server():
|
def eventlet_rpc_server():
|
||||||
pool = eventlet.GreenPool()
|
pool = eventlet.GreenPool()
|
||||||
LOG.info(_LI("Eventlet based AMQP RPC server starting..."))
|
LOG.info(_LI("Eventlet based AMQP RPC server starting..."))
|
||||||
try:
|
try:
|
||||||
@ -39,7 +38,3 @@ def _eventlet_rpc_server():
|
|||||||
else:
|
else:
|
||||||
pool.spawn(neutron_rpc.wait)
|
pool.spawn(neutron_rpc.wait)
|
||||||
pool.waitall()
|
pool.waitall()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
server.boot_server(_eventlet_rpc_server)
|
|
||||||
|
@ -15,13 +15,12 @@ import eventlet
|
|||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
|
||||||
from neutron._i18n import _LI
|
from neutron._i18n import _LI
|
||||||
from neutron import server
|
|
||||||
from neutron import service
|
from neutron import service
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def _eventlet_wsgi_server():
|
def eventlet_wsgi_server():
|
||||||
pool = eventlet.GreenPool()
|
pool = eventlet.GreenPool()
|
||||||
|
|
||||||
neutron_api = service.serve_wsgi(service.NeutronApiService)
|
neutron_api = service.serve_wsgi(service.NeutronApiService)
|
||||||
@ -44,7 +43,3 @@ def _eventlet_wsgi_server():
|
|||||||
api_thread.link(lambda gt: rpc_thread.kill())
|
api_thread.link(lambda gt: rpc_thread.kill())
|
||||||
|
|
||||||
pool.waitall()
|
pool.waitall()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
server.boot_server(_eventlet_wsgi_server)
|
|
||||||
|
@ -21,7 +21,6 @@ from six.moves import socketserver
|
|||||||
from neutron._i18n import _LI, _LW
|
from neutron._i18n import _LI, _LW
|
||||||
from neutron.common import rpc as n_rpc
|
from neutron.common import rpc as n_rpc
|
||||||
from neutron.pecan_wsgi import app as pecan_app
|
from neutron.pecan_wsgi import app as pecan_app
|
||||||
from neutron import server
|
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
@ -31,7 +30,7 @@ class ThreadedSimpleServer(socketserver.ThreadingMixIn,
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _pecan_wsgi_server():
|
def pecan_wsgi_server():
|
||||||
LOG.info(_LI("Pecan WSGI server starting..."))
|
LOG.info(_LI("Pecan WSGI server starting..."))
|
||||||
# No AMQP connection should be created within this process
|
# No AMQP connection should be created within this process
|
||||||
n_rpc.RPC_DISABLED = True
|
n_rpc.RPC_DISABLED = True
|
||||||
@ -54,7 +53,3 @@ def _pecan_wsgi_server():
|
|||||||
)
|
)
|
||||||
|
|
||||||
wsgi.serve_forever()
|
wsgi.serve_forever()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
server.boot_server(_pecan_wsgi_server)
|
|
||||||
|
@ -17,18 +17,18 @@ from neutron.cmd.eventlet import server
|
|||||||
from neutron.tests import base
|
from neutron.tests import base
|
||||||
|
|
||||||
|
|
||||||
@mock.patch('neutron.cmd.eventlet.server.main_wsgi_eventlet')
|
@mock.patch('neutron.server.wsgi_eventlet.eventlet_wsgi_server')
|
||||||
@mock.patch('neutron.cmd.eventlet.server.main_wsgi_pecan')
|
@mock.patch('neutron.server.wsgi_pecan.pecan_wsgi_server')
|
||||||
class TestNeutronServer(base.BaseTestCase):
|
class TestNeutronServer(base.BaseTestCase):
|
||||||
|
|
||||||
def test_legacy_server(self, pecan_mock, legacy_mock):
|
def test_legacy_server(self, pecan_mock, legacy_mock):
|
||||||
cfg.CONF.set_override('web_framework', 'legacy')
|
cfg.CONF.set_override('web_framework', 'legacy')
|
||||||
server.main()
|
server._main_neutron_server()
|
||||||
pecan_mock.assert_not_called()
|
pecan_mock.assert_not_called()
|
||||||
legacy_mock.assert_called_with()
|
legacy_mock.assert_called_with()
|
||||||
|
|
||||||
def test_pecan_server(self, pecan_mock, legacy_mock):
|
def test_pecan_server(self, pecan_mock, legacy_mock):
|
||||||
cfg.CONF.set_override('web_framework', 'pecan')
|
cfg.CONF.set_override('web_framework', 'pecan')
|
||||||
server.main()
|
server._main_neutron_server()
|
||||||
pecan_mock.assert_called_with()
|
pecan_mock.assert_called_with()
|
||||||
legacy_mock.assert_not_called()
|
legacy_mock.assert_not_called()
|
||||||
|
Loading…
Reference in New Issue
Block a user