- echo "clean up bottlenecks images and keys"
-
- if heat stack-list; then
- for stack in $(heat stack-list | grep -e bottlenecks | awk '{print $2}'); do
- echo "clean up stack $stack"
- heat stack-delete $stack || true
- sleep 30
- done
- fi
-
- if glance image-list; then
- for image in $(glance image-list | grep -e $IMAGE_NAME | awk '{print $2}'); do
- echo "clean up image $image"
- glance image-delete $image || true
- done
- fi
-
- if nova keypair-list; then
- for key in $(nova keypair-list | grep -e $KEY_NAME | awk '{print $2}'); do
- echo "clean up key $key"
- nova keypair-delete $key || true
- done
- fi
-
- if nova flavor-list; then
- for flavor in $(nova flavor-list | grep -e $FLAVOR_NAME | awk '{print $2}'); do
- echo "clean up flavor $flavor"
- nova flavor-delete $flavor || true
- done
- fi
+ echo "clean up bottlenecks images and keys"
+
+ if heat stack-list; then
+ for stack in $(heat stack-list | grep -e bottlenecks | awk '{print $2}'); do
+ echo "clean up stack $stack"
+ heat stack-delete $stack || true
+ sleep 30
+ done
+ fi
+
+ if glance image-list; then
+ for image in $(glance image-list | grep -e $IMAGE_NAME | awk '{print $2}'); do
+ echo "clean up image $image"
+ glance image-delete $image || true
+ done
+ fi
+
+ if nova keypair-list; then
+ for key in $(nova keypair-list | grep -e $KEY_NAME | awk '{print $2}'); do
+ echo "clean up key $key"
+ nova keypair-delete $key || true
+ done
+ fi
+
+ if nova flavor-list; then
+ for flavor in $(nova flavor-list | grep -e $FLAVOR_NAME | awk '{print $2}'); do
+ echo "clean up flavor $flavor"
+ nova flavor-delete $flavor || true
+ done
+ fi
+}
+
+bottlenecks_load_cirros_image()
+{
+ echo "load cirros image"
+
+ wget http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img -O \
+ /tmp/bottlenecks-cirros.img
+
+ result=$(glance image-create \
+ --name $IMAGE_NAME \
+ --disk-format qcow2 \
+ --container-format bare \
+ --file /tmp/bottlenecks-cirros.img)
+ echo "$result"
+
+ rm -rf /tmp/bottlenecks-cirros.img
+
+ IMAGE_ID_BOTTLENECKS=$(echo "$result" | grep " id " | awk '{print $(NF-1)}')
+ if [ -z "$IMAGE_ID_BOTTLENECKS" ]; then
+ echo 'failed to upload bottlenecks image to openstack'
+ exit 1
+ fi
+
+ echo "bottlenecks image id: $IMAGE_ID_BOTTLENECKS"