diff --git a/devstack/mixmatch.sh b/devstack/mixmatch.sh index 63740d2..4920fa1 100644 --- a/devstack/mixmatch.sh +++ b/devstack/mixmatch.sh @@ -12,9 +12,13 @@ # License for the specific language governing permissions and limitations # under the License. +MIXMATCH_BIN_DIR=$(get_python_exec_prefix) +MIXMATCH_CONF_DIR="/etc/mixmatch" + +MIXMATCH_UWSGI_INI="$MIXMATCH_CONF_DIR/mixmatch-uwsgi.ini" + function install_mixmatch { pip_install $MIXMATCH_DIR - pip_install uwsgi } function configure_mixmatch { @@ -23,8 +27,7 @@ function configure_mixmatch { sudo chown $STACK_USER:$STACK_USER /etc/mixmatch cp $MIXMATCH_DIR/etc/mixmatch.conf.sample $MIXMATCH_CONF - iniset $MIXMATCH_CONF database connection "sqlite:////tmp/mixmatch.db" - iniset $MIXMATCH_CONF DEFAULT port $MIXMATCH_SERVICE_PORT + iniset $MIXMATCH_CONF database connection "sqlite://" iniset $MIXMATCH_CONF DEFAULT service_providers default iniset $MIXMATCH_CONF DEFAULT aggregation False @@ -51,21 +54,25 @@ function configure_mixmatch { "$NEUTRON_SERVICE_PROTOCOL://$NEUTRON_SERVICE_HOST:$NEUTRON_SERVICE_PORT" iniset $MIXMATCH_CONF sp_default enabled_services "image, volume, network" - run_process mixmatch "$MIXMATCH_DIR/run_proxy.sh" - # Nova - iniset $NOVA_CONF glance api_servers "$MIXMATCH_SERVICE_PROTOCOL://$HOST_IP:$MIXMATCH_SERVICE_PORT/image" - iniset $NOVA_CONF neutron url "$MIXMATCH_SERVICE_PROTOCOL://$HOST_IP:$MIXMATCH_SERVICE_PORT/network" + iniset $NOVA_CONF glance api_servers "$MIXMATCH_URL/image" + iniset $NOVA_CONF neutron url "$MIXMATCH_URL/network" # Cinder - iniset $CINDER_CONF DEFAULT glance_api_servers \ - "$MIXMATCH_SERVICE_PROTOCOL://$HOST_IP:$MIXMATCH_SERVICE_PORT/image" + iniset $CINDER_CONF DEFAULT glance_api_servers "$MIXMATCH_URL/image" iniset $CINDER_CONF oslo_messaging_notifications driver messaging iniset $CINDER_CONF oslo_messaging_notifications topics notifications # Glance iniset $GLANCE_CONF oslo_messaging_notifications driver messaging iniset $CINDER_CONF oslo_messaging_notifications topics notifications + + sudo cp $MIXMATCH_DIR/httpd/mixmatch-uwsgi.conf $(apache_site_config_for mixmatch) + enable_apache_site mixmatch + restart_apache_server + + run_process mixmatch \ + "$MIXMATCH_BIN_DIR/uwsgi --ini $MIXMATCH_DIR/httpd/mixmatch-uwsgi.ini" } function get_endpoint_ids { @@ -84,36 +91,36 @@ function register_mixmatch { get_or_create_endpoint \ "image" \ "$REGION_NAME" \ - "http://$HOST_IP:5001/image" \ - "http://$HOST_IP:5001/image" \ - "http://$HOST_IP:5001/image" + "$MIXMATCH_URL/image" \ + "$MIXMATCH_URL/image" \ + "$MIXMATCH_URL/image" get_or_create_endpoint \ "volume" \ "$REGION_NAME" \ - "http://$HOST_IP:5001/volume/v1/\$(project_id)s" \ - "http://$HOST_IP:5001/volume/v1/\$(project_id)s" \ - "http://$HOST_IP:5001/volume/v1/\$(project_id)s" + "$MIXMATCH_URL/volume/v1/\$(project_id)s" \ + "$MIXMATCH_URL/volume/v1/\$(project_id)s" \ + "$MIXMATCH_URL/volume/v1/\$(project_id)s" get_or_create_endpoint \ "volumev2" \ "$REGION_NAME" \ - "http://$HOST_IP:5001/volume/v2/\$(project_id)s" \ - "http://$HOST_IP:5001/volume/v2/\$(project_id)s" \ - "http://$HOST_IP:5001/volume/v2/\$(project_id)s" + "$MIXMATCH_URL/volume/v2/\$(project_id)s" \ + "$MIXMATCH_URL/volume/v2/\$(project_id)s" \ + "$MIXMATCH_URL/volume/v2/\$(project_id)s" get_or_create_endpoint \ "volumev3" \ "$REGION_NAME" \ - "http://$HOST_IP:5001/volume/v3/\$(project_id)s" \ - "http://$HOST_IP:5001/volume/v3/\$(project_id)s" \ - "http://$HOST_IP:5001/volume/v3/\$(project_id)s" + "$MIXMATCH_URL/volume/v3/\$(project_id)s" \ + "$MIXMATCH_URL/volume/v3/\$(project_id)s" \ + "$MIXMATCH_URL/volume/v3/\$(project_id)s" get_or_create_endpoint \ "network" \ "$REGION_NAME" \ - "http://$HOST_IP:5001/network" \ - "http://$HOST_IP:5001/network" \ - "http://$HOST_IP:5001/network" + "$MIXMATCH_URL/network" \ + "$MIXMATCH_URL/network" \ + "$MIXMATCH_URL/network" fi } diff --git a/devstack/settings b/devstack/settings index 0a94006..e5cf0a2 100644 --- a/devstack/settings +++ b/devstack/settings @@ -4,7 +4,7 @@ MIXMATCH_DIR=$DEST/mixmatch MIXMATCH_PLUGIN=$DEST/mixmatch/devstack MIXMATCH_CONF=/etc/mixmatch/mixmatch.conf -MIXMATCH_SERVICE_PORT=${MIXMATCH_SERVICE_PORT:-5001} -MIXMATCH_SERVICE_PROTOCOL=${MIXMATCH_SERVICE_PROTOCOL:-http} +REGISTER_MIXMATCH=${REGISTER_MIXMATCH:-false} -REGISTER_MIXMATCH=${REGISTER_MIXMATCH:-false} \ No newline at end of file +MIXMATCH_SERVICE_PROTOCOL=${MIXMATCH_SERVICE_PROTOCOL:-http} +MIXMATCH_URL=${MIXMATCH_URL:-"$MIXMATCH_SERVICE_PROTOCOL://$HOST_IP/resource"} diff --git a/doc/source/installation.rst b/doc/source/installation.rst index c9d3e9a..96451e9 100644 --- a/doc/source/installation.rst +++ b/doc/source/installation.rst @@ -14,27 +14,13 @@ Install dependencies. :: Web Server ========== -The recommended way is to run the proxy using uWSGI through the -``run_proxy.sh`` script. :: +The recommended way is to run the proxy using uwsgi and apache through the +`httpd/mixmatch-uwsgi.ini` and `httpd/mixmatch-uwsgi.conf` files respectively :: - $ ./run_proxy.sh - - -It is also possible to run the proxy with Apache2 and ``mod_wsgi``, but there -are limitations compared to running it with uWSGI. - -- Image uploading with Glance doesn't work unless running Apache in embedded - mode. -- Image API v1 uses underscores in the header keys, which are silently dropped - by Apache. Hacking the configuration to allow these through is required. - -To run the proxy with Apache in Ubuntu: :: - - $ apt-get install libapache2-mod-wsgi - $ cp httpd/apache.conf /etc/apache2/sites-available/proxy.conf - $ cp etc/mixmatch.conf.sample /etc/mixmatch/mixmatch.conf - $ a2ensite proxy - $ service apache2 reload + sudo apt install uwsgi uwsgi-plugin-python libapache2-mod-proxy-uwsgi + uwsgi mixmatch/httpd/mixmatch-uwsgi.ini + sudo cp mixmatch/httpd/mixmatach-uwsgi.ini /etc/apache2/sites-available/mixmatch.conf + sudo a2ensite mixmatch Running in a Docker Container diff --git a/httpd/apache.conf b/httpd/apache.conf deleted file mode 100644 index 56c3cd8..0000000 --- a/httpd/apache.conf +++ /dev/null @@ -1,17 +0,0 @@ -LoadModule wsgi_module modules/mod_wsgi.so -WSGISocketPrefix /var/run/wsgi - -Listen 5001 - - - WSGIPassAuthorization On - WSGIChunkedRequest On - #WSGIDaemonProcess k2k-proxy user=ubuntu group=ubuntu threads=2 - WSGIScriptAlias / /home/ubuntu/k2k-proxy/httpd/k2k-proxy.wsgi - - - #WSGIProcessGroup k2k-proxy - #WSGIApplicationGroup %{GLOBAL} - Require all granted - - diff --git a/httpd/k2k-proxy.wsgi b/httpd/k2k-proxy.wsgi deleted file mode 100644 index f35de17..0000000 --- a/httpd/k2k-proxy.wsgi +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2016 Massachusetts Open Cloud -# -# 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. - -from mixmatch.proxy import app as application \ No newline at end of file diff --git a/httpd/mixmatch-uwsgi.conf b/httpd/mixmatch-uwsgi.conf new file mode 100644 index 0000000..32c5990 --- /dev/null +++ b/httpd/mixmatch-uwsgi.conf @@ -0,0 +1,2 @@ +KeepAlive Off +ProxyPass "/resource" "http://127.0.0.1:9913" retry=0 diff --git a/httpd/mixmatch-uwsgi.ini b/httpd/mixmatch-uwsgi.ini new file mode 100644 index 0000000..7ffea68 --- /dev/null +++ b/httpd/mixmatch-uwsgi.ini @@ -0,0 +1,26 @@ +[uwsgi] +wsgi-file = /usr/local/bin/mixmatch + +http-socket = 0.0.0.0:9913 +http-keepalive = false +http-chunked-input = true + +# Override the default size for headers from the 4k default. +# This is required for keystone tokens. +buffer-size = 65535 + +# This is running standalone +master = true + +enable-threads = true + +# Tune this to your environment. +processes = 8 + +# uwsgi recommends this to prevent thundering herd on accept. +thunder-lock = true + +plugins = python + +# This ensures that file descriptors aren't shared between processes. +lazy-apps = true diff --git a/mixmatch/config/default.py b/mixmatch/config/default.py index 294d7af..3d19486 100644 --- a/mixmatch/config/default.py +++ b/mixmatch/config/default.py @@ -17,10 +17,6 @@ from oslo_config import cfg GROUP = None OPTS = [ - cfg.IntOpt('port', - default=5001, - help='Web Server Port'), - cfg.ListOpt('service_providers', default=[], help='List of service providers'), diff --git a/mixmatch/tests/functional/hooks/dsvm_hook.sh b/mixmatch/tests/functional/hooks/dsvm_hook.sh index cbf01f2..12e9e93 100755 --- a/mixmatch/tests/functional/hooks/dsvm_hook.sh +++ b/mixmatch/tests/functional/hooks/dsvm_hook.sh @@ -19,6 +19,7 @@ cd $BASE/new/devstack source openrc admin admin # Register the endpoints +source $BASE/new/mixmatch/devstack/settings source $BASE/new/mixmatch/devstack/mixmatch.sh REGISTER_MIXMATCH=true register_mixmatch diff --git a/mixmatch/wsgi.py b/mixmatch/wsgi.py index a10146b..eb3b8f6 100644 --- a/mixmatch/wsgi.py +++ b/mixmatch/wsgi.py @@ -17,3 +17,7 @@ from mixmatch import session proxy.main() application = session.app + + +def get_application(): + return application diff --git a/run_proxy.sh b/run_proxy.sh deleted file mode 100755 index e5fa53a..0000000 --- a/run_proxy.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -uwsgi --socket 0.0.0.0:5001 \ - --protocol=http \ - --http-chunked-input \ - -w mixmatch.wsgi \ - --master \ - --processes 8 \ - --threads 1 \ - 2>&1 diff --git a/setup.cfg b/setup.cfg index 01e1480..eab1847 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,15 +21,22 @@ classifier = Programming Language :: Python :: 3.4 Programming Language :: Python :: 3.5 +[global] +setup_hooks = + pbr.hooks.setup_hook + [files] packages = mixmatch mixmatch.config mixmatch.extend data_files = - etc/ = etc/* + /etc/mixmatch = etc/* [entry_points] +wsgi_scripts = + mixmatch = mixmatch.wsgi:get_application + oslo.config.opts = mixmatch = mixmatch.config:list_opts mixmatch.extend =