summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Redondo Marchena <francisco.marchena@codethink.co.uk>2015-02-24 12:30:08 +0000
committerFrancisco Redondo Marchena <francisco.marchena@codethink.co.uk>2015-02-27 11:14:57 +0000
commit8a2ec263340dc8dd797241536016096ff225ceb3 (patch)
tree4df310c24c54360c5ac47b6327249ba7aeecdb22
parenta57e13db3d820795d6ad4cbdc3aab8f96619d703 (diff)
downloaddefinitions-baserock/franred/create-statics-for-horizon.tar.gz
Collect statics for horizon and move install commands to the chunkbaserock/franred/create-statics-for-horizon
Collecting the static files (css, js, png, ...) for horizon, compressing them and storing them in a folder accessible by horizon, fixes the problem when some css are not found and improves loading and navigating the pages.
-rw-r--r--openstack/etc/horizon/apache-horizon.conf6
-rw-r--r--openstack/manifest1
-rw-r--r--openstack/usr/share/openstack/openstack-horizon-setup27
-rw-r--r--strata/openstack-services.morph2
-rw-r--r--strata/openstack-services/horizon.morph59
5 files changed, 66 insertions, 29 deletions
diff --git a/openstack/etc/horizon/apache-horizon.conf b/openstack/etc/horizon/apache-horizon.conf
index e51fbd17..1b0b3fe3 100644
--- a/openstack/etc/horizon/apache-horizon.conf
+++ b/openstack/etc/horizon/apache-horizon.conf
@@ -1,6 +1,6 @@
<VirtualHost *:80>
- WSGIScriptAlias /horizon /var/lib/horizon/django.wsgi
- WSGIDaemonProcess horizon user=horizon group=horizon processes=3 threads=10 home=/var/lib/horizon display-name=horzion
+ WSGIScriptAlias /horizon /var/lib/horizon/openstack_dashboard/django.wsgi
+ WSGIDaemonProcess horizon user=horizon group=horizon processes=3 threads=10 home=/var/lib/horizon display-name=horizon
WSGIApplicationGroup %{GLOBAL}
SetEnv APACHE_RUN_USER apache
@@ -10,7 +10,7 @@
DocumentRoot /var/lib/horizon/.blackhole
Alias /static /var/lib/horizon/openstack_dashboard/static
- <Directory "/var/lib/horizon" >
+ <Directory /var/lib/horizon/openstack_dashboard >
Options Indexes FollowSymLinks MultiViews
AllowOverride None
# Apache 2.4 uses mod_authz_host for access control now (instead of
diff --git a/openstack/manifest b/openstack/manifest
index b19142b5..8c7b9915 100644
--- a/openstack/manifest
+++ b/openstack/manifest
@@ -152,7 +152,6 @@
0100644 0 0 /etc/systemd/system/apache-httpd.service
0040755 0 0 /etc/horizon
0040755 0 0 /etc/horizon/openstack_dashboard
-0040755 0 0 /var/lib/horizon
0100644 0 0 /etc/systemd/system/openstack-horizon-setup.service
0100755 0 0 /usr/share/openstack/openstack-horizon-setup
0100644 0 0 /etc/horizon/apache-horizon.conf
diff --git a/openstack/usr/share/openstack/openstack-horizon-setup b/openstack/usr/share/openstack/openstack-horizon-setup
index c8b15125..af944477 100644
--- a/openstack/usr/share/openstack/openstack-horizon-setup
+++ b/openstack/usr/share/openstack/openstack-horizon-setup
@@ -22,39 +22,16 @@ if [ -f /var/openstack/horizon-setup ]; then
fi
# Create required system users and groups
-mkdir -p /var/lib/horizon
getent group horizon >/dev/null || groupadd -r --gid 167 horizon
getent passwd neutron >/dev/null || \
useradd --uid 167 -r -g horizon -d /var/lib/horizon -s /sbin/nologin \
-c "Horizon user" horizon
-# Work around to make django.wsgi working with horizon
-# See: https://bugs.launchpad.net/osprofiler/+bug/1361235
-# and: https://git.openstack.org/cgit/openstack/tripleo-image-elements/commit/?id=41c9a1dfad23f8aee366afb6a0b20a6c57ec8f79
-sed -i "s|'../..'|os.path.realpath('../..')|" \
- /usr/lib/python2.7/site-packages/openstack_dashboard/wsgi/django.wsgi
-
-# And link this django.wsgi file to the horizon home directory
-ln -sf /usr/lib/python2.7/site-packages/openstack_dashboard/wsgi/django.wsgi \
- /var/lib/horizon/django.wsgi
-
-# Link Openstack local_settings where openstack_dashboard is installed.
-ln -sf /etc/horizon/openstack_dashboard/local_settings.py \
- /usr/lib/python2.7/site-packages/openstack_dashboard/local/local_settings.py
-
-# Create the static directory (STATIC_ROOT) used in local_settings.py to keep
-# the static objects like css files.
-mkdir -p /var/lib/horizon/openstack_dashboard/static
-
-# Create the horizon document root for apache configuration
-mkdir -p /var/lib/horizon/.blackhole
+chown -R horizon:horizon /var/lib/horizon
# Link horizon configuration file for apache to the directory where our apache load
# configurations files
-ln -sf /etc/horizon/apache-horizon.conf \
- /etc/httpd/conf.d/apache-horizon.conf
-
-chown -R horizon:horizon /var/lib/horizon
+ln -sf /etc/horizon/apache-horizon.conf /etc/httpd/conf.d/apache-horizon.conf
install -D -m 644 /proc/self/fd/0 <<'EOF' /var/openstack/horizon-setup
Horizon setup: success
diff --git a/strata/openstack-services.morph b/strata/openstack-services.morph
index 8f3bb6f0..8f610934 100644
--- a/strata/openstack-services.morph
+++ b/strata/openstack-services.morph
@@ -876,8 +876,10 @@ chunks:
unpetrify-ref: 1.1.8
build-depends: []
- name: horizon
+ morph: strata/openstack-services/horizon.morph
repo: upstream:openstack/horizon
ref: 3d9a31e2a05288e9a48a51eb4fe693c42e92aac7
unpetrify-ref: 2014.2.1
build-depends:
- django-openstack-auth
+ - lockfile
diff --git a/strata/openstack-services/horizon.morph b/strata/openstack-services/horizon.morph
new file mode 100644
index 00000000..ae6399b1
--- /dev/null
+++ b/strata/openstack-services/horizon.morph
@@ -0,0 +1,59 @@
+name: horizon
+kind: chunk
+configure-commands:
+# Remove unnecessary .mo files they will be generated
+# later during package build.
+- find . -name "django*.mo" -exec rm -f '{}' \;
+# Set COMPRESS_OFFLINE=True
+- |
+ sed -i 's:COMPRESS_OFFLINE.=.False:COMPRESS_OFFLINE = True:' \
+ openstack_dashboard/settings.py
+build-commands:
+# Compile message strings
+- cd horizon && django-admin.py compilemessages && cd ..
+- cd openstack_dashboard && django-admin.py compilemessages && cd ..
+- python setup.py build
+post-build-commands:
+# Use the local_settings.py example to compile and compress the css, js, etc files.
+# This is a hack to make SECRET_KEY work.
+- |
+ cp openstack_dashboard/local/local_settings.py.example \
+ openstack_dashboard/local/local_settings.py
+# Collect the static files and compress them.
+- python manage.py collectstatic --noinput
+- python manage.py compress --force
+install-commands:
+# Undo hack
+- |
+ cp openstack_dashboard/local/local_settings.py.example \
+ openstack_dashboard/local/local_settings.py
+# Install horizon
+- python setup.py install -O1 --skip-build --prefix "$PREFIX" --root "$DESTDIR"
+post-install-commands:
+# Remove unnecessary .po files
+- find "$DESTDIR" -name django.po -exec rm '{}' \;
+- find "$DESTDIR" -name djangojs.po -exec rm '{}' \;
+# Link Openstack local_settings where openstack_dashboard is installed.
+- mkdir -p "$DESTDIR"/var/lib/horizon/openstack_dashboard/local
+- |
+ ln -sf /etc/horizon/openstack_dashboard/local_settings.py \
+ "$DESTDIR$PREFIX"/lib/python2.7/site-packages/openstack_dashboard/local/local_settings.py
+# Create the static directory (STATIC_ROOT) used in local_settings.py to keep
+# the static objects like css files.
+- mkdir -p "$DESTDIR"/var/lib/horizon/openstack_dashboard/static
+# Copy the compressed static files to horizon.
+- cp -a openstack_dashboard/static/* "$DESTDIR"/var/lib/horizon/openstack_dashboard/static
+- cp -a horizon/static/* "$DESTDIR"/var/lib/horizon/openstack_dashboard/static
+- cp -a static/* "$DESTDIR"/var/lib/horizon/openstack_dashboard/static
+# Work around to make django.wsgi working with horizon
+# See: https://bugs.launchpad.net/osprofiler/+bug/1361235
+# and: https://git.openstack.org/cgit/openstack/tripleo-image-elements/commit/?id=41c9a1dfad23f8aee366afb6a0b20a6c57ec8f79
+- |
+ sed -i "s|'../..'|os.path.realpath('../..')|" \
+ "$DESTDIR$PREFIX"/lib/python2.7/site-packages/openstack_dashboard/wsgi/django.wsgi
+# And link this django.wsgi file to the horizon home directory
+- |
+ ln -sf "$PREFIX"/lib/python2.7/site-packages/openstack_dashboard/wsgi/django.wsgi \
+ "$DESTDIR"/var/lib/horizon/openstack_dashboard/django.wsgi
+# Create the horizon document root for apache configuration
+- mkdir -p "$DESTDIR"/var/lib/horizon/.blackhole