gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 1 | FUEL_MASTER_IP=$1 |
| 2 | FUEL_MASTER_PASSWD=$2 |
| 3 | EXTERNAL_IP=$3 |
| 4 | KEY_FILE_NAME=$4 |
| 5 | |
gstepanov | cddbe3b | 2015-03-26 19:05:48 +0200 | [diff] [blame] | 6 | |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 7 | if [ ! -z $5 ] |
| 8 | then |
| 9 | FILE_TO_TEST=$5 |
| 10 | else |
| 11 | FILE_TO_TEST="bbb.txt" |
| 12 | fi |
| 13 | |
| 14 | if [ ! -z $6 ] |
| 15 | then |
| 16 | FILE_TO_STORE_RESULTS=$6 |
| 17 | else |
| 18 | FILE_TO_STORE_RESULTS="aaa.txt" |
| 19 | fi |
| 20 | |
| 21 | if [ ! -z $7 ] |
| 22 | then |
| 23 | TIMEOUT=$7 |
| 24 | else |
| 25 | TIMEOUT=60 |
| 26 | fi |
| 27 | |
| 28 | |
| 29 | echo "Fuel master IP: $FUEL_MASTER_IP" |
| 30 | echo "Fuel master password: $FUEL_MASTER_PASSWD" |
| 31 | echo "External IP: $EXTERNAL_IP" |
| 32 | echo "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 |
| 35 | function wait_image_active() { |
| 36 | image_state="none" |
koder aka kdanilov | 94e3a2c | 2015-03-27 11:36:34 +0200 | [diff] [blame^] | 37 | image_name="$IMAGE_NAME" |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 38 | counter=0 |
| 39 | |
gstepanov | cddbe3b | 2015-03-26 19:05:48 +0200 | [diff] [blame] | 40 | while [ ! $image_state eq "active" ] ; do |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 41 | 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 kdanilov | 94e3a2c | 2015-03-27 11:36:34 +0200 | [diff] [blame^] | 46 | if [ "$counter" -eq "$TIMEOUT" ] |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 47 | then |
| 48 | echo "Time limit exceed" |
| 49 | break |
| 50 | fi |
| 51 | done |
| 52 | } |
| 53 | |
| 54 | |
| 55 | function 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 | |
| 75 | function 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 | |
gstepanov | cddbe3b | 2015-03-26 19:05:48 +0200 | [diff] [blame] | 92 | bash run_vm.sh $FUEL_MASTER_IP $FUEL_MASTER_PASSWD $EXTERNAL_IP |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 93 | source `get_openrc` |
| 94 | list=$(nova list) |
| 95 | if [ "$list" == "" ]; then |
| 96 | echo "openrc variables are unset or set to the empty string" |
| 97 | fi |
| 98 | |
| 99 | IP=$(nova floating-ip-list | grep $FLOATING_NET | awk '{if ($5 == "-") print $2}' | head -n1) |
| 100 | |
| 101 | if [ -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 |
| 107 | fi |
| 108 | |
| 109 | VM_IP=$IP |
| 110 | echo "VM IP: $VM_IP" |
| 111 | |
| 112 | # sends images to glance |
| 113 | bash prepare.sh |
| 114 | wait_image_active |
| 115 | echo "Image has been saved" |
| 116 | VOL_ID=$(boot_vm) |
| 117 | echo "VM has been booted" |
| 118 | wait_floating_ip |
| 119 | echo "Floating IP has been obtained" |
| 120 | source `prepare_vm` |
| 121 | echo "VM has been prepared" |
gstepanov | cddbe3b | 2015-03-26 19:05:48 +0200 | [diff] [blame] | 122 | |
| 123 | # sudo bash ../single_node_test_short.sh $FILE_TO_TEST $FILE_TO_STORE_RESULTS |
| 124 | |
| 125 | ssh $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" |