Create devstack plugin for testing os-loganalyze

This will allow os-loganalyze to be ran as a devstack service.
We can then run tests to make sure the wsgi app is deployable in
apache.

Change-Id: I799c346dca651628743c9b23b69f66692c603397
This commit is contained in:
Joshua Hesketh 2015-05-06 23:57:41 +10:00 committed by Sean Dague
parent cc2907689f
commit 42fc43e7e6
3 changed files with 127 additions and 0 deletions

View File

@ -0,0 +1,41 @@
Listen %PORT%
<VirtualHost *:%PORT%>
# use Apache to compress the results afterwards, to save on the wire
# it's approx 18x savings of wire traffic to compress. We need to
# compress by content types that htmlify can produce
AddOutputFilterByType DEFLATE text/plain text/html
<FilesMatch \.html\.gz$>
ForceType text/html
AddDefaultCharset UTF-8
AddEncoding x-gzip gz
</FilesMatch>
<Directory %OS_LOGANALYZE_DIR%>
Allow from all
Satisfy Any
</Directory>
RewriteEngine On
# rewrite txt.gz & console.html[.gz] files to map to our internal htmlify
# wsgi app
# PT, Pass-through: to come back around and get picked up by the
# WSGIScriptAlias
# NS, No-subrequest: on coming back through, mod-autoindex may have added
# index.html which would match the !-f condition. We
# therefore ensure the rewrite doesn't trigger by
# disallowing subrequests.
RewriteRule ^/(.*\.txt\.gz)$ /htmlify/$1 [QSA,L,PT,NS]
RewriteRule ^/(.*console\.html(\.gz)?)$ /htmlify/$1 [QSA,L,PT,NS]
# Check if the request exists as a file, directory or symbolic link
# If not, write the request to htmlify to see if we can fetch from swift
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !^/icon
RewriteRule ^/(.*)$ /htmlify/$1 [QSA,L,PT,NS]
WSGIScriptAlias /htmlify %OS_LOGANALYZE_DIR%/os_loganalyze/wsgi.py
LogLevel warn
ServerSignature Off
</VirtualHost>

82
devstack/plugin.sh Normal file
View File

@ -0,0 +1,82 @@
# Copyright (c) 2015 Rackspace Australia
#
# 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.
# check for service enabled
if is_service_enabled os_loganalyze; then
if [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
# Set up system services
echo_summary "Configuring system services os_loganalyze"
install_apache_wsgi
if is_ubuntu; then
# rewrite isn't enabled by default, enable it
sudo a2enmod rewrite
elif is_fedora; then
# rewrite is enabled by default, noop
echo "rewrite mod already enabled"
elif is_suse; then
# WSGI isn't enabled by default, enable it
sudo a2enmod rewrite
else
exit_distro_not_supported "apache mod-rewrite installation"
fi
elif [[ "$1" == "stack" && "$2" == "install" ]]; then
# Perform installation of service source
echo_summary "Installing os_loganalyze"
setup_install $OS_LOGANALYZE_DIR
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
# Configure after the other layer 1 and 2 services have been configured
echo_summary "Configuring os_loganalyze"
sudo cp $OS_LOGANALYZE_APACHE_TEMPLATE $(apache_site_config_for os_loganalyze)
sudo sed -e "
s/%PORT%/8080/g;
s/%OS_LOGANALYZE_DIR%/${OS_LOGANALYZE_DIR//\//\\\/}/g;
" -i $(apache_site_config_for os_loganalyze)
enable_apache_site os_loganalyze
restart_apache_server
elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
# Initialize and start the os_loganalyze service
echo_summary "Initializing os_loganalyze"
fi
if [[ "$1" == "unstack" ]]; then
# Shut down os_loganalyze services
# no-op
stop_apache_server
fi
if [[ "$1" == "clean" ]]; then
# Remove state and transient data
# Remember clean.sh first calls unstack.sh
# no-op
disable_apache_site os_loganalyze
if is_ubuntu; then
# rewrite isn't enabled by default, disable it agin
sudo a2dismod rewrite
elif is_fedora; then
# rewrite is enabled by default, noop
echo "rewrite mod enabled by default"
elif is_suse; then
# rewrite isn't enabled by default, disable it agin
sudo a2dismod rewrite
else
exit_distro_not_supported "apache mod-rewrite installation"
fi
fi
fi

4
devstack/settings Normal file
View File

@ -0,0 +1,4 @@
OS_LOGANALYZE_DIR=$DEST/os-loganalyze
OS_LOGANALYZE_APACHE_TEMPLATE=$OS_LOGANALYZE_DIR/devstack/os-loganalyze.template
enable_service os_loganalyze