blob: 2b77d26ea512b657b6a2245e36a41d2be368a1d2 [file] [log] [blame]
gstepanov3d2a9152015-03-27 15:46:20 +02001function get_arguments() {
gstepanov08c0d7e2015-03-25 23:55:44 +02002
gstepanovb65b9a82015-03-28 18:09:17 +02003 export FUEL_MASTER_IP=$1
koder aka kdanilovfb23a262015-03-27 16:50:58 +02004
gstepanovb65b9a82015-03-28 18:09:17 +02005 if [ -z "${FUEL_MASTER_IP}" ]; then echo "Fuel master node ip is not provided"; fi
6
7 export EXTERNAL_IP=$2
8
9 if [ -z "${EXTERNAL_IP}" ]; then echo "Fuel external ip is not provided"; fi
10
11 export KEY_FILE_NAME=$3
12
13 if [ -z "${KEY_FILE_NAME}" ]; then echo "Key file name is not provided"; fi
14
15 export FILE_TO_TEST=$4
16
17 if [ -z "${KEY_FILE_NAME}" ]; then echo "Key file name is not provided"; fi
18
19 if [ ! -f $KEY_FILE_NAME ];
gstepanov3d2a9152015-03-27 15:46:20 +020020 then
21 echo "File $KEY_FILE_NAME does not exist."
22 fi
gstepanovcddbe3b2015-03-26 19:05:48 +020023
gstepanovb65b9a82015-03-28 18:09:17 +020024 export RESULT_FILE=$5
25
26 if [ -z "${RESULT_FILE}" ]; then echo "Result file name is not provided"; fi
27
28 export FUEL_MASTER_PASSWD=${6:-test37}
29 export TIMEOUT=${7:-360}
30
31
gstepanov3d2a9152015-03-27 15:46:20 +020032 echo "Fuel master IP: $FUEL_MASTER_IP"
33 echo "Fuel master password: $FUEL_MASTER_PASSWD"
34 echo "External IP: $EXTERNAL_IP"
35 echo "Key file name: $KEY_FILE_NAME"
36 echo "Timeout: $TIMEOUT"
37}
gstepanov08c0d7e2015-03-25 23:55:44 +020038
39# note : function will works properly only when image dame is single string without spaces that can brake awk
40function wait_image_active() {
41 image_state="none"
koder aka kdanilov94e3a2c2015-03-27 11:36:34 +020042 image_name="$IMAGE_NAME"
gstepanov08c0d7e2015-03-25 23:55:44 +020043 counter=0
44
gstepanovb65b9a82015-03-28 18:09:17 +020045 while [ ["$image_state" == "active"] ] ; do
gstepanov08c0d7e2015-03-25 23:55:44 +020046 sleep 1
gstepanov3d2a9152015-03-27 15:46:20 +020047 image_state=$(glance image-list | grep "$image_name" | awk '{print $12}')
gstepanov08c0d7e2015-03-25 23:55:44 +020048 echo $image_state
49 counter=$((counter + 1))
50
koder aka kdanilov94e3a2c2015-03-27 11:36:34 +020051 if [ "$counter" -eq "$TIMEOUT" ]
gstepanov08c0d7e2015-03-25 23:55:44 +020052 then
53 echo "Time limit exceed"
54 break
55 fi
56 done
57}
58
59
60function wait_floating_ip() {
gstepanov08c0d7e2015-03-25 23:55:44 +020061 floating_ip="|"
62 vm_name=$VM_NAME
63 counter=0
64
gstepanov3d2a9152015-03-27 15:46:20 +020065 while [ "$floating_ip" != "|" ] ; do
gstepanov08c0d7e2015-03-25 23:55:44 +020066 sleep 1
gstepanov3d2a9152015-03-27 15:46:20 +020067 floating_ip=$(nova floating-ip-list | grep "$vm_name" | awk '{print $13}' | head -1)
gstepanov08c0d7e2015-03-25 23:55:44 +020068 counter=$((counter + 1))
69
70 if [ $counter -eq $TIMEOUT ]
71 then
72 echo "Time limit exceed"
73 break
74 fi
75 done
76}
77
78
79function wait_vm_deleted() {
gstepanov3d2a9152015-03-27 15:46:20 +020080 vm_name=$(nova list| grep "$VM_NAME"| awk '{print $4}'| head -1)
gstepanov08c0d7e2015-03-25 23:55:44 +020081 counter=0
82
83 while [ ! -z $vm_name ] ; do
84 sleep 1
gstepanov3d2a9152015-03-27 15:46:20 +020085 vm_name=$(nova list| grep "$VM_NAME"| awk '{print $4}'| head -1)
gstepanov08c0d7e2015-03-25 23:55:44 +020086 counter=$((counter + 1))
87
gstepanov3d2a9152015-03-27 15:46:20 +020088 if [ "$counter" -eq $TIMEOUT ]
gstepanov08c0d7e2015-03-25 23:55:44 +020089 then
90 echo "Time limit exceed"
91 break
92 fi
93 done
94}
95
gstepanov08c0d7e2015-03-25 23:55:44 +020096
gstepanov3d2a9152015-03-27 15:46:20 +020097function get_floating_ip() {
98 IP=$(nova floating-ip-list | grep "$FLOATING_NET" | awk '{if ($5 == "-") print $2}' | head -n1)
gstepanov08c0d7e2015-03-25 23:55:44 +020099
gstepanov3d2a9152015-03-27 15:46:20 +0200100 if [ -z "$IP" ]; then # fix net name
101 IP=$(nova floating-ip-create "$FLOATING_NET"| awk '{print $2}')
gstepanov08c0d7e2015-03-25 23:55:44 +0200102
gstepanov3d2a9152015-03-27 15:46:20 +0200103 if [ -z "$list" ]; then
104 echo "Cannot allocate new floating ip"
gstepanovd2826632015-04-02 15:01:18 +0300105 # exit
gstepanov3d2a9152015-03-27 15:46:20 +0200106 fi
gstepanov08c0d7e2015-03-25 23:55:44 +0200107 fi
gstepanovb65b9a82015-03-28 18:09:17 +0200108
gstepanovd2826632015-04-02 15:01:18 +0300109 echo $FLOATING_NET
gstepanovb65b9a82015-03-28 18:09:17 +0200110 export VM_IP=$IP
111 echo "VM_IP: $VM_IP"
gstepanov3d2a9152015-03-27 15:46:20 +0200112}
gstepanov08c0d7e2015-03-25 23:55:44 +0200113
gstepanovb65b9a82015-03-28 18:09:17 +0200114function run_openrc() {
gstepanovd2826632015-04-02 15:01:18 +0300115 source run_vm.sh "$FUEL_MASTER_IP" "$FUEL_MASTER_PASSWD" "$EXTERNAL_IP" novanetwork nova
gstepanov3d2a9152015-03-27 15:46:20 +0200116 source `get_openrc`
gstepanov08c0d7e2015-03-25 23:55:44 +0200117
gstepanov3d2a9152015-03-27 15:46:20 +0200118 list=$(nova list)
119 if [ "$list" == "" ]; then
120 echo "openrc variables are unset or set to the empty string"
121 fi
122
gstepanovd2826632015-04-02 15:01:18 +0300123 echo "AUTH_URL: $OS_AUTH_URL"
gstepanov3d2a9152015-03-27 15:46:20 +0200124}
125
koder aka kdanilovfb23a262015-03-27 16:50:58 +0200126get_arguments $@
gstepanov3d2a9152015-03-27 15:46:20 +0200127
gstepanov3d2a9152015-03-27 15:46:20 +0200128echo "getting openrc from controller node"
gstepanovb65b9a82015-03-28 18:09:17 +0200129run_openrc
koder aka kdanilovfb23a262015-03-27 16:50:58 +0200130
gstepanov3d2a9152015-03-27 15:46:20 +0200131echo "openrc has been activated on your machine"
132get_floating_ip
koder aka kdanilovfb23a262015-03-27 16:50:58 +0200133
gstepanov3d2a9152015-03-27 15:46:20 +0200134echo "floating ip has been found"
gstepanov08c0d7e2015-03-25 23:55:44 +0200135bash prepare.sh
gstepanov3d2a9152015-03-27 15:46:20 +0200136echo "Image has been sended to glance"
gstepanov08c0d7e2015-03-25 23:55:44 +0200137wait_image_active
138echo "Image has been saved"
koder aka kdanilovfb23a262015-03-27 16:50:58 +0200139
140BOOT_LOG_FILE=`tempfile`
141boot_vm | tee "$BOOT_LOG_FILE"
142VOL_ID=$(cat "$BOOT_LOG_FILE" | grep "VOL_ID=" | sed 's/VOL_ID=//')
143rm "$BOOT_LOG_FILE"
144
gstepanov08c0d7e2015-03-25 23:55:44 +0200145echo "VM has been booted"
146wait_floating_ip
147echo "Floating IP has been obtained"
148source `prepare_vm`
149echo "VM has been prepared"
gstepanovcddbe3b2015-03-26 19:05:48 +0200150
gstepanov3d2a9152015-03-27 15:46:20 +0200151# sudo bash ../single_node_test_short.sh $FILE_TO_TEST $RESULT_FILE
gstepanovcddbe3b2015-03-26 19:05:48 +0200152
gstepanovd2826632015-04-02 15:01:18 +0300153ssh $SSH_OPTS -i $KEY_FILE_NAME ubuntu@$VM_IP \
154 "cd /tmp/io_scenario;"
gstepanovcddbe3b2015-03-26 19:05:48 +0200155
gstepanovd2826632015-04-02 15:01:18 +0300156# echo 'results' > $RESULT_FILE; \
157# curl -X POST -d @$RESULT_FILE http://http://172.16.52.80/api/test --header 'Content-Type:application/json'
158
159# nova delete $VM_NAME
160# wait_vm_deleted
161# echo "$VM_NAME has been deleted successfully"
162# cinder delete $VOL_ID
163# echo "Volume has been deleted $VOL_ID"