blob: fefc5d75528b62d35b930f40c9c7bfa36ed7eeed [file] [log] [blame]
gstepanov08c0d7e2015-03-25 23:55:44 +02001FUEL_MASTER_IP=$1
2FUEL_MASTER_PASSWD=$2
3EXTERNAL_IP=$3
4KEY_FILE_NAME=$4
5
gstepanovcddbe3b2015-03-26 19:05:48 +02006
gstepanov08c0d7e2015-03-25 23:55:44 +02007if [ ! -z $5 ]
8then
9 FILE_TO_TEST=$5
10else
11 FILE_TO_TEST="bbb.txt"
12fi
13
14if [ ! -z $6 ]
15then
16 FILE_TO_STORE_RESULTS=$6
17else
18 FILE_TO_STORE_RESULTS="aaa.txt"
19fi
20
21if [ ! -z $7 ]
22then
23 TIMEOUT=$7
24else
25 TIMEOUT=60
26fi
27
28
29echo "Fuel master IP: $FUEL_MASTER_IP"
30echo "Fuel master password: $FUEL_MASTER_PASSWD"
31echo "External IP: $EXTERNAL_IP"
32echo "Key file name: $KEY_FILE_NAME"
33
34# note : function will works properly only when image dame is single string without spaces that can brake awk
35function wait_image_active() {
36 image_state="none"
koder aka kdanilov94e3a2c2015-03-27 11:36:34 +020037 image_name="$IMAGE_NAME"
gstepanov08c0d7e2015-03-25 23:55:44 +020038 counter=0
39
gstepanovcddbe3b2015-03-26 19:05:48 +020040 while [ ! $image_state eq "active" ] ; do
gstepanov08c0d7e2015-03-25 23:55:44 +020041 sleep 1
42 image_state=$(glance image-list | grep $image_name | awk '{print $12}')
43 echo $image_state
44 counter=$((counter + 1))
45
koder aka kdanilov94e3a2c2015-03-27 11:36:34 +020046 if [ "$counter" -eq "$TIMEOUT" ]
gstepanov08c0d7e2015-03-25 23:55:44 +020047 then
48 echo "Time limit exceed"
49 break
50 fi
51 done
52}
53
54
55function wait_floating_ip() {
56 sleep 10
57 floating_ip="|"
58 vm_name=$VM_NAME
59 counter=0
60
61 while [ $floating_ip != "|" ] ; do
62 sleep 1
63 floating_ip=$(nova floating-ip-list | grep $vm_name | awk '{print $13}' | head -1)
64 counter=$((counter + 1))
65
66 if [ $counter -eq $TIMEOUT ]
67 then
68 echo "Time limit exceed"
69 break
70 fi
71 done
72}
73
74
75function wait_vm_deleted() {
76 vm_name=$(nova list| grep $VM_NAME| awk '{print $4}'| head -1)
77 counter=0
78
79 while [ ! -z $vm_name ] ; do
80 sleep 1
81 vm_name=$(nova list| grep $VM_NAME| awk '{print $4}'| head -1)
82 counter=$((counter + 1))
83
84 if [ $counter -eq $TIMEOUT ]
85 then
86 echo "Time limit exceed"
87 break
88 fi
89 done
90}
91
gstepanovcddbe3b2015-03-26 19:05:48 +020092bash run_vm.sh $FUEL_MASTER_IP $FUEL_MASTER_PASSWD $EXTERNAL_IP
gstepanov08c0d7e2015-03-25 23:55:44 +020093source `get_openrc`
94list=$(nova list)
95if [ "$list" == "" ]; then
96 echo "openrc variables are unset or set to the empty string"
97fi
98
99IP=$(nova floating-ip-list | grep $FLOATING_NET | awk '{if ($5 == "-") print $2}' | head -n1)
100
101if [ -z $IP ]; then
102 IP=$(nova floating-ip-create net04_ext| awk '{print $2}')
103
104 if [ -z $list ]; then
105 echo "Cannot allocate new floating ip"
106 fi
107fi
108
109VM_IP=$IP
110echo "VM IP: $VM_IP"
111
112# sends images to glance
113bash prepare.sh
114wait_image_active
115echo "Image has been saved"
116VOL_ID=$(boot_vm)
117echo "VM has been booted"
118wait_floating_ip
119echo "Floating IP has been obtained"
120source `prepare_vm`
121echo "VM has been prepared"
gstepanovcddbe3b2015-03-26 19:05:48 +0200122
123# sudo bash ../single_node_test_short.sh $FILE_TO_TEST $FILE_TO_STORE_RESULTS
124
125ssh $SSH_OPTS -i $KEY_FILE_NAME ubuntu@$VM_IP \
126 "cd /tmp/io_scenario; echo 'results' > $FILE_TO_STORE_RESULTS; \
127 curl -X POST -d @$FILE_TO_STORE_RESULTS http://http://172.16.52.80/api/test --header 'Content-Type:application/json'"
128
129# nova delete $VM_NAME
130# wait_vm_deleted
131# echo "$VM_NAME has been deleted successfully"
132# cinder delete $VOL_ID
133# echo "Volume has been deleted $VOL_ID"