pre holiday refactor extrodinare, get the horizon code
over fully into lib/horizon so that all these fixes aren't
scattered through stack.sh
Change-Id: I7f26c5c6708d5693048eb7b1ce792122adbc7351
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,133 @@ |
| 0 |
+# lib/horizon |
|
| 1 |
+# Functions to control the configuration and operation of the horizon service |
|
| 2 |
+# <do not include this template file in ``stack.sh``!> |
|
| 3 |
+ |
|
| 4 |
+# Dependencies: |
|
| 5 |
+# ``functions`` file |
|
| 6 |
+# ``SERVICE_{TENANT_NAME|PASSWORD}`` must be defined
|
|
| 7 |
+# <list other global vars that are assumed to be defined> |
|
| 8 |
+ |
|
| 9 |
+# ``stack.sh`` calls the entry points in this order: |
|
| 10 |
+# |
|
| 11 |
+# install_horizon |
|
| 12 |
+# configure_horizon |
|
| 13 |
+# init_horizon |
|
| 14 |
+# start_horizon |
|
| 15 |
+# stop_horizon |
|
| 16 |
+# cleanup_horizon |
|
| 17 |
+ |
|
| 18 |
+# Save trace setting |
|
| 19 |
+XTRACE=$(set +o | grep xtrace) |
|
| 20 |
+set +o xtrace |
|
| 21 |
+ |
|
| 22 |
+ |
|
| 23 |
+# Defaults |
|
| 24 |
+# -------- |
|
| 25 |
+ |
|
| 26 |
+# <define global variables here that belong to this project> |
|
| 27 |
+ |
|
| 28 |
+# Set up default directories |
|
| 29 |
+HORIZON_DIR=$DEST/horizon |
|
| 30 |
+ |
|
| 31 |
+# Allow overriding the default Apache user and group, default both to |
|
| 32 |
+# current user. |
|
| 33 |
+APACHE_USER=${APACHE_USER:-$USER}
|
|
| 34 |
+APACHE_GROUP=${APACHE_GROUP:-$APACHE_USER}
|
|
| 35 |
+ |
|
| 36 |
+ |
|
| 37 |
+# Entry Points |
|
| 38 |
+# ------------ |
|
| 39 |
+ |
|
| 40 |
+# cleanup_horizon() - Remove residual data files, anything left over from previous |
|
| 41 |
+# runs that a clean run would need to clean up |
|
| 42 |
+function cleanup_horizon() {
|
|
| 43 |
+ # kill instances (nova) |
|
| 44 |
+ # delete image files (glance) |
|
| 45 |
+ # This function intentionally left blank |
|
| 46 |
+ : |
|
| 47 |
+} |
|
| 48 |
+ |
|
| 49 |
+# configure_horizon() - Set config files, create data dirs, etc |
|
| 50 |
+function configure_horizon() {
|
|
| 51 |
+ setup_develop $HORIZON_DIR |
|
| 52 |
+} |
|
| 53 |
+ |
|
| 54 |
+# init_horizon() - Initialize databases, etc. |
|
| 55 |
+function init_horizon() {
|
|
| 56 |
+ # Remove stale session database. |
|
| 57 |
+ rm -f $HORIZON_DIR/openstack_dashboard/local/dashboard_openstack.sqlite3 |
|
| 58 |
+ |
|
| 59 |
+ # ``local_settings.py`` is used to override horizon default settings. |
|
| 60 |
+ local_settings=$HORIZON_DIR/openstack_dashboard/local/local_settings.py |
|
| 61 |
+ cp $FILES/horizon_settings.py $local_settings |
|
| 62 |
+ |
|
| 63 |
+ # Initialize the horizon database (it stores sessions and notices shown to |
|
| 64 |
+ # users). The user system is external (keystone). |
|
| 65 |
+ cd $HORIZON_DIR |
|
| 66 |
+ python manage.py syncdb --noinput |
|
| 67 |
+ cd $TOP_DIR |
|
| 68 |
+ |
|
| 69 |
+ # Create an empty directory that apache uses as docroot |
|
| 70 |
+ sudo mkdir -p $HORIZON_DIR/.blackhole |
|
| 71 |
+ |
|
| 72 |
+ |
|
| 73 |
+ if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 74 |
+ APACHE_NAME=apache2 |
|
| 75 |
+ APACHE_CONF=sites-available/horizon |
|
| 76 |
+ # Clean up the old config name |
|
| 77 |
+ sudo rm -f /etc/apache2/sites-enabled/000-default |
|
| 78 |
+ # Be a good citizen and use the distro tools here |
|
| 79 |
+ sudo touch /etc/$APACHE_NAME/$APACHE_CONF |
|
| 80 |
+ sudo a2ensite horizon |
|
| 81 |
+ else |
|
| 82 |
+ # Install httpd, which is NOPRIME'd |
|
| 83 |
+ APACHE_NAME=httpd |
|
| 84 |
+ APACHE_CONF=conf.d/horizon.conf |
|
| 85 |
+ sudo sed '/^Listen/s/^.*$/Listen 0.0.0.0:80/' -i /etc/httpd/conf/httpd.conf |
|
| 86 |
+ fi |
|
| 87 |
+ |
|
| 88 |
+ # Configure apache to run horizon |
|
| 89 |
+ sudo sh -c "sed -e \" |
|
| 90 |
+ s,%USER%,$APACHE_USER,g; |
|
| 91 |
+ s,%GROUP%,$APACHE_GROUP,g; |
|
| 92 |
+ s,%HORIZON_DIR%,$HORIZON_DIR,g; |
|
| 93 |
+ s,%APACHE_NAME%,$APACHE_NAME,g; |
|
| 94 |
+ s,%DEST%,$DEST,g; |
|
| 95 |
+ \" $FILES/apache-horizon.template >/etc/$APACHE_NAME/$APACHE_CONF" |
|
| 96 |
+ |
|
| 97 |
+} |
|
| 98 |
+ |
|
| 99 |
+# install_horizon() - Collect source and prepare |
|
| 100 |
+function install_horizon() {
|
|
| 101 |
+ # Apache installation, because we mark it NOPRIME |
|
| 102 |
+ if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 103 |
+ # Install apache2, which is NOPRIME'd |
|
| 104 |
+ install_package apache2 libapache2-mod-wsgi |
|
| 105 |
+ else |
|
| 106 |
+ sudo rm -f /etc/httpd/conf.d/000-* |
|
| 107 |
+ install_package httpd mod_wsgi |
|
| 108 |
+ fi |
|
| 109 |
+ |
|
| 110 |
+ # NOTE(sdague) quantal changed the name of the node binary |
|
| 111 |
+ if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 112 |
+ if [[ ! -e "/usr/bin/node" ]]; then |
|
| 113 |
+ install_package nodejs-legacy |
|
| 114 |
+ fi |
|
| 115 |
+ fi |
|
| 116 |
+ |
|
| 117 |
+ git_clone $HORIZON_REPO $HORIZON_DIR $HORIZON_BRANCH $HORIZON_TAG |
|
| 118 |
+} |
|
| 119 |
+ |
|
| 120 |
+# start_horizon() - Start running processes, including screen |
|
| 121 |
+function start_horizon() {
|
|
| 122 |
+ restart_service $APACHE_NAME |
|
| 123 |
+ screen_it horizon "cd $HORIZON_DIR && sudo tail -f /var/log/$APACHE_NAME/horizon_error.log" |
|
| 124 |
+} |
|
| 125 |
+ |
|
| 126 |
+# stop_horizon() - Stop running processes (non-screen) |
|
| 127 |
+function stop_horizon() {
|
|
| 128 |
+ stop_service apache2 |
|
| 129 |
+} |
|
| 130 |
+ |
|
| 131 |
+# Restore xtrace |
|
| 132 |
+$XTRACE |
| ... | ... |
@@ -306,6 +306,7 @@ SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60}
|
| 306 | 306 |
# ================== |
| 307 | 307 |
|
| 308 | 308 |
# Get project function libraries |
| 309 |
+source $TOP_DIR/lib/horizon |
|
| 309 | 310 |
source $TOP_DIR/lib/keystone |
| 310 | 311 |
source $TOP_DIR/lib/glance |
| 311 | 312 |
source $TOP_DIR/lib/nova |
| ... | ... |
@@ -568,15 +569,6 @@ read_password ADMIN_PASSWORD "ENTER A PASSWORD TO USE FOR HORIZON AND KEYSTONE ( |
| 568 | 568 |
SERVICE_TENANT_NAME=${SERVICE_TENANT_NAME:-service}
|
| 569 | 569 |
|
| 570 | 570 |
|
| 571 |
-# Horizon |
|
| 572 |
-# ------- |
|
| 573 |
- |
|
| 574 |
-# Allow overriding the default Apache user and group, default both to |
|
| 575 |
-# current user. |
|
| 576 |
-APACHE_USER=${APACHE_USER:-$USER}
|
|
| 577 |
-APACHE_GROUP=${APACHE_GROUP:-$APACHE_USER}
|
|
| 578 |
- |
|
| 579 |
- |
|
| 580 | 571 |
# Log files |
| 581 | 572 |
# --------- |
| 582 | 573 |
|
| ... | ... |
@@ -756,16 +748,6 @@ if is_service_enabled $DATABASE_BACKENDS; then |
| 756 | 756 |
install_database |
| 757 | 757 |
fi |
| 758 | 758 |
|
| 759 |
-if is_service_enabled horizon; then |
|
| 760 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 761 |
- # Install apache2, which is NOPRIME'd |
|
| 762 |
- install_package apache2 libapache2-mod-wsgi |
|
| 763 |
- else |
|
| 764 |
- sudo rm -f /etc/httpd/conf.d/000-* |
|
| 765 |
- install_package httpd mod_wsgi |
|
| 766 |
- fi |
|
| 767 |
-fi |
|
| 768 |
- |
|
| 769 | 759 |
if is_service_enabled q-agt; then |
| 770 | 760 |
if is_quantum_ovs_base_plugin "$Q_PLUGIN"; then |
| 771 | 761 |
# Install deps |
| ... | ... |
@@ -840,8 +822,8 @@ if is_service_enabled n-novnc; then |
| 840 | 840 |
git_clone $NOVNC_REPO $NOVNC_DIR $NOVNC_BRANCH |
| 841 | 841 |
fi |
| 842 | 842 |
if is_service_enabled horizon; then |
| 843 |
- # django powered web control panel for openstack |
|
| 844 |
- git_clone $HORIZON_REPO $HORIZON_DIR $HORIZON_BRANCH $HORIZON_TAG |
|
| 843 |
+ # dashboard |
|
| 844 |
+ install_horizon |
|
| 845 | 845 |
fi |
| 846 | 846 |
if is_service_enabled quantum; then |
| 847 | 847 |
git_clone $QUANTUM_CLIENT_REPO $QUANTUM_CLIENT_DIR $QUANTUM_CLIENT_BRANCH |
| ... | ... |
@@ -899,7 +881,7 @@ if is_service_enabled nova; then |
| 899 | 899 |
configure_nova |
| 900 | 900 |
fi |
| 901 | 901 |
if is_service_enabled horizon; then |
| 902 |
- setup_develop $HORIZON_DIR |
|
| 902 |
+ configure_horizon |
|
| 903 | 903 |
fi |
| 904 | 904 |
if is_service_enabled quantum; then |
| 905 | 905 |
setup_develop $QUANTUM_CLIENT_DIR |
| ... | ... |
@@ -1035,48 +1017,8 @@ fi |
| 1035 | 1035 |
|
| 1036 | 1036 |
if is_service_enabled horizon; then |
| 1037 | 1037 |
echo_summary "Configuring and starting Horizon" |
| 1038 |
- |
|
| 1039 |
- # Remove stale session database. |
|
| 1040 |
- rm -f $HORIZON_DIR/openstack_dashboard/local/dashboard_openstack.sqlite3 |
|
| 1041 |
- |
|
| 1042 |
- # ``local_settings.py`` is used to override horizon default settings. |
|
| 1043 |
- local_settings=$HORIZON_DIR/openstack_dashboard/local/local_settings.py |
|
| 1044 |
- cp $FILES/horizon_settings.py $local_settings |
|
| 1045 |
- |
|
| 1046 |
- # Initialize the horizon database (it stores sessions and notices shown to |
|
| 1047 |
- # users). The user system is external (keystone). |
|
| 1048 |
- cd $HORIZON_DIR |
|
| 1049 |
- python manage.py syncdb --noinput |
|
| 1050 |
- cd $TOP_DIR |
|
| 1051 |
- |
|
| 1052 |
- # Create an empty directory that apache uses as docroot |
|
| 1053 |
- sudo mkdir -p $HORIZON_DIR/.blackhole |
|
| 1054 |
- |
|
| 1055 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 1056 |
- APACHE_NAME=apache2 |
|
| 1057 |
- APACHE_CONF=sites-available/horizon |
|
| 1058 |
- # Clean up the old config name |
|
| 1059 |
- sudo rm -f /etc/apache2/sites-enabled/000-default |
|
| 1060 |
- # Be a good citizen and use the distro tools here |
|
| 1061 |
- sudo touch /etc/$APACHE_NAME/$APACHE_CONF |
|
| 1062 |
- sudo a2ensite horizon |
|
| 1063 |
- else |
|
| 1064 |
- # Install httpd, which is NOPRIME'd |
|
| 1065 |
- APACHE_NAME=httpd |
|
| 1066 |
- APACHE_CONF=conf.d/horizon.conf |
|
| 1067 |
- sudo sed '/^Listen/s/^.*$/Listen 0.0.0.0:80/' -i /etc/httpd/conf/httpd.conf |
|
| 1068 |
- fi |
|
| 1069 |
- |
|
| 1070 |
- # Configure apache to run horizon |
|
| 1071 |
- sudo sh -c "sed -e \" |
|
| 1072 |
- s,%USER%,$APACHE_USER,g; |
|
| 1073 |
- s,%GROUP%,$APACHE_GROUP,g; |
|
| 1074 |
- s,%HORIZON_DIR%,$HORIZON_DIR,g; |
|
| 1075 |
- s,%APACHE_NAME%,$APACHE_NAME,g; |
|
| 1076 |
- s,%DEST%,$DEST,g; |
|
| 1077 |
- \" $FILES/apache-horizon.template >/etc/$APACHE_NAME/$APACHE_CONF" |
|
| 1078 |
- |
|
| 1079 |
- restart_service $APACHE_NAME |
|
| 1038 |
+ init_horizon |
|
| 1039 |
+ start_horizon |
|
| 1080 | 1040 |
fi |
| 1081 | 1041 |
|
| 1082 | 1042 |
|
| ... | ... |
@@ -1958,7 +1900,7 @@ if is_service_enabled ceilometer; then |
| 1958 | 1958 |
echo_summary "Starting Ceilometer" |
| 1959 | 1959 |
start_ceilometer |
| 1960 | 1960 |
fi |
| 1961 |
-screen_it horizon "cd $HORIZON_DIR && sudo tail -f /var/log/$APACHE_NAME/horizon_error.log" |
|
| 1961 |
+ |
|
| 1962 | 1962 |
screen_it swift "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-proxy-server ${SWIFT_CONFIG_DIR}/proxy-server.conf -v"
|
| 1963 | 1963 |
|
| 1964 | 1964 |
# Starting the nova-objectstore only if swift3 service is not enabled. |
| ... | ... |
@@ -26,6 +26,7 @@ DATA_DIR=${DATA_DIR:-${DEST}/data}
|
| 26 | 26 |
|
| 27 | 27 |
# Get project function libraries |
| 28 | 28 |
source $TOP_DIR/lib/cinder |
| 29 |
+source $TOP_DIR/lib/horizon |
|
| 29 | 30 |
|
| 30 | 31 |
# Determine what system we are running on. This provides ``os_VENDOR``, |
| 31 | 32 |
# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME`` |
| ... | ... |
@@ -51,7 +52,7 @@ fi |
| 51 | 51 |
|
| 52 | 52 |
# Apache has the WSGI processes |
| 53 | 53 |
if is_service_enabled horizon; then |
| 54 |
- stop_service apache2 |
|
| 54 |
+ stop_horizon |
|
| 55 | 55 |
fi |
| 56 | 56 |
|
| 57 | 57 |
SCSI_PERSIST_DIR=$CINDER_STATE_PATH/volumes/* |