python-django-horizon: update for stx 5.0
* inherit stx-metadata to help apply patches and install files from stx 'upstream' repo * remove the local copy of stx files * update the do_install according to the spec Story: 2008952 Task: 42576 Signed-off-by: Jackie Huang <jackie.huang@windriver.com> Change-Id: I3a03e93ddea77ce36570c081567eef0e71cb81d7
This commit is contained in:
parent
23d558fe52
commit
059fe15797
@ -1,59 +0,0 @@
|
||||
import datetime
|
||||
import fnmatch
|
||||
import os
|
||||
import resource
|
||||
import subprocess
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
errorlog = "/var/log/horizon/gunicorn.log"
|
||||
capture_output = True
|
||||
|
||||
# maxrss ceiling in kbytes
|
||||
MAXRSS_CEILING = 512000
|
||||
|
||||
|
||||
def worker_abort(worker):
|
||||
path = ("/proc/%s/fd") % os.getpid()
|
||||
contents = os.listdir(path)
|
||||
upload_dir = getattr(settings, 'FILE_UPLOAD_TEMP_DIR', '/tmp')
|
||||
pattern = os.path.join(upload_dir, '*.upload')
|
||||
|
||||
for i in contents:
|
||||
f = os.path.join(path, i)
|
||||
if os.path.exists(f):
|
||||
try:
|
||||
link = os.readlink(f)
|
||||
if fnmatch.fnmatch(link, pattern):
|
||||
worker.log.info(link)
|
||||
os.remove(link)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
def when_ready(server):
|
||||
subprocess.check_call(["/usr/bin/horizon-assets-compress"])
|
||||
|
||||
|
||||
def post_worker_init(worker):
|
||||
worker.nrq = 0
|
||||
worker.restart = False
|
||||
|
||||
|
||||
def pre_request(worker, req):
|
||||
worker.nrq += 1
|
||||
if worker.restart:
|
||||
worker.nr = worker.max_requests - 1
|
||||
maxrss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
|
||||
msg = "%(date)s %(uri)s %(rss)u" % ({'date': datetime.datetime.now(),
|
||||
'uri': getattr(req, "uri"),
|
||||
'rss': maxrss})
|
||||
worker.log.info(msg)
|
||||
|
||||
|
||||
def post_request(worker, req, environ, resp):
|
||||
worker.nrq -= 1
|
||||
if not worker.restart:
|
||||
maxrss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
|
||||
if maxrss > MAXRSS_CEILING and worker.nrq == 0:
|
||||
worker.restart = True
|
@ -1,43 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2017 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
PYTHON=`which python`
|
||||
MANAGE="/usr/share/openstack-dashboard/manage.py"
|
||||
STATICDIR="/www/pages/static"
|
||||
BRANDDIR="/opt/branding"
|
||||
APPLIEDDIR="/opt/branding/applied"
|
||||
|
||||
# Handle custom horizon branding
|
||||
rm -rf ${APPLIEDDIR}
|
||||
if ls ${BRANDDIR}/*.tgz 1> /dev/null 2>&1; then
|
||||
LATESTBRANDING=$(ls $BRANDDIR |grep '\.tgz$' | tail -n 1)
|
||||
mkdir -p ${APPLIEDDIR}
|
||||
tar zxf ${BRANDDIR}/${LATESTBRANDING} -C ${APPLIEDDIR} 2>/dev/null 1>/dev/null
|
||||
RETVAL=$?
|
||||
if [ $RETVAL -ne 0 ]; then
|
||||
echo "Failed to extract ${BRANDDIR}/${LATESTBRANDING}"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Dumping static assets"
|
||||
if [ -d ${STATICDIR} ]; then
|
||||
COLLECTARGS=--clear
|
||||
fi
|
||||
${PYTHON} -- ${MANAGE} collectstatic -v0 --noinput ${COLLECTARGS}
|
||||
|
||||
RETVAL=$?
|
||||
if [ $RETVAL -ne 0 ]; then
|
||||
echo "Failed to dump static assets."
|
||||
exit $RETVAL
|
||||
fi
|
||||
|
||||
nice -n 20 ionice -c Idle ${PYTHON} -- ${MANAGE} compress -v0
|
||||
RETVAL=$?
|
||||
if [ $RETVAL -ne 0 ]; then
|
||||
echo "Failed to compress assets."
|
||||
exit $RETVAL
|
||||
fi
|
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
/usr/bin/nice -n 2 /usr/bin/python /usr/share/openstack-dashboard/manage.py clearsessions
|
@ -1,80 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2017 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
#
|
||||
# The patching subsystem provides a patch-functions bash source file
|
||||
# with useful function and variable definitions.
|
||||
#
|
||||
. /etc/patching/patch-functions
|
||||
|
||||
#
|
||||
# We can now check to see what type of node we're on, if it's locked, etc,
|
||||
# and act accordingly
|
||||
#
|
||||
|
||||
#
|
||||
# Declare an overall script return code
|
||||
#
|
||||
declare -i GLOBAL_RC=$PATCH_STATUS_OK
|
||||
|
||||
#
|
||||
# handle restarting horizon.
|
||||
#
|
||||
if is_controller
|
||||
then
|
||||
# Horizon only runs on the controller
|
||||
|
||||
if [ ! -f $PATCH_FLAGDIR/horizon.restarted ]
|
||||
then
|
||||
# Check SM to see if Horizon is running
|
||||
sm-query service horizon | grep -q 'enabled-active'
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
loginfo "$0: Logging out all horizon sessions"
|
||||
|
||||
# Remove sessions
|
||||
rm -f /var/tmp/sessionid*
|
||||
|
||||
loginfo "$0: Restarting horizon"
|
||||
|
||||
# Ask SM to restart Horizon
|
||||
sm-restart service horizon
|
||||
touch $PATCH_FLAGDIR/horizon.restarted
|
||||
|
||||
# Wait up to 30 seconds for service to recover
|
||||
let -i UNTIL=$SECONDS+30
|
||||
while [ $UNTIL -ge $SECONDS ]
|
||||
do
|
||||
# Check to see if it's running
|
||||
sm-query service horizon | grep -q 'enabled-active'
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
break
|
||||
fi
|
||||
|
||||
# Still not running? Let's wait 5 seconds and check again
|
||||
sleep 5
|
||||
done
|
||||
|
||||
sm-query service horizon | grep -q 'enabled-active'
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
# Still not running! Clear the flag and mark the RC as failed
|
||||
loginfo "$0: Failed to restart horizon"
|
||||
rm -f $PATCH_FLAGDIR/horizon.restarted
|
||||
GLOBAL_RC=$PATCH_STATUS_FAILED
|
||||
sm-query service horizon
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Exit the script with the overall return code
|
||||
#
|
||||
exit $GLOBAL_RC
|
||||
|
@ -1,152 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: OpenStack Dashboard
|
||||
# Required-Start: networking
|
||||
# Required-Stop: networking
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: OpenStack Dashboard
|
||||
# Description: Web based user interface to OpenStack services including
|
||||
# Nova, Swift, Keystone, etc.
|
||||
### END INIT INFO
|
||||
|
||||
RETVAL=0
|
||||
DESC="openstack-dashboard"
|
||||
PIDFILE="/var/run/$DESC.pid"
|
||||
PYTHON=`which python`
|
||||
# Centos packages openstack_dashboard under /usr/share
|
||||
#MANAGE="@PYTHON_SITEPACKAGES@/openstack_dashboard/manage.py"
|
||||
MANAGE="/usr/share/openstack-dashboard/manage.py"
|
||||
EXEC="/usr/bin/gunicorn"
|
||||
BIND="localhost"
|
||||
PORT="8008"
|
||||
WORKER="eventlet"
|
||||
WORKERS=`grep workers /etc/openstack-dashboard/horizon-config.ini | cut -f3 -d' '`
|
||||
# Increased timeout to facilitate large image uploads
|
||||
TIMEOUT="200"
|
||||
STATICDIR="/www/pages/static"
|
||||
BRANDDIR="/opt/branding"
|
||||
APPLIEDDIR="/opt/branding/applied"
|
||||
TMPUPLOADDIR="/scratch/horizon"
|
||||
|
||||
source /usr/bin/tsconfig
|
||||
|
||||
start()
|
||||
{
|
||||
# Change workers if combined controller/compute
|
||||
. /etc/platform/platform.conf
|
||||
if [ "${WORKERS}" -lt "2" ]; then
|
||||
WORKERS=2
|
||||
fi
|
||||
|
||||
if [ -e $PIDFILE ]; then
|
||||
PIDDIR=/proc/$(cat $PIDFILE)
|
||||
if [ -d ${PIDDIR} ]; then
|
||||
echo "$DESC already running."
|
||||
return
|
||||
else
|
||||
echo "Removing stale PID file $PIDFILE"
|
||||
rm -f $PIDFILE
|
||||
fi
|
||||
fi
|
||||
|
||||
# Clean up any possible orphaned worker threads
|
||||
if lsof -t -i:${PORT} 1> /dev/null 2>&1; then
|
||||
kill $(lsof -t -i:${PORT}) > /dev/null 2>&1
|
||||
fi
|
||||
|
||||
rm -rf ${TMPUPLOADDIR}
|
||||
mkdir -p ${TMPUPLOADDIR}
|
||||
|
||||
echo -n "Starting $DESC..."
|
||||
|
||||
start-stop-daemon --start --quiet --background --pidfile ${PIDFILE} \
|
||||
--make-pidfile --exec ${PYTHON} -- ${EXEC} --bind ${BIND}:${PORT} \
|
||||
--worker-class ${WORKER} --workers ${WORKERS} --timeout ${TIMEOUT} \
|
||||
--log-syslog \
|
||||
--config '/usr/share/openstack-dashboard/guni_config.py' \
|
||||
--pythonpath '/usr/share/openstack-dashboard' \
|
||||
openstack_dashboard.wsgi
|
||||
RETVAL=$?
|
||||
if [ $RETVAL -eq 0 ]; then
|
||||
echo "done."
|
||||
else
|
||||
echo "failed."
|
||||
fi
|
||||
|
||||
# now copy customer branding file to CONFIG_PATH/branding if anything updated
|
||||
sm-query service drbd-platform | grep enabled-active > /dev/null 2>&1
|
||||
IS_ACTIVE=$?
|
||||
|
||||
if ls ${BRANDDIR}/*.tgz 1> /dev/null 2>&1; then
|
||||
LATESTBRANDING=$(ls $BRANDDIR |grep '\.tgz$' | tail -n 1)
|
||||
if [ $IS_ACTIVE -eq 0 ]; then
|
||||
# Only do the copy if the tarball has changed
|
||||
if ! cmp --silent ${BRANDDIR}/${LATESTBRANDING} ${CONFIG_PATH}/branding/${LATESTBRANDING} ; then
|
||||
mkdir -p ${CONFIG_PATH}/branding
|
||||
rm -rf ${CONFIG_PATH}/branding/*.tgz
|
||||
cp -r ${BRANDDIR}/${LATESTBRANDING} ${CONFIG_PATH}/branding
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# As part of starting horizon we should kill containerized horizon so that it
|
||||
# will pickup branding changes
|
||||
kubectl --kubeconfig=/etc/kubernetes/admin.conf delete pods -n openstack -l application=horizon 1>/dev/null
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
if [ ! -e $PIDFILE ]; then return; fi
|
||||
|
||||
echo -n "Stopping $DESC..."
|
||||
|
||||
start-stop-daemon --stop --quiet --pidfile $PIDFILE
|
||||
RETVAL=$?
|
||||
if [ $RETVAL -eq 0 ]; then
|
||||
echo "done."
|
||||
else
|
||||
echo "failed."
|
||||
fi
|
||||
rm -rf ${TMPUPLOADDIR}
|
||||
rm -f $PIDFILE
|
||||
}
|
||||
|
||||
status()
|
||||
{
|
||||
pid=`cat $PIDFILE 2>/dev/null`
|
||||
if [ -n "$pid" ]; then
|
||||
if ps -p $pid &> /dev/null ; then
|
||||
echo "$DESC is running"
|
||||
RETVAL=0
|
||||
return
|
||||
else
|
||||
RETVAL=1
|
||||
fi
|
||||
fi
|
||||
echo "$DESC is not running"
|
||||
RETVAL=3
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart|force-reload|reload)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
status)
|
||||
status
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|force-reload|restart|reload|status}"
|
||||
RETVAL=1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
@ -1,20 +0,0 @@
|
||||
|
||||
WSGIDaemonProcess dashboard
|
||||
WSGIProcessGroup dashboard
|
||||
WSGISocketPrefix run/wsgi
|
||||
|
||||
WSGIScriptAlias /dashboard /usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi
|
||||
Alias /dashboard/static /usr/share/openstack-dashboard/static
|
||||
|
||||
<Directory /usr/share/openstack-dashboard/openstack_dashboard/wsgi>
|
||||
Options All
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
<Directory /usr/share/openstack-dashboard/static>
|
||||
Options All
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
@ -1,33 +0,0 @@
|
||||
|
||||
# if you want logging to a separate file, please update your config
|
||||
# according to the last 4 lines in this snippet, and also take care
|
||||
# to introduce a <VirtualHost > directive.
|
||||
#
|
||||
|
||||
WSGISocketPrefix run/wsgi
|
||||
|
||||
<VirtualHost *:80>
|
||||
WSGIScriptAlias /dashboard /usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi
|
||||
Alias /static /usr/share/openstack-dashboard/static
|
||||
|
||||
WSGIDaemonProcess dashboard
|
||||
WSGIProcessGroup dashboard
|
||||
|
||||
#DocumentRoot %HORIZON_DIR%/.blackhole/
|
||||
|
||||
<Directory />
|
||||
Options FollowSymLinks
|
||||
AllowOverride None
|
||||
</Directory>
|
||||
|
||||
<Directory /usr/share/openstack-dashboard/>
|
||||
Options Indexes FollowSymLinks MultiViews
|
||||
AllowOverride None
|
||||
Order allow,deny
|
||||
allow from all
|
||||
</Directory>
|
||||
|
||||
ErrorLog logs/openstack_dashboard_error.log
|
||||
LogLevel warn
|
||||
CustomLog logs/openstack_dashboard_access.log combined
|
||||
</VirtualHost>
|
@ -1,9 +0,0 @@
|
||||
|
||||
/var/log/horizon/*.log {
|
||||
weekly
|
||||
rotate 4
|
||||
missingok
|
||||
compress
|
||||
minsize 100k
|
||||
}
|
||||
|
@ -1,4 +0,0 @@
|
||||
|
||||
[Service]
|
||||
ExecStartPre=/usr/bin/python /usr/share/openstack-dashboard/manage.py collectstatic --noinput --clear
|
||||
ExecStartPre=/usr/bin/python /usr/share/openstack-dashboard/manage.py compress --force
|
@ -1,15 +1,10 @@
|
||||
inherit stx-metadata
|
||||
|
||||
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
|
||||
SRC_URI += " \
|
||||
file://${BPN}/guni_config.py \
|
||||
file://${BPN}/horizon-assets-compress \
|
||||
file://${BPN}/horizon-clearsessions \
|
||||
file://${BPN}/horizon.init \
|
||||
file://${BPN}/horizon-patching-restart \
|
||||
file://${BPN}/openstack-dashboard-httpd-2.4.conf \
|
||||
file://${BPN}/openstack-dashboard-httpd-logging.conf \
|
||||
file://${BPN}/python-django-horizon-logrotate.conf \
|
||||
file://${BPN}/python-django-horizon-systemd.conf \
|
||||
STX_REPO = "upstream"
|
||||
STX_SUBPATH = "openstack/python-horizon/centos/files"
|
||||
|
||||
SRC_URI_STX += " \
|
||||
file://0001-Remove-the-hard-coded-internal-URL-for-keystone.patch \
|
||||
"
|
||||
|
||||
do_configure_prepend () {
|
||||
@ -23,8 +18,8 @@ do_configure_prepend () {
|
||||
rm -rf horizon.egg-info
|
||||
|
||||
# drop config snippet
|
||||
cp -p ${WORKDIR}/${BPN}/openstack-dashboard-httpd-logging.conf .
|
||||
cp -p ${WORKDIR}/${BPN}/guni_config.py .
|
||||
cp -p ${STX_METADATA_PATH}/openstack-dashboard-httpd-logging.conf .
|
||||
cp -p ${STX_METADATA_PATH}/guni_config.py .
|
||||
|
||||
# customize default settings
|
||||
# WAS [PATCH] disable debug, move web root
|
||||
@ -56,20 +51,20 @@ do_install_append () {
|
||||
# STX
|
||||
install -d -m 755 ${D}/opt/branding
|
||||
mkdir -p ${D}${sysconfdir}/rc.d/init.d
|
||||
install -m 755 -D -p ${WORKDIR}/${BPN}/horizon.init ${D}${sysconfdir}/rc.d/init.d/horizon
|
||||
install -m 755 -D -p ${WORKDIR}/${BPN}/horizon.init ${D}${sysconfdir}/init.d/horizon
|
||||
install -m 755 -D -p ${WORKDIR}/${BPN}/horizon-clearsessions ${D}/${bindir}/horizon-clearsessions
|
||||
install -m 755 -D -p ${WORKDIR}/${BPN}/horizon-patching-restart ${D}/${bindir}/horizon-patching-restart
|
||||
install -m 755 -D -p ${WORKDIR}/${BPN}/horizon-assets-compress ${D}/${bindir}/horizon-assets-compress
|
||||
install -m 755 -D -p ${STX_METADATA_PATH}/horizon.init ${D}${sysconfdir}/rc.d/init.d/horizon
|
||||
install -m 755 -D -p ${STX_METADATA_PATH}/horizon.init ${D}${sysconfdir}/init.d/horizon
|
||||
install -m 755 -D -p ${STX_METADATA_PATH}/horizon-clearsessions ${D}/${bindir}/horizon-clearsessions
|
||||
install -m 755 -D -p ${STX_METADATA_PATH}/horizon-patching-restart ${D}/${bindir}/horizon-patching-restart
|
||||
install -m 755 -D -p ${STX_METADATA_PATH}/horizon-assets-compress ${D}/${bindir}/horizon-assets-compress
|
||||
|
||||
# drop httpd-conf snippet
|
||||
install -m 0644 -D -p ${WORKDIR}/${BPN}/openstack-dashboard-httpd-2.4.conf ${D}${sysconfdir}/httpd/conf.d/openstack-dashboard.conf
|
||||
install -m 0644 -D -p ${STX_METADATA_PATH}/openstack-dashboard-httpd-2.4.conf ${D}${sysconfdir}/httpd/conf.d/openstack-dashboard.conf
|
||||
install -d -m 755 ${D}${datadir}/openstack-dashboard
|
||||
install -d -m 755 ${D}${sysconfdir}/openstack-dashboard
|
||||
|
||||
# create directory for systemd snippet
|
||||
mkdir -p ${D}${systemd_system_unitdir}/httpd.service.d/
|
||||
cp ${WORKDIR}/${BPN}/python-django-horizon-systemd.conf ${D}${systemd_system_unitdir}/httpd.service.d/openstack-dashboard.conf
|
||||
cp ${STX_METADATA_PATH}/python-django-horizon-systemd.conf ${D}${systemd_system_unitdir}/httpd.service.d/openstack-dashboard.conf
|
||||
|
||||
# Copy everything to /usr/share
|
||||
mv ${D}${libdir}/python2.7/site-packages/openstack_dashboard \
|
||||
@ -88,7 +83,6 @@ do_install_append () {
|
||||
mv ${D}${datadir}/openstack-dashboard/openstack_dashboard/local/local_settings.py.example ${D}${sysconfdir}/openstack-dashboard/local_settings
|
||||
|
||||
mv ${D}${datadir}/openstack-dashboard/openstack_dashboard/conf/*.json ${D}${sysconfdir}/openstack-dashboard
|
||||
cp -a ${S}/openstack_dashboard/conf/cinder_policy.d ${D}${sysconfdir}/openstack-dashboard
|
||||
cp -a ${S}/openstack_dashboard/conf/nova_policy.d ${D}${sysconfdir}/openstack-dashboard
|
||||
|
||||
# copy static files to ${datadir}/openstack-dashboard/static
|
||||
@ -103,7 +97,7 @@ do_install_append () {
|
||||
|
||||
# place logrotate config:
|
||||
mkdir -p ${D}${sysconfdir}/logrotate.d
|
||||
cp -a ${WORKDIR}/${BPN}/python-django-horizon-logrotate.conf ${D}${sysconfdir}/logrotate.d/openstack-dashboard
|
||||
cp -a ${STX_METADATA_PATH}/python-django-horizon-logrotate.conf ${D}${sysconfdir}/logrotate.d/openstack-dashboard
|
||||
|
||||
chown -R root:root ${D}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user