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
diff --git a/lib/ironic b/lib/ironic
index f5a7531..d07073e 100644
--- a/lib/ironic
+++ b/lib/ironic
@@ -66,8 +66,6 @@
 IRONIC_VM_LOG_CONSOLE=${IRONIC_VM_LOG_CONSOLE:-True}
 IRONIC_VM_LOG_DIR=${IRONIC_VM_LOG_DIR:-$IRONIC_DATA_DIR/logs/}
 
-DIB_DIR=${DIB_DIR:-$DEST/diskimage-builder}
-
 # Use DIB to create deploy ramdisk and kernel.
 IRONIC_BUILD_DEPLOY_RAMDISK=`trueorfalse True $IRONIC_BUILD_DEPLOY_RAMDISK`
 # If not use DIB, these files are used as deploy ramdisk/kernel.
@@ -498,7 +496,9 @@
     echo_summary "Creating and uploading baremetal images for ironic"
 
     # install diskimage-builder
-    git_clone $DIB_REPO $DIB_DIR $DIB_BRANCH
+    if [[ $(type -P ramdisk-image-create) == "" ]]; then
+        pip_install diskimage_builder
+    fi
 
     if [ -z "$IRONIC_DEPLOY_KERNEL" -o -z "$IRONIC_DEPLOY_RAMDISK" ]; then
         local IRONIC_DEPLOY_KERNEL_PATH=$TOP_DIR/files/ir-deploy.kernel
@@ -516,7 +516,7 @@
                 if [ "$IRONIC_DEPLOY_RAMDISK" == "agent_ssh" ]; then
                     die $LINENO "Ironic-python-agent build is not yet supported"
                 else
-                    $DIB_DIR/bin/ramdisk-image-create $IRONIC_DEPLOY_FLAVOR \
+                    ramdisk-image-create $IRONIC_DEPLOY_FLAVOR \
                         -o $TOP_DIR/files/ir-deploy
                 fi
             else