Deploy murano-api via uwsgi

The patch add the devstack install murano-api via uwsgi.

Implements: blueprint murano-api-wsgi
Change-Id: I3b83a0295cf60de24ff90cabfcbbc3cfb0171905
This commit is contained in:
zhurong 2017-03-08 11:59:47 +08:00
parent 075f5777d9
commit efbe5ca5d1
5 changed files with 93 additions and 9 deletions

View File

@ -0,0 +1,25 @@
Listen %PUBLICPORT%
<VirtualHost *:%PUBLICPORT%>
WSGIDaemonProcess murano-api processes=1 threads=10 user=%USER% display-name=%{GROUP} %VIRTUALENV%
WSGIProcessGroup murano-api
WSGIScriptAlias / %MURANO_BIN_DIR%/murano-wsgi-api
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
AllowEncodedSlashes On
<IfVersion >= 2.4>
ErrorLogFormat "%{cu}t %M"
</IfVersion>
ErrorLog /var/log/%APACHE_NAME%/murano_api.log
CustomLog /var/log/%APACHE_NAME%/murano_api_access.log combined
<Directory %MURANO_BIN_DIR%>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
<IfVersion < 2.4>
Order allow,deny
Allow from all
</IfVersion>
</Directory>
</VirtualHost>

View File

