blob: ddc5cfc5ef28522de86b1b08b423b0782dd0baaa [file] [log] [blame]
koder aka kdanilov8ad6e812015-03-22 14:42:18 +02001#!/bin/bash
2MASTER_IP=$1
3FUEL_PASSWD=$2
4
5OS_ORIGIN_IP=192.168.0.2
6OS_EXT_IP=172.16.53.2
7VM_NAME=koder-disk-test
8
9FIXED_NET_NAME="net04"
10FLOATING_NET="net04_ext"
11
12my_dir="$(dirname "$0")"
13source "$my_dir/config.sh"
14SSH_OVER_MASTER="sshpass -p${FUEL_PASSWD} ssh root@${MASTER_IP}"
15VOLUME_NAME="test-volume"
16VOLUME_SIZE=20
17VOLUME_DEVICE="/dev/vdb"
18
19# VM_IP=$(nova floating-ip-create "$FLOATIN_NET" | grep "$FLOATIN_NET" | awk '{print $2}')
20VM_IP=172.16.53.18
21
22function 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
29function 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
37function 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
44function 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
59function 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
67DEBS=`download_debs`
68OPENRC=`get_openrc`
69source $OPENRC
70rm $OPENRC
71
72boot_vm
73prepare_vm
74
75