Browse code

Support oslo-rootwrap in lib/cinder

Make lib/cinder support both cinder-rootwrap (current case) and
oslo-rootwrap (future case) to handle the Cinder transition towards
oslo-rootwrap usage peacefully.

Related blueprint:
https://blueprints.launchpad.net/cinder/+spec/cinder-oslo-rootwrap

Change-Id: I663986304bd74cb6d72d51c553540fb5f9db1d1d

Thierry Carrez authored on 2013/12/13 23:20:26
Showing 1 changed files
... ...
@@ -174,6 +174,12 @@ function configure_cinder() {
174 174
 
175 175
     # Set the paths of certain binaries
176 176
     CINDER_ROOTWRAP=$(get_rootwrap_location cinder)
177
+    if [[ ! -x $CINDER_ROOTWRAP ]]; then
178
+        CINDER_ROOTWRAP=$(get_rootwrap_location oslo)
179
+        if [[ ! -x $CINDER_ROOTWRAP ]]; then
180
+            die $LINENO "No suitable rootwrap found."
181
+        fi
182
+    fi
177 183
 
178 184
     # If Cinder ships the new rootwrap filters files, deploy them
179 185
     # (owned by root) and add a parameter to $CINDER_ROOTWRAP
... ...
@@ -189,11 +195,16 @@ function configure_cinder() {
189 189
         sudo chown -R root:root $CINDER_CONF_DIR/rootwrap.d
190 190
         sudo chmod 644 $CINDER_CONF_DIR/rootwrap.d/*
191 191
         # Set up rootwrap.conf, pointing to /etc/cinder/rootwrap.d
192
-        sudo cp $CINDER_DIR/etc/cinder/rootwrap.conf $CINDER_CONF_DIR/
192
+        if [[ -f $CINDER_DIR/etc/cinder/rootwrap.conf ]]; then
193
+            sudo cp $CINDER_DIR/etc/cinder/rootwrap.conf $CINDER_CONF_DIR/
194
+        else
195
+            # rootwrap.conf is no longer shipped in Cinder itself
196
+            echo "filters_path=" | sudo tee $CINDER_CONF_DIR/rootwrap.conf > /dev/null
197
+        fi
193 198
         sudo sed -e "s:^filters_path=.*$:filters_path=$CINDER_CONF_DIR/rootwrap.d:" -i $CINDER_CONF_DIR/rootwrap.conf
194 199
         sudo chown root:root $CINDER_CONF_DIR/rootwrap.conf
195 200
         sudo chmod 0644 $CINDER_CONF_DIR/rootwrap.conf
196
-        # Specify rootwrap.conf as first parameter to cinder-rootwrap
201
+        # Specify rootwrap.conf as first parameter to rootwrap
197 202
         CINDER_ROOTWRAP="$CINDER_ROOTWRAP $CINDER_CONF_DIR/rootwrap.conf"
198 203
         ROOTWRAP_CINDER_SUDOER_CMD="$CINDER_ROOTWRAP *"
199 204
     fi