5 bottlenecks_create_instance()
7 echo "create bottlenecks instance using heat template"
9 mkdir -p ${BOTTLENECKS_REPO_DIR}
10 git config --global http.sslVerify false
11 git clone ${BOTTLENECKS_REPO} ${BOTTLENECKS_REPO_DIR}
14 nova keypair-add --pub_key $KEY_PATH/bottleneck_key.pub $KEY_NAME
15 #need FIX, only upload the public key? should be keypair
17 echo "use heat template to create stack"
19 heat stack-create bottlenecks -f ${TEMPLATE_NAME} -P "image=$IMAGE_NAME;key=$KEY_NAME;public_network=$PUBLIC_NET_NAME"
20 #need FIX, use stack to create 9 VMs
25 echo "clean up bottlenecks images"
27 if ! glance image-list; then
32 for image in $(glance image-list | grep -e $IMAGE_NAME | awk '{print $2}'); do
33 echo "clean up image $image"
34 glance image-delete $iamge || true
38 #nova flavor-delete yardstick-flavor &> /dev/null || true
41 bottlenecks_build_image()
43 echo "build bottlenecks image"
48 bottlenecks_load_cirros_image()
50 echo "load bottlenecks cirros image"
52 local image_file=/home/opnfv/images/cirros-0.3.3-x86_64-disk.img
54 result=$(glance image-create \
57 --container-format bare \
61 IMAGE_ID_CIRROS=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
62 if [ -z "$IMAGE_ID_CIRROS" ]; then
63 echo 'failed to upload cirros image to openstack'
67 echo "cirros image id: $IMAGE_ID_CIRROS"
70 bottlenecks_load_image()
72 echo "load bottlenecks image"
74 result=$(glance --os-image-api-version 1 image-create \
76 --is-public true --disk-format qcow2 \
77 --container-format bare \
78 --file $IMAGE_FILE_NAME)
81 GLANCE_IMAGE_ID=$(echo "$result" | grep " id " | awk '{print $(NF-1)}')
83 if [ -z "$GLANCE_IMAGE_ID" ]; then
84 echo 'add image to glance failed'
88 sudo rm -f $IMAGE_FILE_NAME
90 echo "add glance image completed: $GLANCE_IMAGE_ID"
95 echo "create instances with heat template"
97 BOTTLENECKS_REPO=https://gerrit.opnfv.org/gerrit/bottlenecks
98 BOTTLENECKS_REPO_DIR=/tmp/opnfvrepo/bottlenecks
99 #IMAGE_URL=http://205.177.226.235:9999
100 IMAGE_NAME=cirros-0.3.3
101 #need FIX, need a script to transfer the image from the url to be the installer images
102 KEY_PATH=$BOTTLENECKS_REPO_DIR/utils/infra_setup/bottlenecks_key
103 HOT_PATH=$BOTTLENECKS_REPO_DIR/utils/infra_setup/heat_template
104 KEY_NAME=bottlenecks_key
105 TEMPLATE_NAME=bottlenecks_template1.yaml
106 PUBLIC_NET_NAME=net04_ext
109 source $BOTTLENECKS_REPO_DIR/rubbos/rubbos_scripts/1-1-1/scripts/env_preparation.sh
112 #bottlenecks_build_image
113 bottlenecks_load_cirros_image
114 bottlenecks_create_instance