Add support to have Senlin API run under Apache

Add scripts for running Senlin API service under apache2, will add
related devstack support in another patch.

Implements bp: run-senlin-api-under-apache

Change-Id: I18872546a653c5de26360b6289dd1f5886c4a2b7
This commit is contained in:
lvdongbing
2016-11-09 05:00:24 -05:00
parent 17bb9c92c9
commit 354784bcb8
3 changed files with 51 additions and 1 deletions

View File

@@ -673,7 +673,13 @@ class Resource(object):
# Attach openstack-api-version header
if hasattr(response, 'headers'):
for hdr, val in response.headers.items():
response.headers[hdr] = six.text_type(val)
# Note(lvdongbing): Ensure header is a python 2 or 3
# native string (thus not unicode in python 2 but stay
# a string in python 3). Because mod-wsgi checks that
# response header values are what's described as
# "native strings". This means whatever `str` is in
# either python 2 or 3, but never `unicode`.
response.headers[hdr] = str(val)
ver = request.version_request
if not ver.is_null():
ver_res = ' '.join(['clustering', str(ver)])

41
senlin/cmd/api_wsgi.py Normal file
View File

@@ -0,0 +1,41 @@
#!/usr/bin/env python
#
# 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 senlin-api.
Use this file for deploying senlin-api under Apache2(mode-wsgi).
"""
from oslo_config import cfg
import oslo_i18n as i18n
from oslo_log import log as logging
from senlin.api.common import wsgi
from senlin.common import messaging
from senlin.common import profiler
from senlin import version
def init_app():
i18n.enable_lazy()
logging.register_options(cfg.CONF)
cfg.CONF(project='senlin', prog='senlin-api',
version=version.version_info.version_string())
logging.setup(cfg.CONF, 'senlin-api')
messaging.setup()
profiler.setup('senlin-api', cfg.CONF.host)
return wsgi.load_paste_app()

View File

@@ -29,6 +29,9 @@ console_scripts =
senlin-engine = senlin.cmd.engine:main
senlin-manage = senlin.cmd.manage:main
wsgi_scripts =
senlin-wsgi-api = senlin.cmd.api_wsgi:init_app
oslo.config.opts =
senlin.config = senlin.common.config:list_opts