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 and keys"
42 if glance image-list; then
43 for image in $(glance image-list | grep -e $IMAGE_NAME | awk '{print $2}'); do
44 echo "clean up image $image"
45 glance image-delete $image || true
49 if nova keypair-list; then
50 for key in $(nova keypair-list | grep -e $KEY_NAME | awk '{print $2}'); do
51 echo "clean up key $key"
52 nova keypair-delete || true
57 bottlenecks_build_image()
59 echo "build bottlenecks image"
64 bottlenecks_load_cirros_image()
66 echo "load bottlenecks cirros image"
68 wget http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img -O /tmp/cirros.img
70 result=$(glance image-create \
73 --container-format bare \
74 --file /tmp/cirros.img)
77 rm -rf /tmp/cirros.img
79 IMAGE_ID_CIRROS=$(echo "$result" | grep " id " | awk '{print $(NF-1)}')
80 if [ -z "$IMAGE_ID_CIRROS" ]; then
81 echo 'failed to upload cirros image to openstack'
85 echo "cirros image id: $IMAGE_ID_CIRROS"
88 bottlenecks_load_image()
90 echo "load bottlenecks image"
92 result=$(glance --os-image-api-version 1 image-create \
94 --is-public true --disk-format qcow2 \
95 --container-format bare \
96 --file $IMAGE_FILE_NAME)
99 GLANCE_IMAGE_ID=$(echo "$result" | grep " id " | awk '{print $(NF-1)}')
101 if [ -z "$GLANCE_IMAGE_ID" ]; then
102 echo 'add image to glance failed'
106 sudo rm -f $IMAGE_FILE_NAME
108 echo "add glance image completed: $GLANCE_IMAGE_ID"
113 echo "create instances with heat template"
115 BOTTLENECKS_REPO=https://gerrit.opnfv.org/gerrit/bottlenecks
116 BOTTLENECKS_REPO_DIR=/tmp/opnfvrepo/bottlenecks
117 #IMAGE_URL=http://205.177.226.235:9999
118 IMAGE_NAME=cirros-0.3.3
119 #need FIX, need a script to transfer the image from the url to be the installer images
120 KEY_PATH=$BOTTLENECKS_REPO_DIR/utils/infra_setup/bottlenecks_key
121 HOT_PATH=$BOTTLENECKS_REPO_DIR/utils/infra_setup/heat_template
122 KEY_NAME=bottlenecks_key
123 TEMPLATE_NAME=bottlenecks_template1.yaml
124 PUBLIC_NET_NAME=net04_ext
128 bottlenecks_env_prepare
130 #bottlenecks_build_image
131 bottlenecks_load_cirros_image
132 bottlenecks_create_instance