5 bottlenecks_env_prepare()
7 if [ -d $BOTTLENECKS_REPO_DIR ]; then
8 rm -rf ${BOTTLENECKS_REPO_DIR}
11 mkdir -p ${BOTTLENECKS_REPO_DIR}
12 git config --global http.sslVerify false
13 git clone ${BOTTLENECKS_REPO} ${BOTTLENECKS_REPO_DIR}
15 source $BOTTLENECKS_REPO_DIR/rubbos/rubbos_scripts/1-1-1/scripts/env_preparation.sh
18 bottlenecks_create_instance()
20 echo "create bottlenecks instance using heat template"
23 nova keypair-add --pub_key $KEY_PATH/bottlenecks_key.pub $KEY_NAME
24 #need FIX, only upload the public key? should be keypair
26 echo "use heat template to create stack"
28 heat stack-create bottlenecks -f ${TEMPLATE_NAME} -P "image=$IMAGE_NAME;key=$KEY_NAME;public_network=$PUBLIC_NET_NAME"
31 heat stack-show bottlenecks
33 heat stack-delete bottlenecks
35 #need FIX, use stack to create 9 VMs
40 echo "clean up bottlenecks images"
42 if ! glance image-list; then
47 for image in $(glance image-list | grep -e $IMAGE_NAME | awk '{print $2}'); do
48 echo "clean up image $image"
49 glance image-delete $iamge || true
53 bottlenecks_build_image()
55 echo "build bottlenecks image"
60 bottlenecks_load_cirros_image()
62 echo "load bottlenecks cirros image"
64 wget http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img -O /tmp/cirros.img
66 result=$(glance image-create \
69 --container-format bare \
70 --file /tmp/cirros.img)
73 rm -rf /tmp/cirros.img
75 IMAGE_ID_CIRROS=$(echo "$result" | grep " id " | awk '{print $(NF-1)}')
76 if [ -z "$IMAGE_ID_CIRROS" ]; then
77 echo 'failed to upload cirros image to openstack'
81 echo "cirros image id: $IMAGE_ID_CIRROS"
84 bottlenecks_load_image()
86 echo "load bottlenecks image"
88 result=$(glance --os-image-api-version 1 image-create \
90 --is-public true --disk-format qcow2 \
91 --container-format bare \
92 --file $IMAGE_FILE_NAME)
95 GLANCE_IMAGE_ID=$(echo "$result" | grep " id " | awk '{print $(NF-1)}')
97 if [ -z "$GLANCE_IMAGE_ID" ]; then
98 echo 'add image to glance failed'
102 sudo rm -f $IMAGE_FILE_NAME
104 echo "add glance image completed: $GLANCE_IMAGE_ID"
109 echo "create instances with heat template"
111 BOTTLENECKS_REPO=https://gerrit.opnfv.org/gerrit/bottlenecks
112 BOTTLENECKS_REPO_DIR=/tmp/opnfvrepo/bottlenecks
113 #IMAGE_URL=http://205.177.226.235:9999
114 IMAGE_NAME=cirros-0.3.3
115 #need FIX, need a script to transfer the image from the url to be the installer images
116 KEY_PATH=$BOTTLENECKS_REPO_DIR/utils/infra_setup/bottlenecks_key
117 HOT_PATH=$BOTTLENECKS_REPO_DIR/utils/infra_setup/heat_template
118 KEY_NAME=bottlenecks_key
119 TEMPLATE_NAME=bottlenecks_template1.yaml
120 PUBLIC_NET_NAME=net04_ext
124 bottlenecks_env_prepare
126 #bottlenecks_build_image
127 bottlenecks_load_cirros_image
128 bottlenecks_create_instance