Merge branch 'scripts_refactoring'
diff --git a/scripts/run_all_tests.sh b/scripts/run_all_tests.sh
index 68d9805..a300468 100644
--- a/scripts/run_all_tests.sh
+++ b/scripts/run_all_tests.sh
@@ -9,7 +9,7 @@
 DEBS=`download_debs`
 echo "Debs has been downloaded"
 
-bash run_test.sh 172.16.52.108 test37 172.16.55.2 disk_io_perf.pem
-bash run_test.sh 172.16.52.108 test37 172.16.55.2 disk_io_perf.pem
-bash run_test.sh 172.16.52.108 test37 172.16.55.2 disk_io_perf.pem
-bash run_test.sh 172.16.52.108 test37 172.16.55.2 disk_io_perf.pem
\ No newline at end of file
+bash run_test.sh 172.16.52.108  172.16.55.2 disk_io_perf.pem file_to_test.dat result.txt
+bash run_test.sh 172.16.52.108  172.16.55.2 disk_io_perf.pem file_to_test.dat result.txt
+bash run_test.sh 172.16.52.108  172.16.55.2 disk_io_perf.pem file_to_test.dat result.txt
+bash run_test.sh 172.16.52.108  172.16.55.2 disk_io_perf.pem file_to_test.dat result.txt
\ No newline at end of file
diff --git a/scripts/run_test.sh b/scripts/run_test.sh
index a4351ce..4745065 100644
--- a/scripts/run_test.sh
+++ b/scripts/run_test.sh
@@ -1,18 +1,34 @@
 function get_arguments() {
 
-    export FUEL_MASTER_IP=${1:-172.16.52.108} # << FIXME
-    export FUEL_MASTER_PASSWD=${2:-test37}
-    export EXTERNAL_IP=${3:-172.16.55.2}  # << FIXME .....
-    export KEY_FILE_NAME=${4:-disk_io_perf.pem}
-    export FILE_TO_TEST=$5 # << FIXME
-    export RESULT_FILE=$6
-    export TIMEOUT=${7:-360}
+    export FUEL_MASTER_IP=$1
 
-    if [ $KEY_FILE_NAME does not exist ];  # << FIXME
+    if [ -z "${FUEL_MASTER_IP}" ]; then echo "Fuel master node ip is not provided"; fi
+
+    export EXTERNAL_IP=$2
+
+    if [ -z "${EXTERNAL_IP}" ]; then echo "Fuel external ip is not provided"; fi
+
+    export KEY_FILE_NAME=$3
+
+    if [ -z "${KEY_FILE_NAME}" ]; then echo "Key file name is not provided"; fi
+
+    export FILE_TO_TEST=$4
+
+    if [ -z "${KEY_FILE_NAME}" ]; then echo "Key file name is not provided"; fi
+
+    if [ ! -f $KEY_FILE_NAME ];
     then
        echo "File $KEY_FILE_NAME does not exist."
     fi
 
+    export RESULT_FILE=$5
+
+    if [ -z "${RESULT_FILE}" ]; then echo "Result file name is not provided"; fi
+
+    export FUEL_MASTER_PASSWD=${6:-test37}
+    export TIMEOUT=${7:-360}
+
+
     echo "Fuel master IP: $FUEL_MASTER_IP"
     echo "Fuel master password: $FUEL_MASTER_PASSWD"
     echo "External IP: $EXTERNAL_IP"
@@ -26,7 +42,7 @@
 	image_name="$IMAGE_NAME"
     counter=0
 
-	while [ ! "$image_state" eq "active" ] ; do
+	while [ ["$image_state" == "active"] ] ; do
 		sleep 1
 		image_state=$(glance image-list | grep "$image_name" | awk '{print $12}')
 		echo $image_state
@@ -86,13 +102,17 @@
 
         if [ -z "$list" ]; then
             echo "Cannot allocate new floating ip"
-            exit
+            # exit
         fi
     fi
+
+    echo $FLOATING_NET
+    export VM_IP=$IP
+    echo "VM_IP: $VM_IP"
 }
 
-function get_openrc() {
-    source run_vm.sh "$FUEL_MASTER_IP" "$FUEL_MASTER_PASSWD" "$EXTERNAL_IP"
+function run_openrc() {
+    source run_vm.sh "$FUEL_MASTER_IP" "$FUEL_MASTER_PASSWD" "$EXTERNAL_IP" novanetwork nova
     source `get_openrc`
 
     list=$(nova list)
@@ -100,17 +120,14 @@
         echo "openrc variables are unset or set to the empty string"
     fi
 
-    VM_IP=$IP
-    echo "VM IP: $VM_IP"
-    echo 'AUTH_URL: "$OS_AUTH_URL"'
+    echo "AUTH_URL: $OS_AUTH_URL"
 }
 
-# CHECK
-shift
 get_arguments $@
 
 echo "getting openrc from controller node"
-get_openrc
+run_openrc
+nova list
 
 echo "openrc has been activated on your machine"
 get_floating_ip
@@ -134,12 +151,14 @@
 
 # sudo bash ../single_node_test_short.sh $FILE_TO_TEST $RESULT_FILE
 
-# ssh $SSH_OPTS -i $KEY_FILE_NAME ubuntu@$VM_IP \
-#     "cd /tmp/io_scenario; echo 'results' > $RESULT_FILE; \
-#     curl -X POST -d @$RESULT_FILE http://http://172.16.52.80/api/test --header 'Content-Type:application/json'"
+ssh $SSH_OPTS -i $KEY_FILE_NAME ubuntu@$VM_IP \
+     "cd /tmp/io_scenario;"
 
-nova delete $VM_NAME
-wait_vm_deleted
-echo "$VM_NAME has been deleted successfully"
-cinder delete $VOL_ID
-echo "Volume has been deleted $VOL_ID"
+# echo 'results' > $RESULT_FILE; \
+#     curl -X POST -d @$RESULT_FILE http://http://172.16.52.80/api/test --header 'Content-Type:application/json'
+
+# nova delete $VM_NAME
+# wait_vm_deleted
+# echo "$VM_NAME has been deleted successfully"
+# cinder delete $VOL_ID
+# echo "Volume has been deleted $VOL_ID"
diff --git a/scripts/run_vm.sh b/scripts/run_vm.sh
index dfd6fb3..1491f8f 100644
--- a/scripts/run_vm.sh
+++ b/scripts/run_vm.sh
@@ -2,7 +2,9 @@
 MASTER_IP=$1
 FUEL_PASSWD=$2
 NEW_IP=$3
-VM_NAME=disk-io-test2
+FIXED_NET_NAME=$4
+FLOATING_NET=$5
+VM_NAME=disk-io-test
 
 # VM_IP=$(nova floating-ip-create "$FLOATIN_NET" | grep "$FLOATIN_NET" | awk '{print $2}')
 VM_IP=172.16.55.23
@@ -11,8 +13,8 @@
 
 
 
-FIXED_NET_NAME="net04"
-FLOATING_NET="net04_ext"
+FIXED_NET_NAME="novanetwork"
+FLOATING_NET="nova"
 
 my_dir="$(dirname -- "$0")"
 source "$my_dir/config.sh"
@@ -50,6 +52,9 @@
 
 function boot_vm() {
 	FIXED_NET_ID=$(nova net-list | grep "\b${FIXED_NET_NAME}\b" | awk '{print $2}')
+	echo "FIXED NET id : $FIXED_NET_ID"
+	sleep 10
+
 	VOL_ID=$(cinder create --display-name $VOLUME_NAME $VOLUME_SIZE | grep '\bid\b' | grep available | awk '{print $4}')
 
     if [ -z $VOL_ID ]; then
@@ -82,18 +87,21 @@
 function prepare_node() {
 	# set -e
 	# set -o pipefail
-
+    echo "Preparing node"
 	COMPUTE_NODE=$($SSH_OVER_MASTER fuel node | grep compute | awk '-F|' '{gsub(" ", "", $5); print $5}')
 
-	sshpass -p${FUEL_PASSWD} scp -r ../io_scenario root@${MASTER_IP}:/tmp
+	echo "Copying io_scenario to compute node"
+	sshpass -p${FUEL_MASTER_PASSWD} scp -r ../io_scenario root@${FUEL_MASTER_IP}:/tmp
 	$SSH_OVER_MASTER scp -r /tmp/io_scenario $COMPUTE_NODE:/tmp >/dev/null
 
-	sshpass -p${FUEL_PASSWD} scp $DEBS root@${MASTER_IP}:/tmp
+	echo "Copying debs to compute node"
+	sshpass -p${FUEL_MASTER_PASSWD} scp $DEBS root@${FUEL_MASTER_IP}:/tmp
 
 	$SSH_OVER_MASTER scp $DEBS $COMPUTE_NODE:/tmp
 	$SSH_OVER_MASTER ssh $COMPUTE_NODE dpkg -i $DEBS
 
-	sshpass -p${FUEL_PASSWD} scp single_node_test_short.sh root@${MASTER_IP}:/tmp
+    echo "Copying single_node_test.sh to compute node"
+	sshpass -p${FUEL_MASTER_PASSWD} scp single_node_test_short.sh root@${FUEL_MASTER_IP}:/tmp
 	$SSH_OVER_MASTER scp /tmp/single_node_test_short.sh $COMPUTE_NODE:/tmp
 }
 
diff --git a/scripts/single_node_test_short.sh b/scripts/single_node_test_short.sh
index 489cd54..e4772e0 100644
--- a/scripts/single_node_test_short.sh
+++ b/scripts/single_node_test_short.sh
@@ -15,7 +15,7 @@
 # }
 
 function run_tests(){
-	OPTS="--test-file $TEST_FILE --type fio --iodepth 1 --iosize 10G"
+	OPTS="--test-file $TEST_FILE --type fio --iodepth 1 --iosize 10G --timeout 60"
 
 	sync ; echo 3 > /proc/sys/vm/drop_caches ; python io.py $OPTS -a randwrite --blocksize 4k -d --concurrency 1