blob: a4351ce733e49e54b84a8b028518ada308660e51 [file] [log] [blame]
gstepanov3d2a9152015-03-27 15:46:20 +02001function get_arguments() {
gstepanov08c0d7e2015-03-25 23:55:44 +02002
koder aka kdanilovfb23a262015-03-27 16:50:58 +02003 export FUEL_MASTER_IP=${1:-172.16.52.108} # << FIXME
4 export FUEL_MASTER_PASSWD=${2:-test37}
5 export EXTERNAL_IP=${3:-172.16.55.2} # << FIXME .....
6 export KEY_FILE_NAME=${4:-disk_io_perf.pem}
7 export FILE_TO_TEST=$5 # << FIXME
8 export RESULT_FILE=$6
9 export TIMEOUT=${7:-360}
10
11 if [ $KEY_FILE_NAME does not exist ]; # << FIXME
gstepanov3d2a9152015-03-27 15:46:20 +020012 then
13 echo "File $KEY_FILE_NAME does not exist."
14 fi
gstepanovcddbe3b2015-03-26 19:05:48 +020015
gstepanov3d2a9152015-03-27 15:46:20 +020016 echo "Fuel master IP: $FUEL_MASTER_IP"
17 echo "Fuel master password: $FUEL_MASTER_PASSWD"
18 echo "External IP: $EXTERNAL_IP"
19 echo "Key file name: $KEY_FILE_NAME"
20 echo "Timeout: $TIMEOUT"
21}
gstepanov08c0d7e2015-03-25 23:55:44 +020022
23# note : function will works properly only when image dame is single string without spaces that can brake awk
24function wait_image_active() {
25 image_state="none"
koder aka kdanilov94e3a2c2015-03-27 11:36:34 +020026 image_name="$IMAGE_NAME"
gstepanov08c0d7e2015-03-25 23:55:44 +020027 counter=0
28
gstepanov3d2a9152015-03-27 15:46:20 +020029 while [ ! "$image_state" eq "active" ] ; do
gstepanov08c0d7e2015-03-25 23:55:44 +020030 sleep 1
gstepanov3d2a9152015-03-27 15:46:20 +020031 image_state=$(glance image-list | grep "$image_name" | awk '{print $12}')
gstepanov08c0d7e2015-03-25 23:55:44 +020032 echo $image_state
33 counter=$((counter + 1))
34
koder aka kdanilov94e3a2c2015-03-27 11:36:34 +020035 if [ "$counter" -eq "$TIMEOUT" ]
gstepanov08c0d7e2015-03-25 23:55:44 +020036 then
37 echo "Time limit exceed"
38 break
39 fi
40 done
41}
42
43
44function wait_floating_ip() {
gstepanov08c0d7e2015-03-25 23:55:44 +020045 floating_ip="|"
46 vm_name=$VM_NAME
47 counter=0
48
gstepanov3d2a9152015-03-27 15:46:20 +020049 while [ "$floating_ip" != "|" ] ; do
gstepanov08c0d7e2015-03-25 23:55:44 +020050 sleep 1
gstepanov3d2a9152015-03-27 15:46:20 +020051 floating_ip=$(nova floating-ip-list | grep "$vm_name" | awk '{print $13}' | head -1)
gstepanov08c0d7e2015-03-25 23:55:44 +020052 counter=$((counter + 1))
53
54 if [ $counter -eq $TIMEOUT ]
55 then
56 echo "Time limit exceed"
57 break
58 fi
59 done
60}
61
62
63function wait_vm_deleted() {
gstepanov3d2a9152015-03-27 15:46:20 +020064 vm_name=$(nova list| grep "$VM_NAME"| awk '{print $4}'| head -1)
gstepanov08c0d7e2015-03-25 23:55:44 +020065 counter=0
66
67 while [ ! -z $vm_name ] ; do
68 sleep 1
gstepanov3d2a9152015-03-27 15:46:20 +020069 vm_name=$(nova list| grep "$VM_NAME"| awk '{print $4}'| head -1)
gstepanov08c0d7e2015-03-25 23:55:44 +020070 counter=$((counter + 1))
71
gstepanov3d2a9152015-03-27 15:46:20 +020072 if [ "$counter" -eq $TIMEOUT ]
gstepanov08c0d7e2015-03-25 23:55:44 +020073 then
74 echo "Time limit exceed"
75 break
76 fi
77 done
78}
79
gstepanov08c0d7e2015-03-25 23:55:44 +020080
gstepanov3d2a9152015-03-27 15:46:20 +020081function get_floating_ip() {
82 IP=$(nova floating-ip-list | grep "$FLOATING_NET" | awk '{if ($5 == "-") print $2}' | head -n1)
gstepanov08c0d7e2015-03-25 23:55:44 +020083
gstepanov3d2a9152015-03-27 15:46:20 +020084 if [ -z "$IP" ]; then # fix net name
85 IP=$(nova floating-ip-create "$FLOATING_NET"| awk '{print $2}')
gstepanov08c0d7e2015-03-25 23:55:44 +020086
gstepanov3d2a9152015-03-27 15:46:20 +020087 if [ -z "$list" ]; then
88 echo "Cannot allocate new floating ip"
89 exit
90 fi
gstepanov08c0d7e2015-03-25 23:55:44 +020091 fi
gstepanov3d2a9152015-03-27 15:46:20 +020092}
gstepanov08c0d7e2015-03-25 23:55:44 +020093
gstepanov3d2a9152015-03-27 15:46:20 +020094function get_openrc() {
95 source run_vm.sh "$FUEL_MASTER_IP" "$FUEL_MASTER_PASSWD" "$EXTERNAL_IP"
96 source `get_openrc`
gstepanov08c0d7e2015-03-25 23:55:44 +020097
gstepanov3d2a9152015-03-27 15:46:20 +020098 list=$(nova list)
99 if [ "$list" == "" ]; then
100 echo "openrc variables are unset or set to the empty string"
101 fi
102
103 VM_IP=$IP
104 echo "VM IP: $VM_IP"
105 echo 'AUTH_URL: "$OS_AUTH_URL"'
106}
107
koder aka kdanilovfb23a262015-03-27 16:50:58 +0200108# CHECK
109shift
110get_arguments $@
gstepanov3d2a9152015-03-27 15:46:20 +0200111
gstepanov3d2a9152015-03-27 15:46:20 +0200112echo "getting openrc from controller node"
113get_openrc
koder aka kdanilovfb23a262015-03-27 16:50:58 +0200114
gstepanov3d2a9152015-03-27 15:46:20 +0200115echo "openrc has been activated on your machine"
116get_floating_ip
koder aka kdanilovfb23a262015-03-27 16:50:58 +0200117
gstepanov3d2a9152015-03-27 15:46:20 +0200118echo "floating ip has been found"
gstepanov08c0d7e2015-03-25 23:55:44 +0200119bash prepare.sh
gstepanov3d2a9152015-03-27 15:46:20 +0200120echo "Image has been sended to glance"
gstepanov08c0d7e2015-03-25 23:55:44 +0200121wait_image_active
122echo "Image has been saved"
koder aka kdanilovfb23a262015-03-27 16:50:58 +0200123
124BOOT_LOG_FILE=`tempfile`
125boot_vm | tee "$BOOT_LOG_FILE"
126VOL_ID=$(cat "$BOOT_LOG_FILE" | grep "VOL_ID=" | sed 's/VOL_ID=//')
127rm "$BOOT_LOG_FILE"
128
gstepanov08c0d7e2015-03-25 23:55:44 +0200129echo "VM has been booted"
130wait_floating_ip
131echo "Floating IP has been obtained"
132source `prepare_vm`
133echo "VM has been prepared"
gstepanovcddbe3b2015-03-26 19:05:48 +0200134
gstepanov3d2a9152015-03-27 15:46:20 +0200135# sudo bash ../single_node_test_short.sh $FILE_TO_TEST $RESULT_FILE
gstepanovcddbe3b2015-03-26 19:05:48 +0200136
koder aka kdanilovac16aae2015-03-27 12:28:31 +0200137# ssh $SSH_OPTS -i $KEY_FILE_NAME ubuntu@$VM_IP \
gstepanov3d2a9152015-03-27 15:46:20 +0200138# "cd /tmp/io_scenario; echo 'results' > $RESULT_FILE; \
139# 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 +0200140
gstepanov3d2a9152015-03-27 15:46:20 +0200141nova delete $VM_NAME
142wait_vm_deleted
143echo "$VM_NAME has been deleted successfully"
144cinder delete $VOL_ID
145echo "Volume has been deleted $VOL_ID"