Whamcloud - gitweb
f66335e92d058115816e0321df60fbb8d9d2429b
[fs/lustre-release.git] / lustre / tests / mcr-routed-config.sh
1 #!/bin/bash
2
3 BASE=`hostname | sed "s/[i0-9]*$//"`
4 [ $BASE = "mcr" ] && OSTBASE=${OSTBASE:-ba} || OSTBASE=${OSTBASE:-ba-ost-}
5
6 config=${1:-$BASE.xml}
7
8 BATCH=/tmp/lmc-batch.$$
9 save_cmd() {
10     echo "$@" >> $BATCH
11 }
12
13 LMC="save_cmd"
14 LMC_REAL="../../lustre/utils/lmc -m $config"
15
16 # TCP/IP servers
17 SERVER_START=0
18 SERVER_CNT=64
19 GW_START=0
20 GW_CNT=32
21 MDS=${BASE}23
22 UUIDLIST=${UUIDLIST:-/usr/local/admin/ba-ost/UUID.txt}
23
24 echo "MDS: $MDS"
25
26 # This is needed for to create route for elan network
27 CLIENT_LO=36
28 CLIENT_HI=155
29
30 TCPBUF=1048576
31  
32 h2elan () {
33     echo $1 | sed 's/[^0-9]*//g'
34 }
35
36 h2ip () {
37     echo "${1}"
38 }
39
40 # map gateway NN to host NN (assumes mcr[22-25] are not gateways)
41 gw2node() {
42         [ $1 -gt 21 ] && echo $(($1 + 4)) || echo $1
43 }
44
45 [ -f $config ] && rm $config
46
47 ${LMC} --node $MDS --net `h2elan $MDS` elan || exit 1
48 ${LMC} --node $MDS --mds mds1 /tmp/mds1 100000 || exit 1
49 ${LMC} --lov lov1 mds1 65536 1 0
50
51 # Client node
52 #${LMC} --node client --tcpbuf $TCPBUF --net '*' tcp || exit 1
53 ${LMC} --node client --net '*' elan || exit 1
54 ${LMC} --node client --mtpt /mnt/lustre mds1 lov1
55
56 # this is crude, but effective
57 let server_per_gw=($SERVER_CNT / $GW_CNT )
58 let tot_server=$server_per_gw*$GW_CNT
59 echo "Allocating $server_per_gw OSTs per gateway."
60 echo "For a total of $tot_server Blue Arc OSTs"
61
62 let gw=$GW_START
63 let server=$SERVER_START
64 while (( $gw < $GW_CNT + GW_START ));
65 do 
66    gwnode=$BASE`gw2node $gw`
67    echo "Router: $gwnode"
68    ${LMC} --router --node $gwnode --tcpbuf $TCPBUF --net `h2ip $gwnode`  tcp || exit 1
69    ${LMC} --node $gwnode --net `h2elan $gwnode` elan|| exit 1
70    ${LMC} --node $gwnode --route elan `h2elan $gwnode` `h2elan $CLIENT_LO` `h2elan $CLIENT_HI` || exit 2
71
72    let  i=0
73    while (( $i < $server_per_gw ));
74    do
75       OST=${OSTBASE}$server
76       echo "server: $OST"
77       OBD_UUID=`awk "/$OST / { print \\$3 }" $UUIDLIST`
78       [ "$OBD_UUID" ] && OBD_UUID="--obduuid=$OBD_UUID" || echo "$OST: no UUID"
79       # server node
80       ${LMC} --node $OST --tcpbuf $TCPBUF --net $OST tcp || exit 1
81       # the device on the server
82       ${LMC} --lov lov1 --node $OST $OBD_UUID --ost bluearc || exit 3
83       # route to server
84       ${LMC} --node $gwnode --route tcp `h2ip $gwnode` $OST || exit 2
85       let server=$server+1 
86       let i=$i+1
87    done
88
89    let gw=$gw+1
90 done
91
92 $LMC_REAL --batch $BATCH
93 rm -f $BATCH