amend heat template instance creation script
[bottlenecks.git] / utils / infra_setup / heat_template / HOT_create_instance.sh
old mode 100644 (file)
new mode 100755 (executable)
index d9e09a9..aa4e2e3
@@ -1,22 +1,37 @@
 #!/bin/bash
 
-set -e
+set -ex
 
-bottlenecks_create_instance()
+bottlenecks_env_prepare()
 {
-   echo "create bottlenecks instance using heat template"
+   if [ -d $BOTTLENECKS_REPO_DIR ]; then
+       rm -rf ${BOTTLENECKS_REPO_DIR}
+   fi
 
    mkdir -p ${BOTTLENECKS_REPO_DIR}
    git config --global http.sslVerify false
    git clone ${BOTTLENECKS_REPO} ${BOTTLENECKS_REPO_DIR}
 
+   source $BOTTLENECKS_REPO_DIR/rubbos/rubbos_scripts/1-1-1/scripts/env_preparation.sh
+}
+
+bottlenecks_create_instance()
+{
+   echo "create bottlenecks instance using heat template"
+
    echo "upload keypair"
-   nova keypair-add --pub_key $KEY_PATH/bottleneck_key.pub $KEY_NAME
+   nova keypair-add --pub_key $KEY_PATH/bottlenecks_key.pub $KEY_NAME
    #need FIX, only upload the public key? should be keypair
 
    echo "use heat template to create stack"
    cd $HOT_PATH
    heat stack-create bottlenecks -f ${TEMPLATE_NAME} -P "image=$IMAGE_NAME;key=$KEY_NAME;public_network=$PUBLIC_NET_NAME"
+   sleep 60
+   heat stack-list
+   heat stack-show bottlenecks
+   nova list
+   heat stack-delete bottlenecks
+
    #need FIX, use stack to create 9 VMs
 }
 
@@ -33,9 +48,6 @@ bottlenecks_cleanup()
        echo "clean up image $image"
        glance image-delete $iamge || true
    done
-
-   #FIX ME
-   #nova flavor-delete yardstick-flavor &> /dev/null || true
 }
 
 bottlenecks_build_image()
@@ -49,16 +61,18 @@ bottlenecks_load_cirros_image()
 {
    echo "load bottlenecks cirros image"
 
-   local image_file=/home/opnfv/images/cirros-0.3.3-x86_64-disk.img
+   wget http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img -O /tmp/cirros.img
 
    result=$(glance image-create \
        --name cirros-0.3.3 \
        --disk-format qcow2 \
        --container-format bare \
-       --file $image_file)
+       --file /tmp/cirros.img)
    echo "$result"
 
-   IMAGE_ID_CIRROS=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
+   rm -rf /tmp/cirros.img
+
+   IMAGE_ID_CIRROS=$(echo "$result" | grep " id " | awk '{print $(NF-1)}')
    if [ -z "$IMAGE_ID_CIRROS" ]; then
         echo 'failed to upload cirros image to openstack'
         exit 1
@@ -107,6 +121,7 @@ main()
    #need FIX
    #IMAGE_FILE_NAME=""
 
+   bottlenecks_env_prepare
    #bottlenecks_cleanup
    #bottlenecks_build_image
    bottlenecks_load_cirros_image
@@ -114,3 +129,5 @@ main()
 }
 
 main
+set +ex
+