Whamcloud - gitweb
land 0.5.20.3 b_devel onto HEAD (b_devel will remain)
[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=32
19 GW_START=0
20 GW_CNT=16
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=38
28 CLIENT_HI=191
29
30 TCPBUF=1048576
31  
32 h2elan () {
33     echo $1 | sed 's/[^0-9]*//g'
34 }
35
36 h2tcp () {
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} --add net --node $MDS --nid `h2elan $MDS` --nettype elan || exit 1
48 ${LMC} --add mds --node $MDS --mds mds1 --dev /tmp/mds1 --size 100000 || exit 1
49 ${LMC} --add lov --lov lov1 --mds mds1 --stripe_sz 65536 --stripe_cnt 1 --stripe_pattern 0
50
51 # Client node
52 #${LMC} --add net --node client --tcpbuf $TCPBUF --nid '*' --nettype tcp || exit 1
53 ${LMC} --add net --node client --nid '*' --nettype elan || exit 1
54 ${LMC} --add mtpt --node client --path /mnt/lustre --mds mds1 --lov 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} --add net --router --node $gwnode --tcpbuf $TCPBUF --nid `h2tcp $gwnode`  --nettype tcp || exit 1
69    ${LMC} --add net --node $gwnode --nid `h2elan $gwnode` --nettype elan || exit 1
70    ${LMC} --add route --node $gwnode --nettype elan --gw `h2elan $gwnode` --lo `h2elan $CLIENT_LO` --hi `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       OST_UUID=`awk "/$OST / { print \\$3 }" $UUIDLIST`
78       [ "$OST_UUID" ] && OST_UUID="--ostuuid $OST_UUID" || echo "$OST: no UUID"
79       # server node
80       ${LMC} --add net --node $OST --tcpbuf $TCPBUF --nid $OST --nettype tcp || exit 1
81       # the device on the server
82       ${LMC} --add ost --lov lov1 --node $OST $OBD_UUID --dev bluearc || exit 3
83       # route to server
84       ${LMC} --add route --node $gwnode --nettype tcp --gw `h2tcp $gwnode` --lo $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