Masayoshi Kobayashi | f358ff5 | 2013-03-22 00:31:59 +0000 | [diff] [blame] | 1 | #! /bin/bash |
Masayoshi Kobayashi | c18e3b6 | 2013-04-08 19:46:13 +0000 | [diff] [blame] | 2 | if [ x$ONOS_CLUSTER_BASENAME == "x" -o x$ONOS_CLUSTER_NR_NODES == "x" ]; then |
| 3 | echo "set environment variable ONOS_CLUSTER_BASENAME and ONOS_CLUSTER_NR_NODES" |
| 4 | exit |
| 5 | elif [ $# != 1 ]; then |
| 6 | echo "$0 hostfile" |
Masayoshi Kobayashi | f358ff5 | 2013-03-22 00:31:59 +0000 | [diff] [blame] | 7 | exit |
| 8 | fi |
| 9 | |
Masayoshi Kobayashi | c18e3b6 | 2013-04-08 19:46:13 +0000 | [diff] [blame] | 10 | basename=$ONOS_CLUSTER_BASENAME |
Masayoshi Kobayashi | e916190 | 2013-06-19 11:34:52 -0700 | [diff] [blame] | 11 | ## Shell Var can't handle "-" so replace it with "_" |
| 12 | basename_var=`echo $ONOS_CLUSTER_BASENAME | sed 's/\-/_/g'` |
| 13 | |
Masayoshi Kobayashi | c18e3b6 | 2013-04-08 19:46:13 +0000 | [diff] [blame] | 14 | NR_NODES=$ONOS_CLUSTER_NR_NODES |
| 15 | hosts_file=$1 |
| 16 | |
Masayoshi Kobayashi | f358ff5 | 2013-03-22 00:31:59 +0000 | [diff] [blame] | 17 | for n in `seq 2 $NR_NODES`; do |
| 18 | if [ $n == 2 ]; then |
| 19 | nrsw=50 |
| 20 | else |
| 21 | nrsw=25 |
| 22 | fi |
| 23 | cat template/onsdemo_edge_template.py | sed "s/__NWID__/$n/g" | sed "s/__NRSW__/${nrsw}/g" > ${basename}${n}/onsdemo.py |
| 24 | done |
| 25 | cp template/onsdemo_core.py ${basename}1/onsdemo.py |
| 26 | |
Masayoshi Kobayashi | e916190 | 2013-06-19 11:34:52 -0700 | [diff] [blame] | 27 | ## Shell var can't handle "-" so replace it with "_" |
| 28 | cat $hosts_file | sed 's/\-/\_/g' | awk '{printf("%s=%s\n",$2,$1)}' > .tmp |
| 29 | |
Masayoshi Kobayashi | f358ff5 | 2013-03-22 00:31:59 +0000 | [diff] [blame] | 30 | for n in `seq 2 $NR_NODES`; do |
| 31 | cat template/tunnel_onsdemo_edge_template.sh | awk '{if(NR==2){system("cat .tmp")}else{print $0}}' |\ |
| 32 | sed "s/__NWID__/$n/g" |\ |
Masayoshi Kobayashi | e916190 | 2013-06-19 11:34:52 -0700 | [diff] [blame] | 33 | sed "s/__TUNNEL__/TUNNEL\=\(\"1 $n ${basename_var}1\"\)/g" > ${basename}${n}/tunnel_onsdemo.sh |
Masayoshi Kobayashi | f358ff5 | 2013-03-22 00:31:59 +0000 | [diff] [blame] | 34 | chmod 755 ${basename}${n}/tunnel_onsdemo.sh |
| 35 | done |
| 36 | |
| 37 | cat template/tunnel_onsdemo_core_template.sh | awk '{if(NR==2){system("cat .tmp")}else{print $0}}' |\ |
Masayoshi Kobayashi | e916190 | 2013-06-19 11:34:52 -0700 | [diff] [blame] | 38 | sed "s/__basename__/${basename_var}/g" > ${basename}1/tunnel_onsdemo.sh |
Masayoshi Kobayashi | f358ff5 | 2013-03-22 00:31:59 +0000 | [diff] [blame] | 39 | chmod 755 ${basename}1/tunnel_onsdemo.sh |