Browse code

Add python_version function to functions-common

This makes it possible to list virtual site-package directories
without statically stating the python version, which is a bit ugly.

Change-Id: I3e7ac39eb43cdc4f656e0c90f3bfb23545722aef

Chris Dent authored on 2015/05/12 22:41:25
Showing 3 changed files
... ...
@@ -1897,6 +1897,12 @@ function maskip {
1897 1897
     echo $subnet
1898 1898
 }
1899 1899
 
1900
+# Return the current python as "python<major>.<minor>"
1901
+function python_version {
1902
+    local python_version=$(python -c 'import sys; print("%s.%s" % sys.version_info[0:2])')
1903
+    echo "python${python_version}"
1904
+}
1905
+
1900 1906
 # Service wrapper to restart services
1901 1907
 # restart_service service-name
1902 1908
 function restart_service {
... ...
@@ -164,7 +164,7 @@ function _config_keystone_apache_wsgi {
164 164
         keystone_auth_port=$KEYSTONE_AUTH_PORT_INT
165 165
     fi
166 166
     if [[ ${USE_VENV} = True ]]; then
167
-        venv_path="python-path=${PROJECT_VENV["keystone"]}/lib/python2.7/site-packages"
167
+        venv_path="python-path=${PROJECT_VENV["keystone"]}/lib/$(python_version)/site-packages"
168 168
     fi
169 169
 
170 170
     # copy proxy vhost and wsgi file
... ...
@@ -259,7 +259,7 @@ function _config_nova_apache_wsgi {
259 259
         nova_keyfile="SSLCertificateKeyFile $NOVA_SSL_KEY"
260 260
     fi
261 261
     if [[ ${USE_VENV} = True ]]; then
262
-        venv_path="python-path=${PROJECT_VENV["nova"]}/lib/python2.7/site-packages"
262
+        venv_path="python-path=${PROJECT_VENV["nova"]}/lib/$(python_version)/site-packages"
263 263
     fi
264 264
 
265 265
     # copy proxy vhost and wsgi helper files