@ -20,6 +20,17 @@ fi
MURANO_AUTH_CACHE_DIR=${MURANO_AUTH_CACHE_DIR:-/var/cache/murano}
# Toggle for deploying Murano-API under under a wsgi server
MURANO_USE_UWSGI=${MURANO_USE_UWSGI:-True}
MURANO_UWSGI=$MURANO_BIN_DIR/murano-wsgi-api
MURANO_UWSGI_CONF=$MURANO_CONF_DIR/murano-api-uwsgi.ini
if [[ "$MURANO_USE_UWSGI" == "True" ]]; then
MURANO_API_URL="$MURANO_SERVICE_PROTOCOL://$MURANO_SERVICE_HOST/application-catalog"
else
MURANO_API_URL="$MURANO_SERVICE_PROTOCOL://$MURANO_SERVICE_HOST:$MURANO_SERVICE_PORT"
fi
# create_murano_accounts() - Set up common required murano accounts
#
@ -36,9 +47,9 @@ function create_murano_accounts() {
get_or_create_service "murano" "application-catalog" "Application Catalog Service"
get_or_create_endpoint "application-catalog" \
"$REGION_NAME" \
"$MURANO_SERVICE_PROTOCOL://$MURANO_SERVICE_HOST:$MURANO_SERVICE_PORT" \
"$MURANO_SERVICE_PROTOCOL://$MURANO_SERVICE_HOST:$MURANO_SERVICE_PORT" \
"$MURANO_SERVICE_PROTOCOL://$MURANO_SERVICE_HOST:$MURANO_SERVICE_PORT"
"$MURANO_API_URL" \
"$MURANO_API_URL" \
"$MURANO_API_URL"
if is_service_enabled murano-cfapi; then
get_or_create_service "murano-cfapi" "service-broker" "Murano CloudFoundry Service Broker"
@ -164,7 +175,7 @@ function configure_murano {
iniset $MURANO_CONF_FILE DEFAULT debug $MURANO_DEBUG
iniset $MURANO_CONF_FILE DEFAULT use_syslog $SYSLOG
# Format logging
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ] && [ "$MURANO_USE_UWSGI" == "False" ] ; then
setup_colorized_logging $MURANO_CONF_FILE DEFAULT
else
# Show user_name and project_name instead of user_id and project_id
@ -200,7 +211,7 @@ function configure_murano {
iniset $MURANO_CONF_FILE keystone auth_url $KEYSTONE_SERVICE_URI
# Configure Murano API URL
iniset $MURANO_CONF_FILE murano url "$MURANO_SERVICE_PROTOCOL://$MURANO_SERVICE_HOST:$MURANO_SERVICE_PORT"
iniset $MURANO_CONF_FILE murano url "$MURANO_API_URL"
# Configure the number of api workers
if [[ -n "$MURANO_API_WORKERS" ]]; then
@ -214,6 +225,11 @@ function configure_murano {
if is_murano_backend_glare; then
configure_murano_glare_backend
fi
if [ "$MURANO_USE_UWSGI" == "True" ]; then
write_uwsgi_config "$MURANO_UWSGI_CONF" "$MURANO_UWSGI" "/application-catalog"
fi
}
# set the murano packages service backend
@ -259,7 +275,7 @@ function install_murano_apps() {
--os-password $OS_PASSWORD \
--os-tenant-name $OS_PROJECT_NAME \
--os-auth-url $KEYSTONE_SERVICE_URI \
--murano-url "$MURANO_SERVICE_PROTOCOL://$MURANO_SERVICE_HOST:$MURANO_SERVICE_PORT" \
--murano-url $MURANO_API_URL \
--glare-url $GLANCE_SERVICE_PROTOCOL://$GLANCE_GLARE_HOSTPORT \
--murano-packages-service $MURANO_PACKAGES_SERVICE \
package-import \
@ -345,7 +361,7 @@ function setup_core_library() {
--os-tenant-name admin \
--os-auth-url $KEYSTONE_SERVICE_URI \
--os-region-name $REGION_NAME \
--murano-url "$MURANO_SERVICE_PROTOCOL://$MURANO_SERVICE_HOST:$MURANO_SERVICE_PORT" \
--murano-url $MURANO_API_URL \
--glare-url $GLANCE_SERVICE_PROTOCOL://$GLANCE_GLARE_HOSTPORT \
--murano-packages-service $MURANO_PACKAGES_SERVICE \
package-import $MURANO_DIR/meta/*.zip \
@ -365,6 +381,7 @@ function install_murano() {
if is_murano_backend_glare; then
install_murano_artifact_plugin
fi
}
function install_murano_pythonclient() {
@ -382,7 +399,11 @@ function install_murano_pythonclient() {
# start_murano() - Start running processes, including screen
function start_murano() {
run_process murano-api "$MURANO_BIN_DIR/murano-api --config-file $MURANO_CONF_DIR/murano.conf"
if [ "$MURANO_USE_UWSGI" == "True" ]; then
run_process murano-api "$MURANO_BIN_DIR/uwsgi --ini $MURANO_UWSGI_CONF"
else
run_process murano-api "$MURANO_BIN_DIR/murano-api --config-file $MURANO_CONF_DIR/murano.conf"
fi
run_process murano-engine "$MURANO_BIN_DIR/murano-engine --config-file $MURANO_CONF_DIR/murano.conf"
}
@ -390,7 +411,12 @@ function start_murano() {
# stop_murano() - Stop running processes
function stop_murano() {
# Kill the Murano screen windows
stop_process murano-api
if [ "$MURANO_USE_UWSGI" == "True" ]; then
disable_apache_site murano-api
restart_apache_server
else
stop_process murano-api
fi
stop_process murano-engine
}
@ -412,6 +438,11 @@ function cleanup_murano() {
# Cleanup keystone signing dir
sudo rm -rf $MURANO_KEYSTONE_SIGNING_DIR
if [[ "$MURANO_USE_UWSGI" == "True" ]]; then
remove_uwsgi_config "$MURANO_UWSGI_CONF" "$MURANO_UWSGI"
fi
}
function configure_murano_tempest_plugin() {

View File

@ -13,6 +13,7 @@ GITDIR["python-muranoclient"]=$DEST/python-muranoclient
# Set up default directories
MURANO_DIR=$DEST/murano
MURANO_FILES_DIR=$MURANO_DIR/devstack/files
MURANO_CONF_DIR=${MURANO_CONF_DIR:-/etc/murano}
MURANO_CONF_FILE=${MURANO_CONF_DIR}/murano.conf
MURANO_CFAPI_CONF_FILE=${MURANO_CONF_DIR}/murano-cfapi.conf

View File

@ -218,6 +218,30 @@ class Service(service.Service):
super(Service, self).reset()
def get_notification_listener():
endpoints = [report_notification, track_instance, untrack_instance]
transport = messaging.get_notification_transport(CONF)
s_target = target.Target(topic='murano', server=str(uuid.uuid4()))
listener = messaging.get_notification_listener(
transport, [s_target], endpoints, executor='threading')
return listener
def get_rpc_server():
endpoints = [ResultEndpoint()]
transport = messaging.get_transport(CONF)
s_target = target.Target('murano', 'results', server=str(uuid.uuid4()))
access_policy = dispatcher.DefaultRPCAccessPolicy
server = messaging.get_rpc_server(
transport, s_target, endpoints, 'threading',
access_policy=access_policy)
return server
class NotificationService(Service):
def __init__(self):
super(NotificationService, self).__init__()

View File

@ -25,6 +25,7 @@ from murano.common import app_loader
from murano.common import config
from murano.common.i18n import _
from murano.common import policy
from murano.common import server
def init_application():
@ -38,6 +39,8 @@ def init_application():
config.set_middleware_defaults()
request_statistics.init_stats()
policy.init()
server.get_notification_listener().start()
server.get_rpc_server().start()
port = cfg.CONF.bind_port
host = cfg.CONF.bind_host