Add uWSGI support

This patch implements uWSGI support for ironic API service.
ironic/api/app.wsgi is deprecated in favor of pbr generated
ironic-api-wsgi

Co-Authored-By: anascko <ovoshchana@mirantis.com>

Change-Id: Ieb68c1042e31b77f9a549fd90afe31a65008deca
Closes-Bug: #1719260
Closes-Bug: #1668966
This commit is contained in:
Vasyl Saienko 2017-09-25 10:44:09 +03:00 committed by Pavlo Shchelokovskyy
parent bf8cb05aa4
commit 61b81d0c73
6 changed files with 64 additions and 26 deletions

View File

@ -43,8 +43,9 @@ Bare Metal service comes with an example file for configuring the
``APACHE_RUN_GROUP`` directives to set the user and group values to ``APACHE_RUN_GROUP`` directives to set the user and group values to
an appropriate user on your server. an appropriate user on your server.
#. Modify the ``WSGIScriptAlias`` directive to point to the #. Modify the ``WSGIScriptAlias`` directive to point to the automatically
``ironic/api/app.wsgi`` script. generated ``ironic-api-wsgi`` script that is located in `IRONIC_BIN`
directory.
#. Modify the ``Directory`` directive to set the path to the Ironic API code. #. Modify the ``Directory`` directive to set the path to the Ironic API code.
@ -68,5 +69,5 @@ Bare Metal service comes with an example file for configuring the
sudo systemctl reload apache2 sudo systemctl reload apache2
.. note:: .. note::
The file ``ironic/api/app.wsgi`` is installed with the rest of the Bare Metal The file ``ironic-api-wsgi`` is automatically generated by pbr and is
service application code, and should not need to be modified. available in `IRONIC_BIN` directory. It should not be modified.

View File

@ -12,13 +12,14 @@
# This is an example Apache2 configuration file for using the # This is an example Apache2 configuration file for using the
# Ironic API through mod_wsgi. This version assumes you are # Ironic API through mod_wsgi. This version assumes you are
# running devstack to configure the software. # running devstack to configure the software, and PBR has generated
# and installed the ironic-api-wsgi script while installing ironic.
Listen 6385 Listen 6385
<VirtualHost *:6385> <VirtualHost *:6385>
WSGIDaemonProcess ironic user=stack group=stack threads=10 display-name=%{GROUP} WSGIDaemonProcess ironic user=stack group=stack threads=10 display-name=%{GROUP}
WSGIScriptAlias / /opt/stack/ironic/ironic/api/app.wsgi WSGIScriptAlias / /usr/local/bin/ironic-api-wsgi
SetEnv APACHE_RUN_USER stack SetEnv APACHE_RUN_USER stack
SetEnv APACHE_RUN_GROUP stack SetEnv APACHE_RUN_GROUP stack

View File

@ -16,24 +16,6 @@
Use this file for deploying the API service under Apache2 mod_wsgi. Use this file for deploying the API service under Apache2 mod_wsgi.
""" """
import sys from ironic.api import wsgi
from oslo_config import cfg application = wsgi.initialize_wsgi_app(show_deprecated=True)
import oslo_i18n as i18n
from oslo_log import log
from ironic.api import app
from ironic.common import service
CONF = cfg.CONF
i18n.install('ironic')
service.prepare_service(sys.argv)
LOG = log.getLogger(__name__)
LOG.debug("Configuration:")
CONF.log_opt_values(LOG, log.DEBUG)
application = app.VersionSelectorApplication()

41
ironic/api/wsgi.py Normal file
View File

@ -0,0 +1,41 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""WSGI script for Ironic API, installed by pbr."""
import sys
from oslo_config import cfg
import oslo_i18n as i18n
from oslo_log import log
from ironic.api import app
from ironic.common import service
CONF = cfg.CONF
LOG = log.getLogger(__name__)
def initialize_wsgi_app(show_deprecated=False):
i18n.install('ironic')
service.prepare_service(sys.argv)
LOG.debug("Configuration:")
CONF.log_opt_values(LOG, log.DEBUG)
if show_deprecated:
LOG.warning("Using ironic/api/app.wsgi is deprecated and it will "
"be removed in Rocky release. Please use automatically "
"generated ironic-api-wsgi instead.")
return app.VersionSelectorApplication()

View File

@ -0,0 +1,10 @@
---
upgrade:
- An Ironic API WSGI application script ``ironic-api-wsgi`` is now available.
It is auto-generated by ``pbr`` and allows to run the API service
using WSGI server (for example Nginx and uWSGI or Apache with mod_wsgi).
deprecations:
- Using ``ironic/api/app.wsgi`` script is deprecated and it will be removed
in Rocky release.
Please switch to automatically generated ``ironic-api-wsgi`` script
instead.

View File

@ -44,6 +44,9 @@ console_scripts =
ironic-conductor = ironic.cmd.conductor:main ironic-conductor = ironic.cmd.conductor:main
ironic-rootwrap = oslo_rootwrap.cmd:main ironic-rootwrap = oslo_rootwrap.cmd:main
wsgi_scripts =
ironic-api-wsgi = ironic.api.wsgi:initialize_wsgi_app
ironic.dhcp = ironic.dhcp =
neutron = ironic.dhcp.neutron:NeutronDHCPApi neutron = ironic.dhcp.neutron:NeutronDHCPApi
none = ironic.dhcp.none:NoneDHCPApi none = ironic.dhcp.none:NoneDHCPApi