koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | MASTER_IP=$1 |
| 3 | FUEL_PASSWD=$2 |
| 4 | |
| 5 | OS_ORIGIN_IP=192.168.0.2 |
| 6 | OS_EXT_IP=172.16.53.2 |
| 7 | VM_NAME=koder-disk-test |
| 8 | |
| 9 | FIXED_NET_NAME="net04" |
| 10 | FLOATING_NET="net04_ext" |
| 11 | |
| 12 | my_dir="$(dirname "$0")" |
| 13 | source "$my_dir/config.sh" |
| 14 | SSH_OVER_MASTER="sshpass -p${FUEL_PASSWD} ssh root@${MASTER_IP}" |
| 15 | VOLUME_NAME="test-volume" |
| 16 | VOLUME_SIZE=20 |
| 17 | VOLUME_DEVICE="/dev/vdb" |
| 18 | |
| 19 | # VM_IP=$(nova floating-ip-create "$FLOATIN_NET" | grep "$FLOATIN_NET" | awk '{print $2}') |
| 20 | VM_IP=172.16.53.18 |
| 21 | |
| 22 | function get_openrc() { |
| 23 | OPENRC=`tempfile` |
| 24 | CONTROLLER_NODE=$($SSH_OVER_MASTER fuel node | grep controller | awk '-F|' '{gsub(" ", "", $5); print $5}') |
| 25 | $SSH_OVER_MASTER ssh $CONTROLLER_NODE cat openrc 2>/dev/null | sed "s/$OS_ORIGIN_IP/$OS_EXT_IP/g" > $OPENRC |
| 26 | echo $OPENRC |
| 27 | } |
| 28 | |
| 29 | function boot_vm() { |
| 30 | FIXED_NET_ID=$(nova net-list | grep "\b${FIXED_NET_NAME}\b" | awk '{print $2}') |
| 31 | nova boot --flavor "$FLAVOR_NAME" --image "$IMAGE_NAME" --key-name "$KEYPAIR_NAME" --security-groups default --nic net-id=$FIXED_NET_ID $VM_NAME |
| 32 | nova floating-ip-associate $VM_NAME $VM_IP |
| 33 | VOL_ID=$(cinder create --display-name $VOLUME_NAME $VOLUME_SIZE | grep '\bid\b' | awk '{print $4}') |
| 34 | nova volume-attach $VM_NAME $VOL_ID $VOLUME_DEVICE |
| 35 | } |
| 36 | |
| 37 | function prepare_vm() { |
| 38 | scp -i "$KEY_FILE_NAME" -r ../io_scenario ubuntu@${VM_IP}:/tmp |
| 39 | scp -i "$KEY_FILE_NAME" $DEBS ubuntu@${VM_IP}:/tmp |
| 40 | scp -i "$KEY_FILE_NAME" single_node_test_short.sh ubuntu@${VM_IP}:/tmp |
| 41 | ssh -i "$KEY_FILE_NAME" ubuntu@${VM_IP} sudo dpkg -i $DEBS |
| 42 | } |
| 43 | |
| 44 | function prepare_node() { |
| 45 | COMPUTE_NODE=$($SSH_OVER_MASTER fuel node | grep compute | awk '-F|' '{gsub(" ", "", $5); print $5}') |
| 46 | |
| 47 | sshpass -p${FUEL_PASSWD} scp -r ../io_scenario root@${MASTER_IP}:/tmp |
| 48 | $SSH_OVER_MASTER scp -r /tmp/io_scenario $COMPUTE_NODE:/tmp |
| 49 | |
| 50 | sshpass -p${FUEL_PASSWD} scp $DEBS root@${MASTER_IP}:/tmp |
| 51 | |
| 52 | $SSH_OVER_MASTER scp $DEBS $COMPUTE_NODE:/tmp |
| 53 | $SSH_OVER_MASTER ssh $COMPUTE_NODE dpkg -i $DEBS |
| 54 | |
| 55 | sshpass -p${FUEL_PASSWD} scp single_node_test_short.sh root@${MASTER_IP}:/tmp |
| 56 | $SSH_OVER_MASTER scp /tmp/single_node_test_short.sh $COMPUTE_NODE:/tmp |
| 57 | } |
| 58 | |
| 59 | function download_debs() { |
| 60 | pushd /tmp >/dev/null |
| 61 | rm -f *.deb >/dev/null |
| 62 | aptitude download libibverbs1 librdmacm1 libaio1 fio >/dev/null |
| 63 | popd >/dev/null |
| 64 | echo /tmp/*.deb |
| 65 | } |
| 66 | |
| 67 | DEBS=`download_debs` |
| 68 | OPENRC=`get_openrc` |
| 69 | source $OPENRC |
| 70 | rm $OPENRC |
| 71 | |
| 72 | boot_vm |
| 73 | prepare_vm |
| 74 | |
| 75 | |