blob: b6d9ac8fe7aa4b8c435d50df4de9fc5b8d92ad9d [file] [log] [blame]
gstepanov3d2a9152015-03-27 15:46:20 +02001function get_arguments() {
2 export FUEL_MASTER_IP=${1:-172.16.52.108}
3 export FUEL_MASTER_PASSWD=${2:-test37}
4 export EXTERNAL_IP=${3:-172.16.55.2}
5 export KEY_FILE_NAME=${4:-disk_io_perf.pem}
6 export FILE_TO_TEST=${5:-file.txt}
7 export RESULT_FILE=${6:-results.txt}
8 export TIMEOUT=${7:-60}
gstepanov08c0d7e2015-03-25 23:55:44 +02009
gstepanov3d2a9152015-03-27 15:46:20 +020010 if [ $KEY_FILE_NAME does not exist ];
11 then
12 echo "File $KEY_FILE_NAME does not exist."
13 fi
gstepanovcddbe3b2015-03-26 19:05:48 +020014
gstepanov3d2a9152015-03-27 15:46:20 +020015 echo "Fuel master IP: $FUEL_MASTER_IP"
16 echo "Fuel master password: $FUEL_MASTER_PASSWD"
17 echo "External IP: $EXTERNAL_IP"
18 echo "Key file name: $KEY_FILE_NAME"
19 echo "Timeout: $TIMEOUT"
20}
gstepanov08c0d7e2015-03-25 23:55:44 +020021
22# note : function will works properly only when image dame is single string without spaces that can brake awk
23function wait_image_active() {
24 image_state="none"
koder aka kdanilov94e3a2c2015-03-27 11:36:34 +020025 image_name="$IMAGE_NAME"
gstepanov08c0d7e2015-03-25 23:55:44 +020026 counter=0
27
gstepanov3d2a9152015-03-27 15:46:20 +020028 while [ ! "$image_state" eq "active" ] ; do
gstepanov08c0d7e2015-03-25 23:55:44 +020029 sleep 1
gstepanov3d2a9152015-03-27 15:46:20 +020030 image_state=$(glance image-list | grep "$image_name" | awk '{print $12}')
gstepanov08c0d7e2015-03-25 23:55:44 +020031 echo $image_state
32 counter=$((counter + 1))
33
koder aka kdanilov94e3a2c2015-03-27 11:36:34 +020034 if [ "$counter" -eq "$TIMEOUT" ]
gstepanov08c0d7e2015-03-25 23:55:44 +020035 then
36 echo "Time limit exceed"
37 break
38 fi
39 done
40}
41
42
43function wait_floating_ip() {
gstepanov08c0d7e2015-03-25 23:55:44 +020044 floating_ip="|"
45 vm_name=$VM_NAME
46 counter=0
47
gstepanov3d2a9152015-03-27 15:46:20 +020048 while [ "$floating_ip" != "|" ] ; do
gstepanov08c0d7e2015-03-25 23:55:44 +020049 sleep 1
gstepanov3d2a9152015-03-27 15:46:20 +020050 floating_ip=$(nova floating-ip-list | grep "$vm_name" | awk '{print $13}' | head -1)
gstepanov08c0d7e2015-03-25 23:55:44 +020051 counter=$((counter + 1))
52
53 if [ $counter -eq $TIMEOUT ]
54 then
55 echo "Time limit exceed"
56 break
57 fi
58 done
59}
60
61
62function wait_vm_deleted() {
gstepanov3d2a9152015-03-27 15:46:20 +020063 vm_name=$(nova list| grep "$VM_NAME"| awk '{print $4}'| head -1)
gstepanov08c0d7e2015-03-25 23:55:44 +020064 counter=0
65
66 while [ ! -z $vm_name ] ; do
67 sleep 1
gstepanov3d2a9152015-03-27 15:46:20 +020068 vm_name=$(nova list| grep "$VM_NAME"| awk '{print $4}'| head -1)
gstepanov08c0d7e2015-03-25 23:55:44 +020069 counter=$((counter + 1))
70
gstepanov3d2a9152015-03-27 15:46:20 +020071 if [ "$counter" -eq $TIMEOUT ]
gstepanov08c0d7e2015-03-25 23:55:44 +020072 then
73 echo "Time limit exceed"
74 break
75 fi
76 done
77}
78
gstepanov08c0d7e2015-03-25 23:55:44 +020079
gstepanov3d2a9152015-03-27 15:46:20 +020080function get_floating_ip() {
81 IP=$(nova floating-ip-list | grep "$FLOATING_NET" | awk '{if ($5 == "-") print $2}' | head -n1)
gstepanov08c0d7e2015-03-25 23:55:44 +020082
gstepanov3d2a9152015-03-27 15:46:20 +020083 if [ -z "$IP" ]; then # fix net name
84 IP=$(nova floating-ip-create "$FLOATING_NET"| awk '{print $2}')
gstepanov08c0d7e2015-03-25 23:55:44 +020085
gstepanov3d2a9152015-03-27 15:46:20 +020086 if [ -z "$list" ]; then
87 echo "Cannot allocate new floating ip"
88 exit
89 fi
gstepanov08c0d7e2015-03-25 23:55:44 +020090 fi
gstepanov3d2a9152015-03-27 15:46:20 +020091}
gstepanov08c0d7e2015-03-25 23:55:44 +020092
gstepanov3d2a9152015-03-27 15:46:20 +020093function get_openrc() {
94 source run_vm.sh "$FUEL_MASTER_IP" "$FUEL_MASTER_PASSWD" "$EXTERNAL_IP"
95 source `get_openrc`
gstepanov08c0d7e2015-03-25 23:55:44 +020096
gstepanov3d2a9152015-03-27 15:46:20 +020097 list=$(nova list)
98 if [ "$list" == "" ]; then
99 echo "openrc variables are unset or set to the empty string"
100 fi
101
102 VM_IP=$IP
103 echo "VM IP: $VM_IP"
104 echo 'AUTH_URL: "$OS_AUTH_URL"'
105}
106
107
108get_arguments $1 $2 $3 $4 $5 $6 $6 $7
109echo "getting openrc from controller node"
110get_openrc
111echo "openrc has been activated on your machine"
112get_floating_ip
113echo "floating ip has been found"
gstepanov08c0d7e2015-03-25 23:55:44 +0200114bash prepare.sh
gstepanov3d2a9152015-03-27 15:46:20 +0200115echo "Image has been sended to glance"
gstepanov08c0d7e2015-03-25 23:55:44 +0200116wait_image_active
117echo "Image has been saved"
118VOL_ID=$(boot_vm)
119echo "VM has been booted"
120wait_floating_ip
121echo "Floating IP has been obtained"
122source `prepare_vm`
123echo "VM has been prepared"
gstepanovcddbe3b2015-03-26 19:05:48 +0200124
gstepanov3d2a9152015-03-27 15:46:20 +0200125# sudo bash ../single_node_test_short.sh $FILE_TO_TEST $RESULT_FILE
gstepanovcddbe3b2015-03-26 19:05:48 +0200126
koder aka kdanilovac16aae2015-03-27 12:28:31 +0200127# ssh $SSH_OPTS -i $KEY_FILE_NAME ubuntu@$VM_IP \
gstepanov3d2a9152015-03-27 15:46:20 +0200128# "cd /tmp/io_scenario; echo 'results' > $RESULT_FILE; \
129# curl -X POST -d @$RESULT_FILE http://http://172.16.52.80/api/test --header 'Content-Type:application/json'"
gstepanovcddbe3b2015-03-26 19:05:48 +0200130
gstepanov3d2a9152015-03-27 15:46:20 +0200131nova delete $VM_NAME
132wait_vm_deleted
133echo "$VM_NAME has been deleted successfully"
134cinder delete $VOL_ID
135echo "Volume has been deleted $VOL_ID"