Browse code

Merge "Install Keystone into its own venv"

Jenkins authored on 2015/03/27 05:35:01
Showing 2 changed files
... ...
@@ -2,7 +2,7 @@ Listen %PUBLICPORT%
2 2
 Listen %ADMINPORT%
3 3
 
4 4
 <VirtualHost *:%PUBLICPORT%>
5
-    WSGIDaemonProcess keystone-public processes=5 threads=1 user=%USER% display-name=%{GROUP}
5
+    WSGIDaemonProcess keystone-public processes=5 threads=1 user=%USER% display-name=%{GROUP} %VIRTUALENV%
6 6
     WSGIProcessGroup keystone-public
7 7
     WSGIScriptAlias / %PUBLICWSGI%
8 8
     WSGIApplicationGroup %{GLOBAL}
... ...
@@ -18,7 +18,7 @@ Listen %ADMINPORT%
18 18
 </VirtualHost>
19 19
 
20 20
 <VirtualHost *:%ADMINPORT%>
21
-    WSGIDaemonProcess keystone-admin processes=5 threads=1 user=%USER% display-name=%{GROUP}
21
+    WSGIDaemonProcess keystone-admin processes=5 threads=1 user=%USER% display-name=%{GROUP} %VIRTUALENV%
22 22
     WSGIProcessGroup keystone-admin
23 23
     WSGIScriptAlias / %ADMINWSGI%
24 24
     WSGIApplicationGroup %{GLOBAL}
... ...
@@ -37,8 +37,16 @@ set +o xtrace
37 37
 # Set up default directories
38 38
 GITDIR["python-keystoneclient"]=$DEST/python-keystoneclient
39 39
 GITDIR["keystonemiddleware"]=$DEST/keystonemiddleware
40
-
41 40
 KEYSTONE_DIR=$DEST/keystone
41
+
42
+# Keystone virtual environment
43
+if [[ ${USE_VENV} = True ]]; then
44
+    PROJECT_VENV["keystone"]=${KEYSTONE_DIR}.venv
45
+    KEYSTONE_BIN_DIR=${PROJECT_VENV["keystone"]}/bin
46
+else
47
+    KEYSTONE_BIN_DIR=$(get_python_exec_prefix)
48
+fi
49
+
42 50
 KEYSTONE_CONF_DIR=${KEYSTONE_CONF_DIR:-/etc/keystone}
43 51
 KEYSTONE_CONF=$KEYSTONE_CONF_DIR/keystone.conf
44 52
 KEYSTONE_PASTE_INI=${KEYSTONE_PASTE_INI:-$KEYSTONE_CONF_DIR/keystone-paste.ini}
... ...
@@ -144,6 +152,7 @@ function _config_keystone_apache_wsgi {
144 144
     local keystone_keyfile=""
145 145
     local keystone_service_port=$KEYSTONE_SERVICE_PORT
146 146
     local keystone_auth_port=$KEYSTONE_AUTH_PORT
147
+    local venv_path=""
147 148
 
148 149
     if is_ssl_enabled_service key; then
149 150
         keystone_ssl="SSLEngine On"
... ...
@@ -154,6 +163,9 @@ function _config_keystone_apache_wsgi {
154 154
         keystone_service_port=$KEYSTONE_SERVICE_PORT_INT
155 155
         keystone_auth_port=$KEYSTONE_AUTH_PORT_INT
156 156
     fi
157
+    if [[ ${USE_VENV} = True ]]; then
158
+        venv_path="python-path=${PROJECT_VENV["keystone"]}/lib/python2.7/site-packages"
159
+    fi
157 160
 
158 161
     # copy proxy vhost and wsgi file
159 162
     sudo cp $KEYSTONE_DIR/httpd/keystone.py $KEYSTONE_WSGI_DIR/main
... ...
@@ -169,7 +181,8 @@ function _config_keystone_apache_wsgi {
169 169
         s|%SSLENGINE%|$keystone_ssl|g;
170 170
         s|%SSLCERTFILE%|$keystone_certfile|g;
171 171
         s|%SSLKEYFILE%|$keystone_keyfile|g;
172
-        s|%USER%|$STACK_USER|g
172
+        s|%USER%|$STACK_USER|g;
173
+        s|%VIRTUALENV%|$venv_path|g
173 174
     " -i $keystone_apache_conf
174 175
 }
175 176
 
... ...
@@ -460,20 +473,20 @@ function init_keystone {
460 460
     recreate_database keystone
461 461
 
462 462
     # Initialize keystone database
463
-    $KEYSTONE_DIR/bin/keystone-manage db_sync
463
+    $KEYSTONE_BIN_DIR/keystone-manage db_sync
464 464
 
465 465
     local extension_value
466 466
     for extension_value in ${KEYSTONE_EXTENSIONS//,/ }; do
467 467
         if [[ -z "${extension_value}" ]]; then
468 468
             continue
469 469
         fi
470
-        $KEYSTONE_DIR/bin/keystone-manage db_sync --extension "${extension_value}"
470
+        $KEYSTONE_BIN_DIR/keystone-manage db_sync --extension "${extension_value}"
471 471
     done
472 472
 
473 473
     if [[ "$KEYSTONE_TOKEN_FORMAT" != "uuid" ]]; then
474 474
         # Set up certificates
475 475
         rm -rf $KEYSTONE_CONF_DIR/ssl
476
-        $KEYSTONE_DIR/bin/keystone-manage pki_setup
476
+        $KEYSTONE_BIN_DIR/keystone-manage pki_setup
477 477
 
478 478
         # Create cache dir
479 479
         sudo install -d -o $STACK_USER $KEYSTONE_AUTH_CACHE_DIR
... ...
@@ -492,9 +505,14 @@ function install_keystoneclient {
492 492
 
493 493
 # install_keystonemiddleware() - Collect source and prepare
494 494
 function install_keystonemiddleware {
495
+    # install_keystonemiddleware() is called when keystonemiddleware is needed
496
+    # to provide an opportunity to install it from the source repo
495 497
     if use_library_from_git "keystonemiddleware"; then
496 498
         git_clone_by_name "keystonemiddleware"
497 499
         setup_dev_lib "keystonemiddleware"
500
+    else
501
+        # When not installing from repo, keystonemiddleware is still needed...
502
+        pip_install keystonemiddleware
498 503
     fi
499 504
 }
500 505
 
... ...
@@ -542,7 +560,7 @@ function start_keystone {
542 542
         tail_log key-access /var/log/$APACHE_NAME/keystone_access.log
543 543
     else
544 544
         # Start Keystone in a screen window
545
-        run_process key "$KEYSTONE_DIR/bin/keystone-all --config-file $KEYSTONE_CONF"
545
+        run_process key "$KEYSTONE_BIN_DIR/keystone-all --config-file $KEYSTONE_CONF"
546 546
     fi
547 547
 
548 548
     echo "Waiting for keystone to start..."