Browse code

Introduce get_python_exec_prefix function.

get_python_exec_prefix returns the path to the direcotry where python
executables are installed, that is /usr/bin on Fedora and /usr/local/bin
everywhere else.

It is used to properly locate OpenStack executables.

Fixes: bug #1068386

Change-Id: I228498ebe2762568d00757d065e37377ee2c8fb3

Jakub Ruzicka authored on 2013/01/30 23:35:54
Showing 5 changed files
... ...
@@ -1110,17 +1110,23 @@ function add_user_to_group() {
1110 1110
 }
1111 1111
 
1112 1112
 
1113
+# Get the path to the direcotry where python executables are installed.
1114
+# get_python_exec_prefix
1115
+function get_python_exec_prefix() {
1116
+    if is_fedora; then
1117
+        echo "/usr/bin"
1118
+    else
1119
+        echo "/usr/local/bin"
1120
+    fi
1121
+}
1122
+
1113 1123
 # Get the location of the $module-rootwrap executables, where module is cinder
1114 1124
 # or nova.
1115 1125
 # get_rootwrap_location module
1116 1126
 function get_rootwrap_location() {
1117 1127
     local module=$1
1118 1128
 
1119
-    if is_fedora; then
1120
-        echo "/usr/bin/$module-rootwrap"
1121
-    else
1122
-        echo "/usr/local/bin/$module-rootwrap"
1123
-    fi
1129
+    echo "$(get_python_exec_prefix)/$module-rootwrap"
1124 1130
 }
1125 1131
 
1126 1132
 # Get the path to the pip command.
... ...
@@ -40,7 +40,7 @@ CEILOMETER_AUTH_CACHE_DIR=${CEILOMETER_AUTH_CACHE_DIR:-/var/cache/ceilometer}
40 40
 if [ -d $CEILOMETER_DIR/bin ] ; then
41 41
     CEILOMETER_BIN_DIR=$CEILOMETER_DIR/bin
42 42
 else
43
-    CEILOMETER_BIN_DIR=/usr/local/bin
43
+    CEILOMETER_BIN_DIR=$(get_python_exec_prefix)
44 44
 fi
45 45
 
46 46
 # cleanup_ceilometer() - Remove residual data files, anything left over from previous
... ...
@@ -47,7 +47,7 @@ CINDER_SERVICE_PROTOCOL=${CINDER_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
47 47
 if [[ -d $CINDER_DIR/bin ]]; then
48 48
     CINDER_BIN_DIR=$CINDER_DIR/bin
49 49
 else
50
-    CINDER_BIN_DIR=/usr/local/bin
50
+    CINDER_BIN_DIR=$(get_python_exec_prefix)
51 51
 fi
52 52
 
53 53
 # Name of the lvm volume group to use/create for iscsi volumes
... ...
@@ -44,7 +44,7 @@ GLANCE_POLICY_JSON=$GLANCE_CONF_DIR/policy.json
44 44
 if [[ -d $GLANCE_DIR/bin ]]; then
45 45
     GLANCE_BIN_DIR=$GLANCE_DIR/bin
46 46
 else
47
-    GLANCE_BIN_DIR=/usr/local/bin
47
+    GLANCE_BIN_DIR=$(get_python_exec_prefix)
48 48
 fi
49 49
 
50 50
 # Glance connection info.  Note the port must be specified.
... ...
@@ -49,7 +49,7 @@ NOVA_SERVICE_PROTOCOL=${NOVA_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
49 49
 if [[ -d $NOVA_DIR/bin ]]; then
50 50
     NOVA_BIN_DIR=$NOVA_DIR/bin
51 51
 else
52
-    NOVA_BIN_DIR=/usr/local/bin
52
+    NOVA_BIN_DIR=$(get_python_exec_prefix)
53 53
 fi
54 54
 
55 55
 # Set the paths of certain binaries