add vm env setup and run script after instance creation
[bottlenecks.git] / utils / infra_setup / heat_template / HOT_create_instance.sh
index bc28a99..3c96ce1 100755 (executable)
@@ -34,11 +34,23 @@ bottlenecks_create_instance()
    heat stack-show bottlenecks
    nova list
    nova list | grep rubbos_control
+}
+
+bottlenecks_rubbos_run()
+{
+   echo "Run Rubbos"
    control_ip=$(nova list | grep rubbos_control | awk '{print $13}')
+   chmod 600 $KEY_PATH/bottlenecks_key
    ssh -i $KEY_PATH/bottlenecks_key \
        -o StrictHostKeyChecking=no \
        -o BatchMode=yes root@$control_ip "uname -a"
-   heat stack-delete bottlenecks
+   scp -r -i $KEY_PATH/bottlenecks_key \
+       -o StrictHostKeyChecking=no -o BatchMode=yes \
+       $BOTTLENECKS_REPO_DIR/utils/infra_setup/vm_dev_setup \
+       root@$control_ip:/tmp
+   ssh -i $KEY_PATH/bottlenecks_key \
+       -o StrictHostKeyChecking=no \
+       -o BatchMode=yes root@$control_ip "bash /tmp/vm_dev_setup/setup_env.sh"
 }
 
 bottlenecks_cleanup()
@@ -80,6 +92,10 @@ bottlenecks_load_bottlenecks_image()
    echo "load bottlenecks image"
 
    curl --connect-timeout 10 -o /tmp/bottlenecks-trusty-server.img $IMAGE_URL -v
+   if [ $? != 0 ]; then
+        wget http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img -O \
+             /tmp/bottlenecks-trusty-server.img
+   fi
 
    result=$(glance image-create \
        --name $IMAGE_NAME \
@@ -105,7 +121,7 @@ main()
 
    BOTTLENECKS_REPO=https://gerrit.opnfv.org/gerrit/bottlenecks
    BOTTLENECKS_REPO_DIR=/tmp/opnfvrepo/bottlenecks
-   IMAGE_URL=http://205.177.226.235:9999/bottlenecks/rubbos/bottlenecks-trusty-server.img
+   IMAGE_URL=http://artifacts.opnfv.org/bottlenecks/rubbos/bottlenecks-trusty-server.img
    IMAGE_NAME=bottlenecks-trusty-server
    KEY_PATH=$BOTTLENECKS_REPO_DIR/utils/infra_setup/bottlenecks_key
    HOT_PATH=$BOTTLENECKS_REPO_DIR/utils/infra_setup/heat_template
@@ -118,6 +134,7 @@ main()
    bottlenecks_cleanup
    bottlenecks_load_bottlenecks_image
    bottlenecks_create_instance
+   bottlenecks_rubbos_run
    bottlenecks_cleanup
 }