A service to install diskimage-builder

Enabling service 'dib' will install the following repos:
* diskimage-builder
* tripleo-image-elements
* os-collect-config
* os-refresh-config
* os-apply-config

These repos are already pre-fetched in devstack-gate.

This will facilitate gating on changes in these projects by building
a custom image then running the heat-slow job against that image.

diskimage_builder is pip installed from the current git checkout
if the dib service is enabled. This allows devstack gating on
diskimage-builder changes while also allowing diskimage-builder to
be installed from releases for other scenarios (for example, ironic).

Change-Id: Ia911cdee86f5b2e2ba1557e5aa8bf392b92ef555
diff --git a/lib/dib b/lib/dib
new file mode 100644
index 0000000..25558e9
--- /dev/null
+++ b/lib/dib
@@ -0,0 +1,51 @@
+# lib/dib
+# Install and build images with **diskimage-builder**
+
+# Dependencies:
+#
+# - functions
+# - DEST, DATA_DIR must be defined
+
+# stack.sh
+# ---------
+# - install_dib
+
+# Save trace setting
+XTRACE=$(set +o | grep xtrace)
+set +o xtrace
+
+# Defaults
+# --------
+
+# set up default directories
+DIB_DIR=$DEST/diskimage-builder
+TIE_DIR=$DEST/tripleo-image-elements
+DIB_IMAGE_CACHE=$DATA_DIR/diskimage-builder/image-create
+OCC_DIR=$DEST/os-collect-config
+ORC_DIR=$DEST/os-refresh-config
+OAC_DIR=$DEST/os-apply-config
+
+# Functions
+# ---------
+
+# install_dib() - Collect source and prepare
+function install_dib {
+    git_clone $DIB_REPO $DIB_DIR $DIB_BRANCH
+    pushd $DIB_DIR
+    pip_install ./
+    popd
+
+    git_clone $TIE_REPO $TIE_DIR $TIE_BRANCH
+    git_clone $OCC_REPO $OCC_DIR $OCC_BRANCH
+    git_clone $ORC_REPO $ORC_DIR $ORC_BRANCH
+    git_clone $OAC_REPO $OAC_DIR $OAC_BRANCH
+    mkdir -p $DIB_IMAGE_CACHE
+}
+
+# Restore xtrace
+$XTRACE
+
+# Tell emacs to use shell-script-mode
+## Local variables:
+## mode: shell-script
+## End: