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