From 429703a9a8781c38c709551a3cfed35ca3d2c574 Mon Sep 17 00:00:00 2001 From: Victor Morales Date: Fri, 9 Dec 2016 16:03:38 -0600 Subject: [PATCH] Expose neutron api application as a wsgi script This can then be loaded into a wsgi compatible web server like apache2/httpd or nginx. DocImpact A new neutron-api script is installed, and can be used to start either a standalone wsgi server (calling the script directly), or as a wsgi script loaded by a web server (e.g. by httpd/mod_wsgi). Change-Id: Ie9bb8b33f6e1335219e574d832ac264b043d90e6 Partial-Bug: #1666779 Co-Authored-By: Brandon Logan Co-Authored-By: Ihar Hrachyshka --- neutron/server/__init__.py | 13 ++++++++++++- .../add-wsgi-script-support-e611fa5b5c2043a5.yaml | 7 +++++++ setup.cfg | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/add-wsgi-script-support-e611fa5b5c2043a5.yaml diff --git a/neutron/server/__init__.py b/neutron/server/__init__.py index 312a65c4d3d..ac4bc91d767 100644 --- a/neutron/server/__init__.py +++ b/neutron/server/__init__.py @@ -22,9 +22,10 @@ from oslo_config import cfg from neutron._i18n import _ from neutron.common import config +from neutron.common import profiler -def boot_server(server_func): +def _init_configuration(): # the configuration will be read into the cfg.CONF global data structure config.init(sys.argv[1:]) config.setup_logging() @@ -33,9 +34,19 @@ def boot_server(server_func): sys.exit(_("ERROR: Unable to find configuration file via the default" " search paths (~/.neutron/, ~/, /etc/neutron/, /etc/) and" " the '--config-file' option!")) + + +def boot_server(server_func): + _init_configuration() try: server_func() except KeyboardInterrupt: pass except RuntimeError as e: sys.exit(_("ERROR: %s") % e) + + +def get_application(): + _init_configuration() + profiler.setup('neutron-server', cfg.CONF.host) + return config.load_paste_app('neutron') diff --git a/releasenotes/notes/add-wsgi-script-support-e611fa5b5c2043a5.yaml b/releasenotes/notes/add-wsgi-script-support-e611fa5b5c2043a5.yaml new file mode 100644 index 00000000000..27802cac399 --- /dev/null +++ b/releasenotes/notes/add-wsgi-script-support-e611fa5b5c2043a5.yaml @@ -0,0 +1,7 @@ +--- +prelude: > + This release adds support for running Neutron API component with a ``mod_wsgi`` + compatible web server. +features: + - Neutron API can now be managed by a ``mod_wsgi`` compatible web server (e.g. + ``apache2`` (``httpd``), ``nginx``, etc.) diff --git a/setup.cfg b/setup.cfg index f423344a2eb..2a71119e2c5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -41,6 +41,8 @@ scripts = bin/neutron-rootwrap-xen-dom0 [entry_points] +wsgi_scripts = + neutron-api = neutron.server:get_application console_scripts = neutron-db-manage = neutron.db.migration.cli:main neutron-debug = neutron.debug.shell:main