5 bottlenecks_create_instance()
7 echo "create bottlenecks instance using heat template"
9 if [ -d $BOTTLENECKS_REPO_DIR ]; then
10 rm -rf ${BOTTLENECKS_REPO_DIR}
13 mkdir -p ${BOTTLENECKS_REPO_DIR}
14 git config --global http.sslVerify false
15 git clone ${BOTTLENECKS_REPO} ${BOTTLENECKS_REPO_DIR}
17 source $BOTTLENECKS_REPO_DIR/rubbos/rubbos_scripts/1-1-1/scripts/env_preparation.sh
20 nova keypair-add --pub_key $KEY_PATH/bottleneck_key.pub $KEY_NAME
21 #need FIX, only upload the public key? should be keypair
23 echo "use heat template to create stack"
25 heat stack-create bottlenecks -f ${TEMPLATE_NAME} -P "image=$IMAGE_NAME;key=$KEY_NAME;public_network=$PUBLIC_NET_NAME"
26 #need FIX, use stack to create 9 VMs
31 echo "clean up bottlenecks images"
33 if ! glance image-list; then
38 for image in $(glance image-list | grep -e $IMAGE_NAME | awk '{print $2}'); do
39 echo "clean up image $image"
40 glance image-delete $iamge || true
44 bottlenecks_build_image()
46 echo "build bottlenecks image"
51 bottlenecks_load_cirros_image()
53 echo "load bottlenecks cirros image"
55 wget http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img -O /tmp/cirros.img
57 result=$(glance image-create \
60 --container-format bare \
61 --file /tmp/cirros.img)
64 rm -rf /tmp/cirros.img
66 IMAGE_ID_CIRROS=$(echo "$result" | grep " id " | awk '{print $(NF-1)}')
67 if [ -z "$IMAGE_ID_CIRROS" ]; then
68 echo 'failed to upload cirros image to openstack'
72 echo "cirros image id: $IMAGE_ID_CIRROS"
75 bottlenecks_load_image()
77 echo "load bottlenecks image"
79 result=$(glance --os-image-api-version 1 image-create \
81 --is-public true --disk-format qcow2 \
82 --container-format bare \
83 --file $IMAGE_FILE_NAME)
86 GLANCE_IMAGE_ID=$(echo "$result" | grep " id " | awk '{print $(NF-1)}')
88 if [ -z "$GLANCE_IMAGE_ID" ]; then
89 echo 'add image to glance failed'
93 sudo rm -f $IMAGE_FILE_NAME
95 echo "add glance image completed: $GLANCE_IMAGE_ID"
100 echo "create instances with heat template"
102 BOTTLENECKS_REPO=https://gerrit.opnfv.org/gerrit/bottlenecks
103 BOTTLENECKS_REPO_DIR=/tmp/opnfvrepo/bottlenecks
104 #IMAGE_URL=http://205.177.226.235:9999
105 IMAGE_NAME=cirros-0.3.3
106 #need FIX, need a script to transfer the image from the url to be the installer images
107 KEY_PATH=$BOTTLENECKS_REPO_DIR/utils/infra_setup/bottlenecks_key
108 HOT_PATH=$BOTTLENECKS_REPO_DIR/utils/infra_setup/heat_template
109 KEY_NAME=bottlenecks_key
110 TEMPLATE_NAME=bottlenecks_template1.yaml
111 PUBLIC_NET_NAME=net04_ext
116 #bottlenecks_build_image
117 bottlenecks_load_cirros_image
118 bottlenecks_create_instance