Browse code

Ironic and baremetal install diskimage-builder with pip

This change installs diskimage-builder with pip instead
of from git, and only if the executable ramdisk-image-create
isn't already installed.

This allows the ironic and baremetal to consume the latest
release of diskimage-builder by default, and gives the option of
defining version constraints for which version to install.

If the dib service is enabled (which it isn't by default) then
diskimage-builder will already be installed from git and will
not be re-installed for ironic and diskimage-builder.

Change-Id: Ic6613a11e2c4fb7a1261b81cdc2cf958515e60cd

Steve Baker authored on 2014/05/05 13:06:47
Showing 2 changed files
... ...
@@ -127,10 +127,6 @@ BM_FLAVOR_ID=${BM_FLAVOR_ID:-11}
127 127
 BM_FLAVOR_ARCH=${BM_FLAVOR_ARCH:-$BM_CPU_ARCH}
128 128
 
129 129
 
130
-# Below this, we set some path and filenames.
131
-# Defaults are probably sufficient.
132
-DIB_DIR=${DIB_DIR:-$DEST/diskimage-builder}
133
-
134 130
 # Use DIB to create deploy ramdisk and kernel.
135 131
 BM_BUILD_DEPLOY_RAMDISK=`trueorfalse True $BM_BUILD_DEPLOY_RAMDISK`
136 132
 # If not use DIB, these files are used as deploy ramdisk/kernel.
... ...
@@ -165,8 +161,9 @@ function is_baremetal {
165 165
 # Install diskimage-builder and shell-in-a-box
166 166
 # so that we can build the deployment kernel & ramdisk
167 167
 function prepare_baremetal_toolchain {
168
-    git_clone $DIB_REPO $DIB_DIR $DIB_BUILD_BRANCH
169
-
168
+    if [[ $(type -P ramdisk-image-create) == "" ]]; then
169
+        pip_install diskimage_builder
170
+    fi
170 171
     local shellinabox_basename=$(basename $BM_SHELL_IN_A_BOX)
171 172
     if [[ ! -e $DEST/$shellinabox_basename ]]; then
172 173
         cd $DEST
... ...
@@ -223,7 +220,7 @@ function upload_baremetal_deploy {
223 223
         BM_DEPLOY_KERNEL=bm-deploy.kernel
224 224
         BM_DEPLOY_RAMDISK=bm-deploy.initramfs
225 225
         if [ ! -e "$TOP_DIR/files/$BM_DEPLOY_KERNEL" -o ! -e "$TOP_DIR/files/$BM_DEPLOY_RAMDISK" ]; then
226
-            $DIB_DIR/bin/ramdisk-image-create $BM_DEPLOY_FLAVOR \
226
+            ramdisk-image-create $BM_DEPLOY_FLAVOR \
227 227
                 -o $TOP_DIR/files/bm-deploy
228 228
         fi
229 229
     fi
... ...
@@ -271,7 +268,7 @@ function extract_and_upload_k_and_r_from_image {
271 271
     image_name=$(basename "$file" ".qcow2")
272 272
 
273 273
     # this call returns the file names as "$kernel,$ramdisk"
274
-    out=$($DIB_DIR/bin/disk-image-get-kernel \
274
+    out=$(disk-image-get-kernel \
275 275
             -x -d $TOP_DIR/files -o bm-deploy -i $file)
276 276
     if [ $? -ne 0 ]; then
277 277
         die $LINENO "Failed to get kernel and ramdisk from $file"
... ...
@@ -66,8 +66,6 @@ IRONIC_AUTHORIZED_KEYS_FILE=${IRONIC_AUTHORIZED_KEYS_FILE:-$HOME/.ssh/authorized
66 66
 IRONIC_VM_LOG_CONSOLE=${IRONIC_VM_LOG_CONSOLE:-True}
67 67
 IRONIC_VM_LOG_DIR=${IRONIC_VM_LOG_DIR:-$IRONIC_DATA_DIR/logs/}
68 68
 
69
-DIB_DIR=${DIB_DIR:-$DEST/diskimage-builder}
70
-
71 69
 # Use DIB to create deploy ramdisk and kernel.
72 70
 IRONIC_BUILD_DEPLOY_RAMDISK=`trueorfalse True $IRONIC_BUILD_DEPLOY_RAMDISK`
73 71
 # If not use DIB, these files are used as deploy ramdisk/kernel.
... ...
@@ -498,7 +496,9 @@ function upload_baremetal_ironic_deploy {
498 498
     echo_summary "Creating and uploading baremetal images for ironic"
499 499
 
500 500
     # install diskimage-builder
501
-    git_clone $DIB_REPO $DIB_DIR $DIB_BRANCH
501
+    if [[ $(type -P ramdisk-image-create) == "" ]]; then
502
+        pip_install diskimage_builder
503
+    fi
502 504
 
503 505
     if [ -z "$IRONIC_DEPLOY_KERNEL" -o -z "$IRONIC_DEPLOY_RAMDISK" ]; then
504 506
         local IRONIC_DEPLOY_KERNEL_PATH=$TOP_DIR/files/ir-deploy.kernel
... ...
@@ -516,7 +516,7 @@ function upload_baremetal_ironic_deploy {
516 516
                 if [ "$IRONIC_DEPLOY_RAMDISK" == "agent_ssh" ]; then
517 517
                     die $LINENO "Ironic-python-agent build is not yet supported"
518 518
                 else
519
-                    $DIB_DIR/bin/ramdisk-image-create $IRONIC_DEPLOY_FLAVOR \
519
+                    ramdisk-image-create $IRONIC_DEPLOY_FLAVOR \
520 520
                         -o $TOP_DIR/files/ir-deploy
521 521
                 fi
522 522
             else