From 3a2c86aabfa985dbdc998f02201649f49f3adab7 Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Tue, 12 May 2015 13:41:25 +0000 Subject: [PATCH] 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 --- functions-common | 6 ++++++ lib/keystone | 2 +- lib/nova | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/functions-common b/functions-common index 4d07c03cce..d28ef85cc1 100644 --- a/functions-common +++ b/functions-common @@ -1897,6 +1897,12 @@ function maskip { echo $subnet } +# Return the current python as "python." +function python_version { + local python_version=$(python -c 'import sys; print("%s.%s" % sys.version_info[0:2])') + echo "python${python_version}" +} + # Service wrapper to restart services # restart_service service-name function restart_service { diff --git a/lib/keystone b/lib/keystone index 997bb14967..0f369af71d 100644 --- a/lib/keystone +++ b/lib/keystone @@ -164,7 +164,7 @@ function _config_keystone_apache_wsgi { keystone_auth_port=$KEYSTONE_AUTH_PORT_INT fi if [[ ${USE_VENV} = True ]]; then - venv_path="python-path=${PROJECT_VENV["keystone"]}/lib/python2.7/site-packages" + venv_path="python-path=${PROJECT_VENV["keystone"]}/lib/$(python_version)/site-packages" fi # copy proxy vhost and wsgi file diff --git a/lib/nova b/lib/nova index 6ac9da3b41..7d2145b170 100644 --- a/lib/nova +++ b/lib/nova @@ -259,7 +259,7 @@ function _config_nova_apache_wsgi { nova_keyfile="SSLCertificateKeyFile $NOVA_SSL_KEY" fi if [[ ${USE_VENV} = True ]]; then - venv_path="python-path=${PROJECT_VENV["nova"]}/lib/python2.7/site-packages" + venv_path="python-path=${PROJECT_VENV["nova"]}/lib/$(python_version)/site-packages" fi # copy proxy vhost and wsgi helper files