gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 1 | function get_arguments() { |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 2 | |
koder aka kdanilov | fb23a26 | 2015-03-27 16:50:58 +0200 | [diff] [blame^] | 3 | 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 |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 12 | then |
| 13 | echo "File $KEY_FILE_NAME does not exist." |
| 14 | fi |
gstepanov | cddbe3b | 2015-03-26 19:05:48 +0200 | [diff] [blame] | 15 | |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 16 | 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 | } |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 22 | |
| 23 | # note : function will works properly only when image dame is single string without spaces that can brake awk |
| 24 | function wait_image_active() { |
| 25 | image_state="none" |
koder aka kdanilov | 94e3a2c | 2015-03-27 11:36:34 +0200 | [diff] [blame] | 26 | image_name="$IMAGE_NAME" |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 27 | counter=0 |
| 28 | |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 29 | while [ ! "$image_state" eq "active" ] ; do |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 30 | sleep 1 |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 31 | image_state=$(glance image-list | grep "$image_name" | awk '{print $12}') |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 32 | echo $image_state |
| 33 | counter=$((counter + 1)) |
| 34 | |
koder aka kdanilov | 94e3a2c | 2015-03-27 11:36:34 +0200 | [diff] [blame] | 35 | if [ "$counter" -eq "$TIMEOUT" ] |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 36 | then |
| 37 | echo "Time limit exceed" |
| 38 | break |
| 39 | fi |
| 40 | done |
| 41 | } |
| 42 | |
| 43 | |
| 44 | function wait_floating_ip() { |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 45 | floating_ip="|" |
| 46 | vm_name=$VM_NAME |
| 47 | counter=0 |
| 48 | |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 49 | while [ "$floating_ip" != "|" ] ; do |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 50 | sleep 1 |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 51 | floating_ip=$(nova floating-ip-list | grep "$vm_name" | awk '{print $13}' | head -1) |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 52 | 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 | |
| 63 | function wait_vm_deleted() { |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 64 | vm_name=$(nova list| grep "$VM_NAME"| awk '{print $4}'| head -1) |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 65 | counter=0 |
| 66 | |
| 67 | while [ ! -z $vm_name ] ; do |
| 68 | sleep 1 |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 69 | vm_name=$(nova list| grep "$VM_NAME"| awk '{print $4}'| head -1) |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 70 | counter=$((counter + 1)) |
| 71 | |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 72 | if [ "$counter" -eq $TIMEOUT ] |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 73 | then |
| 74 | echo "Time limit exceed" |
| 75 | break |
| 76 | fi |
| 77 | done |
| 78 | } |
| 79 | |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 80 | |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 81 | function get_floating_ip() { |
| 82 | IP=$(nova floating-ip-list | grep "$FLOATING_NET" | awk '{if ($5 == "-") print $2}' | head -n1) |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 83 | |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 84 | if [ -z "$IP" ]; then # fix net name |
| 85 | IP=$(nova floating-ip-create "$FLOATING_NET"| awk '{print $2}') |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 86 | |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 87 | if [ -z "$list" ]; then |
| 88 | echo "Cannot allocate new floating ip" |
| 89 | exit |
| 90 | fi |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 91 | fi |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 92 | } |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 93 | |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 94 | function get_openrc() { |
| 95 | source run_vm.sh "$FUEL_MASTER_IP" "$FUEL_MASTER_PASSWD" "$EXTERNAL_IP" |
| 96 | source `get_openrc` |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 97 | |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 98 | 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 kdanilov | fb23a26 | 2015-03-27 16:50:58 +0200 | [diff] [blame^] | 108 | # CHECK |
| 109 | shift |
| 110 | get_arguments $@ |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 111 | |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 112 | echo "getting openrc from controller node" |
| 113 | get_openrc |
koder aka kdanilov | fb23a26 | 2015-03-27 16:50:58 +0200 | [diff] [blame^] | 114 | |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 115 | echo "openrc has been activated on your machine" |
| 116 | get_floating_ip |
koder aka kdanilov | fb23a26 | 2015-03-27 16:50:58 +0200 | [diff] [blame^] | 117 | |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 118 | echo "floating ip has been found" |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 119 | bash prepare.sh |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 120 | echo "Image has been sended to glance" |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 121 | wait_image_active |
| 122 | echo "Image has been saved" |
koder aka kdanilov | fb23a26 | 2015-03-27 16:50:58 +0200 | [diff] [blame^] | 123 | |
| 124 | BOOT_LOG_FILE=`tempfile` |
| 125 | boot_vm | tee "$BOOT_LOG_FILE" |
| 126 | VOL_ID=$(cat "$BOOT_LOG_FILE" | grep "VOL_ID=" | sed 's/VOL_ID=//') |
| 127 | rm "$BOOT_LOG_FILE" |
| 128 | |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 129 | echo "VM has been booted" |
| 130 | wait_floating_ip |
| 131 | echo "Floating IP has been obtained" |
| 132 | source `prepare_vm` |
| 133 | echo "VM has been prepared" |
gstepanov | cddbe3b | 2015-03-26 19:05:48 +0200 | [diff] [blame] | 134 | |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 135 | # sudo bash ../single_node_test_short.sh $FILE_TO_TEST $RESULT_FILE |
gstepanov | cddbe3b | 2015-03-26 19:05:48 +0200 | [diff] [blame] | 136 | |
koder aka kdanilov | ac16aae | 2015-03-27 12:28:31 +0200 | [diff] [blame] | 137 | # ssh $SSH_OPTS -i $KEY_FILE_NAME ubuntu@$VM_IP \ |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 138 | # "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'" |
gstepanov | cddbe3b | 2015-03-26 19:05:48 +0200 | [diff] [blame] | 140 | |
gstepanov | 3d2a915 | 2015-03-27 15:46:20 +0200 | [diff] [blame] | 141 | nova delete $VM_NAME |
| 142 | wait_vm_deleted |
| 143 | echo "$VM_NAME has been deleted successfully" |
| 144 | cinder delete $VOL_ID |
| 145 | echo "Volume has been deleted $VOL_ID" |