enable trove-api behind mod-wsgi
This change enables behind mod-wsgi as part of the community pike goal goal-deploy-api-in-wsgi. The change includes: - the wsgi script files to run trove api under apache - updates to the devstack plugin - a basic deploy doc which explains this change Change-Id: Icdd39b47a1be426e87a5d09f9e9d567af1974a9c Depends-On: I3d6f6649430ee40879de15fee0b215dc32e8b666 Closes-Bug: #1681478
This commit is contained in:
parent
191e3036e1
commit
20d51467c7
45
devstack/files/apache-trove-api.template
Normal file
45
devstack/files/apache-trove-api.template
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
# Copyright 2017 Amrith Kumar.
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
# This is an example Apache2 configuration file for using the
|
||||||
|
# Watcher API through mod_wsgi. This version assumes you are
|
||||||
|
# running devstack to configure the software.
|
||||||
|
|
||||||
|
Listen %TROVE_SERVICE_PORT%
|
||||||
|
|
||||||
|
<VirtualHost *:%TROVE_SERVICE_PORT%>
|
||||||
|
WSGIDaemonProcess trove-api user=%USER% processes=%APIWORKERS% threads=1 display-name=%{GROUP}
|
||||||
|
WSGIScriptAlias / %TROVE_WSGI_DIR%/app.wsgi
|
||||||
|
WSGIApplicationGroup %{GLOBAL}
|
||||||
|
WSGIProcessGroup trove-api
|
||||||
|
WSGIPassAuthorization On
|
||||||
|
|
||||||
|
ErrorLogFormat "%M"
|
||||||
|
ErrorLog /var/log/%APACHE_NAME%/trove-api.log
|
||||||
|
CustomLog /var/log/%APACHE_NAME%/trove-api-access.log combined
|
||||||
|
|
||||||
|
|
||||||
|
<Directory %TROVE_WSGI_DIR%>
|
||||||
|
WSGIProcessGroup trove-api
|
||||||
|
WSGIApplicationGroup %{GLOBAL}
|
||||||
|
<IfVersion >= 2.4>
|
||||||
|
Require all granted
|
||||||
|
</IfVersion>
|
||||||
|
<IfVersion < 2.4>
|
||||||
|
Order allow,deny
|
||||||
|
Allow from all
|
||||||
|
</IfVersion>
|
||||||
|
</Directory>
|
||||||
|
</VirtualHost>
|
@ -64,6 +64,14 @@ function create_trove_accounts {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# _cleanup_trove_apache_wsgi - Removes all the WSGI related files and
|
||||||
|
# restart apache.
|
||||||
|
function _cleanup_trove_apache_wsgi {
|
||||||
|
sudo rm -rf $TROVE_WSGI_DIR
|
||||||
|
sudo rm -f ${apache_site_config_for trove-api}
|
||||||
|
restart_apache_server
|
||||||
|
}
|
||||||
|
|
||||||
# stack.sh entry points
|
# stack.sh entry points
|
||||||
# ---------------------
|
# ---------------------
|
||||||
|
|
||||||
@ -77,6 +85,11 @@ function cleanup_trove {
|
|||||||
if is_service_enabled horizon; then
|
if is_service_enabled horizon; then
|
||||||
cleanup_trove_dashboard
|
cleanup_trove_dashboard
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "${TROVE_USE_MOD_WSGI}" == "TRUE" ]]; then
|
||||||
|
echo "Cleaning up Trove's WSGI setup"
|
||||||
|
_cleanup_trove_apache_wsgi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -139,6 +152,27 @@ function configure_nova_kvm {
|
|||||||
echo "configure_nova_kvm: using virt_type: ${virt_type} for cpu: ${cpu}."
|
echo "configure_nova_kvm: using virt_type: ${virt_type} for cpu: ${cpu}."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# _config_trove_apache_wsgi() - Setup WSGI config files for Trove and
|
||||||
|
# enable the site
|
||||||
|
function _config_trove_apache_wsgi {
|
||||||
|
local trove_apache_conf
|
||||||
|
|
||||||
|
sudo mkdir -p ${TROVE_WSGI_DIR}
|
||||||
|
sudo cp $TROVE_DIR/trove/cmd/app.wsgi $TROVE_WSGI_DIR/app.wsgi
|
||||||
|
trove_apache_conf=$(apache_site_config_for trove-api)
|
||||||
|
sudo cp $TROVE_DEVSTACK_FILES/apache-trove-api.template ${trove_apache_conf}
|
||||||
|
sudo sed -e "
|
||||||
|
s|%TROVE_SERVICE_PORT%|${TROVE_SERVICE_PORT}|g;
|
||||||
|
s|%TROVE_WSGI_DIR%|${TROVE_WSGI_DIR}|g;
|
||||||
|
s|%USER%|${STACK_USER}|g;
|
||||||
|
s|%APACHE_NAME%|${APACHE_NAME}|g;
|
||||||
|
s|%APIWORKERS%|${API_WORKERS}|g;
|
||||||
|
" -i ${trove_apache_conf}
|
||||||
|
enable_apache_site trove-api
|
||||||
|
tail_log trove-access /var/log/${APACHE_NAME}/trove-api-access.log
|
||||||
|
tail_log trove-api /var/log/${APACHE_NAME}/trove-api.log
|
||||||
|
}
|
||||||
|
|
||||||
# configure_trove() - Set config files, create data dirs, etc
|
# configure_trove() - Set config files, create data dirs, etc
|
||||||
function configure_trove {
|
function configure_trove {
|
||||||
setup_develop $TROVE_DIR
|
setup_develop $TROVE_DIR
|
||||||
@ -185,6 +219,12 @@ function configure_trove {
|
|||||||
iniset $TROVE_CONF DEFAULT trove_auth_url $TROVE_AUTH_ENDPOINT
|
iniset $TROVE_CONF DEFAULT trove_auth_url $TROVE_AUTH_ENDPOINT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# configure apache related files
|
||||||
|
if [[ "${TROVE_USE_MOD_WSGI}" == "TRUE" ]]; then
|
||||||
|
echo "Configuring Trove to use mod-wsgi and Apache"
|
||||||
|
_config_trove_apache_wsgi
|
||||||
|
fi
|
||||||
|
|
||||||
# (Re)create trove taskmanager conf file if needed
|
# (Re)create trove taskmanager conf file if needed
|
||||||
if is_service_enabled tr-tmgr; then
|
if is_service_enabled tr-tmgr; then
|
||||||
# Use these values only if they're set
|
# Use these values only if they're set
|
||||||
@ -265,6 +305,11 @@ function configure_trove {
|
|||||||
function install_trove {
|
function install_trove {
|
||||||
setup_develop $TROVE_DIR
|
setup_develop $TROVE_DIR
|
||||||
|
|
||||||
|
if [[ "${TROVE_USE_MOD_WSGI}" == "TRUE" ]]; then
|
||||||
|
echo "Installing apache wsgi"
|
||||||
|
install_apache_wsgi
|
||||||
|
fi
|
||||||
|
|
||||||
if is_service_enabled horizon; then
|
if is_service_enabled horizon; then
|
||||||
install_trove_dashboard
|
install_trove_dashboard
|
||||||
fi
|
fi
|
||||||
@ -491,7 +536,13 @@ function finalize_trove_network {
|
|||||||
|
|
||||||
# start_trove() - Start running processes, including screen
|
# start_trove() - Start running processes, including screen
|
||||||
function start_trove {
|
function start_trove {
|
||||||
run_process tr-api "$TROVE_BIN_DIR/trove-api --config-file=$TROVE_CONF --debug"
|
if [[ ${TROVE_USE_MOD_WSGI}" == TRUE" ]]; then
|
||||||
|
echo "Restarting Apache server ..."
|
||||||
|
enable_apache_site trove-api
|
||||||
|
restart_apache_server
|
||||||
|
else
|
||||||
|
run_process tr-api "$TROVE_BIN_DIR/trove-api --config-file=$TROVE_CONF --debug"
|
||||||
|
fi
|
||||||
run_process tr-tmgr "$TROVE_BIN_DIR/trove-taskmanager --config-file=$TROVE_TASKMANAGER_CONF --debug"
|
run_process tr-tmgr "$TROVE_BIN_DIR/trove-taskmanager --config-file=$TROVE_TASKMANAGER_CONF --debug"
|
||||||
run_process tr-cond "$TROVE_BIN_DIR/trove-conductor --config-file=$TROVE_CONDUCTOR_CONF --debug"
|
run_process tr-cond "$TROVE_BIN_DIR/trove-conductor --config-file=$TROVE_CONDUCTOR_CONF --debug"
|
||||||
}
|
}
|
||||||
@ -500,7 +551,13 @@ function start_trove {
|
|||||||
function stop_trove {
|
function stop_trove {
|
||||||
# Kill the trove screen windows
|
# Kill the trove screen windows
|
||||||
local serv
|
local serv
|
||||||
for serv in tr-api tr-tmgr tr-cond; do
|
if [[ ${TROVE_USE_MOD_WSGI} == "TRUE" ]]; then
|
||||||
|
echo "Disabling Trove API in Apache"
|
||||||
|
disable_apache_site trove-api
|
||||||
|
else
|
||||||
|
stop_process tr-api
|
||||||
|
fi
|
||||||
|
for serv in tr-tmgr tr-cond; do
|
||||||
stop_process $serv
|
stop_process $serv
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -61,4 +61,13 @@ TROVE_MANAGE=$TROVE_BIN_DIR/trove-manage
|
|||||||
# Tell Tempest this project is present
|
# Tell Tempest this project is present
|
||||||
TEMPEST_SERVICES+=,trove
|
TEMPEST_SERVICES+=,trove
|
||||||
|
|
||||||
|
# By default enable Trove API behind mod-wsgi. Change this to FALSE
|
||||||
|
# if you don't want Apache/mod-wsgi
|
||||||
|
TROVE_USE_MOD_WSGI=$(trueorfalse TRUE TROVE_USE_MOD_WSGI)
|
||||||
|
|
||||||
|
TROVE_SERVICE_PORT=${TROVE_SERVICE_PORT:-8779}
|
||||||
|
TROVE_DEVSTACK_DIR=${TROVE_DIR}/devstack
|
||||||
|
TROVE_DEVSTACK_FILES=${TROVE_DEVSTACK_DIR}/files
|
||||||
|
TROVE_WSGI_DIR=${TROVE_WSGI_DIR:-/var/www/trove}
|
||||||
|
|
||||||
enable_service trove tr-api tr-tmgr tr-cond
|
enable_service trove tr-api tr-tmgr tr-cond
|
||||||
|
49
doc/source/deploy/apache-mod-wsgi.rst
Normal file
49
doc/source/deploy/apache-mod-wsgi.rst
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
..
|
||||||
|
Except where otherwise noted, this document is licensed under Creative
|
||||||
|
Commons Attribution 3.0 License. You can view the license at:
|
||||||
|
|
||||||
|
https://creativecommons.org/licenses/by/3.0/
|
||||||
|
|
||||||
|
|
||||||
|
Installing API behind mod_wsgi
|
||||||
|
==============================
|
||||||
|
|
||||||
|
#. Install the Apache Service::
|
||||||
|
|
||||||
|
Fedora 21/RHEL7/CentOS7:
|
||||||
|
sudo yum install httpd
|
||||||
|
|
||||||
|
Fedora 22 (or higher):
|
||||||
|
sudo dnf install httpd
|
||||||
|
|
||||||
|
Debian/Ubuntu:
|
||||||
|
apt-get install apache2
|
||||||
|
|
||||||
|
#. Copy ``etc/apache2/trove`` under the apache sites::
|
||||||
|
|
||||||
|
Fedora/RHEL7/CentOS7:
|
||||||
|
sudo cp etc/apache2/trove /etc/httpd/conf.d/trove-api.conf
|
||||||
|
|
||||||
|
Debian/Ubuntu:
|
||||||
|
sudo cp etc/apache2/trove /etc/apache2/sites-available/trove-api.conf
|
||||||
|
|
||||||
|
#. Edit ``<apache-configuration-dir>/trove-api.conf`` according to installation
|
||||||
|
and environment.
|
||||||
|
|
||||||
|
* Modify the ``WSGIDaemonProcess`` directive to set the ``user`` and
|
||||||
|
``group`` values to appropriate user on your server.
|
||||||
|
* Modify the ``WSGIScriptAlias`` directive to point to the
|
||||||
|
trove/api/app.wsgi script.
|
||||||
|
* Modify the ``Directory`` directive to set the path to the Trove API
|
||||||
|
code.
|
||||||
|
* Modify the ``ErrorLog and CustomLog`` to redirect the logs to the right
|
||||||
|
directory.
|
||||||
|
|
||||||
|
#. Enable the apache trove site and reload::
|
||||||
|
|
||||||
|
Fedora/RHEL7/CentOS7:
|
||||||
|
sudo systemctl reload httpd
|
||||||
|
|
||||||
|
Debian/Ubuntu:
|
||||||
|
sudo a2ensite trove
|
||||||
|
sudo service apache2 reload
|
@ -52,6 +52,7 @@ functionality, the following resources are provided.
|
|||||||
dev/notifier.rst
|
dev/notifier.rst
|
||||||
dev/trove_api_extensions.rst
|
dev/trove_api_extensions.rst
|
||||||
dev/secure_oslo_messaging.rst
|
dev/secure_oslo_messaging.rst
|
||||||
|
deploy/apache-mod-wsgi
|
||||||
|
|
||||||
* Source Code Repositories
|
* Source Code Repositories
|
||||||
|
|
||||||
|
36
etc/apache2/trove
Normal file
36
etc/apache2/trove
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# Copyright 2017 Amrith Kumar.
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
# This is an example Apache2 configuration file for using Trove API
|
||||||
|
through mod_wsgi
|
||||||
|
|
||||||
|
Listen 8779
|
||||||
|
|
||||||
|
<VirtualHost *:8779>
|
||||||
|
WSGIDaemonProcess trove-api user=stack group=stack processes=2 threads=2 display-name=%{GROUP}
|
||||||
|
WSGIScriptAlias / /opt/stack/trove/trove/cmd/app.wsgi
|
||||||
|
WSGIProcessGroup trove-api
|
||||||
|
|
||||||
|
ErrorLog /var/log/httpd/trove_error.log
|
||||||
|
LogLevel info
|
||||||
|
CustomLog /var/log/httpd/trove_access.log combined
|
||||||
|
|
||||||
|
<Directory /opt/stack/trove/trove/cmd>
|
||||||
|
WSGIProcessGroup trove-api
|
||||||
|
WSGIApplicationGroup %{GLOBAL}
|
||||||
|
AllowOverride All
|
||||||
|
Require all granted
|
||||||
|
</Directory>
|
||||||
|
</VirtualHost>
|
||||||
|
|
@ -74,6 +74,7 @@ export RELEASE=${RELEASE:-$DISTRO_RELEASE}
|
|||||||
# allow overrides from devstack if already set
|
# allow overrides from devstack if already set
|
||||||
[[ -f $PATH_DEVSTACK_SRC/functions-common ]] && source $PATH_DEVSTACK_SRC/functions-common
|
[[ -f $PATH_DEVSTACK_SRC/functions-common ]] && source $PATH_DEVSTACK_SRC/functions-common
|
||||||
[[ -f $PATH_DEVSTACK_SRC/functions ]] && source $PATH_DEVSTACK_SRC/functions
|
[[ -f $PATH_DEVSTACK_SRC/functions ]] && source $PATH_DEVSTACK_SRC/functions
|
||||||
|
[[ -f $PATH_DEVSTACK_SRC/lib/apache ]] && source $PATH_DEVSTACK_SRC/lib/apache
|
||||||
|
|
||||||
# Set up variables for the CONF files - this has to happen after loading trovestack.rc, since
|
# Set up variables for the CONF files - this has to happen after loading trovestack.rc, since
|
||||||
# TROVE_CONF_DIR is defined there - these will be used by devstack too
|
# TROVE_CONF_DIR is defined there - these will be used by devstack too
|
||||||
|
40
trove/cmd/app.wsgi
Normal file
40
trove/cmd/app.wsgi
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# Copyright 2017 Amrith Kumar.
|
||||||
|
# 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.
|
||||||
|
"""
|
||||||
|
Used for deploying Trove API through mod-wsgi
|
||||||
|
"""
|
||||||
|
|
||||||
|
from oslo_log import log as logging
|
||||||
|
from trove.cmd.common import with_initialize
|
||||||
|
from trove.common import pastedeploy
|
||||||
|
from trove.common import profile
|
||||||
|
|
||||||
|
LOG = logging.getLogger('trove.cmd.app')
|
||||||
|
|
||||||
|
@with_initialize
|
||||||
|
def wsgimain(CONF):
|
||||||
|
from trove.common import cfg
|
||||||
|
from trove.common import notification
|
||||||
|
from trove.instance import models as inst_models
|
||||||
|
|
||||||
|
notification.DBaaSAPINotification.register_notify_callback(
|
||||||
|
inst_models.persist_instance_fault)
|
||||||
|
cfg.set_api_config_defaults()
|
||||||
|
profile.setup_profiler('api', CONF.host)
|
||||||
|
conf_file = CONF.find_file(CONF.api_paste_config)
|
||||||
|
LOG.debug("Trove started on %s", CONF.host)
|
||||||
|
return pastedeploy.paste_deploy_app(conf_file, 'trove', {})
|
||||||
|
|
||||||
|
application = wsgimain()
|
Loading…
Reference in New Issue
Block a user