Generate heat images for tempest tests

This requires HEAT_CREATE_TEST_IMAGE to be set for any images
to be created.

If the file (files/fedora-vm-heat-cfntools-tempest.qcow2) already
exists then disk-image-create will not be called, and the existing
image file will be registered with glance. This is most likely to
happen in the following scenarios:
- a second run of stack.sh
- the image has been pre-built elsewhere (such as during devstack-gate
  image building)
Change-Id: I276573a20927e72f2cb68784f655c1ba1913ae8a
diff --git a/lib/heat b/lib/heat
index 1b715f2..92b4e50 100644
--- a/lib/heat
+++ b/lib/heat
@@ -197,6 +197,21 @@
     done
 }
 
+function disk_image_create {
+    local elements_path=$1
+    local elements=$2
+    local arch=$3
+    local output=$TOP_DIR/files/$4
+    if [[ -f "$output.qcow2" ]];
+    then
+        echo "Image file already exists: $output_file"
+    else
+        ELEMENTS_PATH=$elements_path disk-image-create \
+            $elements -a $arch -o $output
+    fi
+    # upload with fake URL so that image in $TOP_DIR/files is used
+    upload_image "http://localhost/$output.qcow2" $TOKEN
+}
 
 # Restore xtrace
 $XTRACE