Use uwsgi for devstack

Two patches added wsgi support:
https://review.openstack.org/455734/
https://review.openstack.org/453705/
According to:
https://governance.openstack.org/tc/goals/pike/deploy-api-in-wsgi.html
However, this patch:
https://review.openstack.org/460951/
changed the goal to use uwsgi by default.

Change-Id: Id02deddc52d81b9cd240364a22422a31fc02c9c3
This commit is contained in:
Yuval Brik 2017-05-25 12:00:43 +03:00
parent 1b0f9e6932
commit d5718bd47f
2 changed files with 62 additions and 30 deletions

View File

@ -27,10 +27,11 @@ function create_karbor_accounts {
create_service_user "$KARBOR_SERVICE_NAME" "admin"
get_or_create_service "$KARBOR_SERVICE_NAME" "$KARBOR_SERVICE_TYPE" "Application Data Protection Service"
get_or_create_endpoint "$KARBOR_SERVICE_TYPE" "$REGION_NAME" \
"$KARBOR_API_PROTOCOL://$KARBOR_API_HOST:$KARBOR_API_PORT/v1/\$(project_id)s" \
"$KARBOR_API_PROTOCOL://$KARBOR_API_HOST:$KARBOR_API_PORT/v1/\$(project_id)s" \
"$KARBOR_API_PROTOCOL://$KARBOR_API_HOST:$KARBOR_API_PORT/v1/\$(project_id)s"
"$KARBOR_API_ENDPOINT" \
"$KARBOR_API_ENDPOINT" \
"$KARBOR_API_ENDPOINT"
fi
}
@ -64,29 +65,51 @@ function karbor_config_apache_wsgi {
" -i $karbor_apache_conf
}
# clean_karbor_api_wsgi() - Remove wsgi files, disable and remove apache vhost file
function clean_karbor_api_wsgi {
function karbor_config_uwsgi {
write_uwsgi_config "$KARBOR_API_UWSGI_CONF" "$KARBOR_API_UWSGI" "/$KARBOR_SERVICE_TYPE"
}
# clean_karbor_api_mod_wsgi() - Remove wsgi files, disable and remove apache vhost file
function clean_karbor_api_mod_wsgi {
sudo rm -f $(apache_site_config_for osapi_karbor)
}
# start_karbor_api_wsgi() - Start the API processes ahead of other things
function start_karbor_api_wsgi {
function clean_karbor_api_uwsgi {
remove_uwsgi_config "$KARBOR_API_UWSGI_CONF" "$KARBOR_API_UWSGI"
}
# start_karbor_api_mod_wsgi() - Start the API processes ahead of other things
function start_karbor_api_mod_wsgi {
enable_apache_site osapi_karbor
restart_apache_server
tail_log karbor-api /var/log/$APACHE_NAME/karbor-api.log
echo "Waiting for Karbor API to start..."
if ! wait_for_service $SERVICE_TIMEOUT $KARBOR_API_PROTOCOL://$KARBOR_API_HOST:$KARBOR_API_PORT; then
die $LINENO "karbor-api wsgi did not start"
if ! wait_for_service $SERVICE_TIMEOUT $KARBOR_API_ENDPOINT; then
die $LINENO "karbor-api mod_wsgi did not start"
fi
}
# stop_karbor_api_wsgi() - Disable the api service and stop it.
function stop_karbor_api_wsgi {
function start_karbor_api_uwsgi {
run_process karbor-api "$KARBOR_BIN_DIR/uwsgi --ini $KARBOR_API_UWSGI_CONF" ""
echo "Waiting for Karbor API to start..."
if ! wait_for_service $SERVICE_TIMEOUT $KARBOR_API_ENDPOINT; then
die $LINENO "karbor-api uwsgi did not start"
fi
}
# stop_karbor_api_mod_wsgi() - Disable the api service and stop it.
function stop_karbor_api_mod_wsgi {
disable_apache_site osapi_karbor
restart_apache_server
}
function stop_karbor_api_uwsgi {
remove_uwsgi_config "$KARBOR_API_UWSGI_CONF" "$KARBOR_API_UWSGI"
stop_process karbor-api
}
function configure_karbor_api {
if is_service_enabled karbor-api ; then
echo "Configuring Karbor API"
@ -177,8 +200,10 @@ if [[ "$Q_ENABLE_KARBOR" == "True" ]]; then
configure_karbor_api
configure_providers
if [ "$KARBOR_USE_MOD_WSGI" == "True" ]; then
if [[ "$KARBOR_DEPLOY" == "mod_wsgi" ]]; then
karbor_config_apache_wsgi
elif [[ "$KARBOR_DEPLOY" == "uwsgi" ]]; then
karbor_config_uwsgi
fi
echo export PYTHONPATH=\$PYTHONPATH:$KARBOR_DIR >> $RC_DIR/.localrc.auto
@ -198,10 +223,10 @@ if [[ "$Q_ENABLE_KARBOR" == "True" ]]; then
$KARBOR_BIN_DIR/karbor-manage db sync
fi
if is_service_enabled karbor-api; then
if [[ "$KARBOR_USE_MOD_WSGI" == "True" ]]; then
start_karbor_api_wsgi
else
run_process karbor-api "$KARBOR_BIN_DIR/karbor-api --config-file $KARBOR_API_CONF"
if [[ "$KARBOR_DEPLOY" == "mod_wsgi" ]]; then
start_karbor_api_mod_wsgi
elif [[ "$KARBOR_DEPLOY" == "uwsgi" ]]; then
start_karbor_api_uwsgi
fi
fi
if is_service_enabled karbor-operationengine; then
@ -215,12 +240,13 @@ if [[ "$Q_ENABLE_KARBOR" == "True" ]]; then
if [[ "$1" == "unstack" ]]; then
if is_service_enabled karbor-api; then
if [[ "$KARBOR_USE_MOD_WSGI" == "True" ]]; then
stop_karbor_api_wsgi
clean_karbor_api_wsgi
else
stop_process karbor-api
fi
if [[ "$KARBOR_DEPLOY" == "mod_wsgi" ]]; then
stop_karbor_api_mod_wsgi
clean_karbor_api_mod_wsgi
elif [[ "$KARBOR_DEPLOY" == "uwsgi" ]]; then
stop_karbor_api_uwsgi
clean_karbor_api_uwsgi
fi
fi
if is_service_enabled karbor-operationengine; then
stop_process karbor-operationengine

View File

@ -6,13 +6,14 @@ KARBORCLIENT_REPO=${KARBORCLIENT_REPO:-"https://git.openstack.org/cgit/openstack
KARBORCLIENT_DIR=$DEST/python-karborclient
KARBORCLIENT_BRANCH=${KARBORCLIENT_BRANCH:-master}
# Toggle for deploying Karbor under apache2 in mod_wsgi
KARBOR_USE_MOD_WSGI=${KARBOR_USE_MOD_WSGI:-True}
# common variables
KARBOR_SERVICE_NAME=karbor
KARBOR_SERVICE_TYPE=data-protect
KARBOR_CONF_DIR=${KARBOR_CONF_DIR:-/etc/karbor}
KARBOR_BIN_DIR=$(get_python_exec_prefix)
# common variables
KARBOR_CONF_DIR=${KARBOR_CONF_DIR:-/etc/karbor}
KARBOR_API_UWSGI_CONF=$KARBOR_CONF_DIR/karbor-uwsgi.ini
KARBOR_API_UWSGI=$KARBOR_BIN_DIR/karbor-wsgi
# karbor rest api
KARBOR_API=$KARBOR_DIR/karbor/cmd/api.py
@ -23,10 +24,15 @@ KARBOR_API_LISTEN_ADDRESS=${KARBOR_API_LISTEN_ADDRESS:-0.0.0.0}
KARBOR_API_HOST=${KARBOR_API_HOST:-$SERVICE_HOST}
KARBOR_API_PORT=${KARBOR_API_PORT:-8799}
KARBOR_API_PROTOCOL=${KARBOR_API_PROTOCOL:-$SERVICE_PROTOCOL}
if [[ "$WSGI_MODE" == "uwsgi" ]]; then
KARBOR_DEPLOY=uwsgi
KARBOR_API_ENDPOINT="$KARBOR_API_PROTOCOL://$KARBOR_API_HOST/$KARBOR_SERVICE_TYPE/v1/\$(project_id)s"
else
KARBOR_DEPLOY=mod_wsgi
KARBOR_API_ENDPOINT="$KARBOR_API_PROTOCOL://$KARBOR_API_HOST:$KARBOR_API_PORT/v1/\$(project_id)s"
fi
KARBOR_AUTH_CACHE_DIR=${KARBOR_AUTH_CACHE_DIR:-/var/cache/karbor}
export PYTHONPATH=$PYTHONPATH:$KARBOR_DIR
KARBOR_SERVICE_NAME=karbor
KARBOR_SERVICE_TYPE=data-protect