Browse Source
1. What is the problem Currently Tricircle Admin API is running through python command line and will start oslo_service wsgi server directly. The community has set a community wide goal in Pike cycle: "Control Plane API endpoints deployment via WSGI" https://governance.openstack.org/tc/goals/pike/deploy-api-in-wsgi.html Completion Criteria a). Provide WSGI application script file(s) (e.g. to be used by web server). There shouldn't be any web server restriction and the application could be deploying to any web server that support WSGI applications. b). Switch devstack jobs to deploy control-plane API services in WSGI with Apache. Usage of Apache is already the default in Devstack, let's keep using it for consistency unless there is some efforts to support another web server but this is not the case at this time. 2. What is the solution for the problem The first step is to finish these two goals: a). Provide WSGI application script file b). Update devstack related script in Tricircle to use Apache as the web server. The second step will clean and update other documentation accordingly 3. What the features need to be implemented to the Tricircle to realize the solution No new feature delivered to end user. Change-Id: I828f2d846725d18bb4a66a5d357c717e6b7d28bb Signed-off-by: joehuang <joehuang@huawei.com>changes/75/440175/6
12 changed files with 209 additions and 23 deletions
@ -0,0 +1,39 @@
|
||||
# apache configuration template for tricircle-api |
||||
|
||||
Listen %PUBLICPORT% |
||||
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %D(us)" tricircle_combined |
||||
|
||||
<Directory %TRICIRCLE_BIN%> |
||||
Require all granted |
||||
</Directory> |
||||
<VirtualHost *:%PUBLICPORT%> |
||||
WSGIDaemonProcess tricircle-api processes=%APIWORKERS% threads=1 user=%USER% display-name=%{GROUP} %VIRTUALENV% |
||||
WSGIProcessGroup tricircle-api |
||||
WSGIScriptAlias / %PUBLICWSGI% |
||||
WSGIApplicationGroup %{GLOBAL} |
||||
WSGIPassAuthorization On |
||||
<IfVersion >= 2.4> |
||||
ErrorLogFormat "%M" |
||||
</IfVersion> |
||||
ErrorLog /var/log/%APACHE_NAME%/tricircle-api.log |
||||
CustomLog /var/log/%APACHE_NAME%/tricircle_access.log tricircle_combined |
||||
%SSLENGINE% |
||||
%SSLCERTFILE% |
||||
%SSLKEYFILE% |
||||
</VirtualHost> |
||||
|
||||
%SSLLISTEN%<VirtualHost *:443> |
||||
%SSLLISTEN% %SSLENGINE% |
||||
%SSLLISTEN% %SSLCERTFILE% |
||||
%SSLLISTEN% %SSLKEYFILE% |
||||
%SSLLISTEN%</VirtualHost> |
||||
|
||||
Alias /tricircle %PUBLICWSGI% |
||||
<Location /tricircle> |
||||
SetHandler wsgi-script |
||||
Options +ExecCGI |
||||
|
||||
WSGIProcessGroup tricircle-api |
||||
WSGIApplicationGroup %{GLOBAL} |
||||
WSGIPassAuthorization On |
||||
</Location> |
@ -0,0 +1,6 @@
|
||||
--- |
||||
prelude: > |
||||
Tricircle Admin API now supports WSGI deployment. The endpoint of |
||||
Tricircle Admin API could be accessed via the format of |
||||
http://host/tricircle, and no need to expose special port, thus |
||||
reduce the risk of port management. |
@ -0,0 +1,57 @@
|
||||
# Copyright (c) 2017 Huawei Tech. Co,. Ltd. |
||||
# All Rights Reserved. |
||||
# |
||||
# 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 Tricircle API |
||||
WSGI handler for running Tricircle API under Apache2, nginx, gunicorn etc. |
||||
|
||||
Community wide goal in Pike: |
||||
https://governance.openstack.org/tc/goals/pike/deploy-api-in-wsgi.html |
||||
""" |
||||
|
||||
import os |
||||
import os.path |
||||
|
||||
from oslo_config import cfg |
||||
from oslo_log import log as logging |
||||
|
||||
from tricircle.api import app |
||||
from tricircle.common import config |
||||
from tricircle.common.i18n import _LI |
||||
|
||||
CONFIG_FILE = 'api.conf' |
||||
|
||||
CONF = cfg.CONF |
||||
LOG = logging.getLogger(__name__) |
||||
|
||||
|
||||
def _get_config_file(env=None): |
||||
if env is None: |
||||
env = os.environ |
||||
|
||||
dir_name = env.get('TRICIRCLE_CONF_DIR', '/etc/tricircle').strip() |
||||
return os.path.join(dir_name, CONFIG_FILE) |
||||
|
||||
|
||||
def init_application(): |
||||
|
||||
# initialize the config system |
||||
conf_file = _get_config_file() |
||||
config.init(app.common_opts, ['--config-file', conf_file]) |
||||
|
||||
LOG.info(_LI("Configuration:")) |
||||
CONF.log_opt_values(LOG, logging.INFO) |
||||
|
||||
# return WSGI app |
||||
return app.setup_app() |
Loading…
Reference in new issue