diff options
Diffstat (limited to 'devstack')
-rw-r--r-- | devstack/files/apache-trove-api.template | 45 | ||||
-rw-r--r-- | devstack/plugin.sh | 61 | ||||
-rw-r--r-- | devstack/settings | 9 |
3 files changed, 113 insertions, 2 deletions
diff --git a/devstack/files/apache-trove-api.template b/devstack/files/apache-trove-api.template new file mode 100644 index 00000000..06c88b26 --- /dev/null +++ b/devstack/files/apache-trove-api.template @@ -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> diff --git a/devstack/plugin.sh b/devstack/plugin.sh index b423ff27..e64e8b0d 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -64,6 +64,14 @@ function create_trove_accounts { 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 # --------------------- @@ -77,6 +85,11 @@ function cleanup_trove { if is_service_enabled horizon; then cleanup_trove_dashboard 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}." } +# _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 function configure_trove { setup_develop $TROVE_DIR @@ -185,6 +219,12 @@ function configure_trove { iniset $TROVE_CONF DEFAULT trove_auth_url $TROVE_AUTH_ENDPOINT 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 if is_service_enabled tr-tmgr; then # Use these values only if they're set @@ -265,6 +305,11 @@ function configure_trove { function install_trove { 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 install_trove_dashboard fi @@ -491,7 +536,13 @@ function finalize_trove_network { # start_trove() - Start running processes, including screen 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-cond "$TROVE_BIN_DIR/trove-conductor --config-file=$TROVE_CONDUCTOR_CONF --debug" } @@ -500,7 +551,13 @@ function start_trove { function stop_trove { # Kill the trove screen windows 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 done } diff --git a/devstack/settings b/devstack/settings index be3074f4..2dff5fb3 100644 --- a/devstack/settings +++ b/devstack/settings @@ -61,4 +61,13 @@ TROVE_MANAGE=$TROVE_BIN_DIR/trove-manage # Tell Tempest this project is present 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 |