blob: 207b89ecfc144b27562ca1d2f97d010406c89aa3 [file] [log] [blame]
Masayoshi Kobayashif358ff52013-03-22 00:31:59 +00001#! /bin/bash
Masayoshi Kobayashic18e3b62013-04-08 19:46:13 +00002if [ 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
5elif [ $# != 1 ]; then
6 echo "$0 hostfile"
Masayoshi Kobayashif358ff52013-03-22 00:31:59 +00007 exit
8fi
9
Masayoshi Kobayashic18e3b62013-04-08 19:46:13 +000010basename=$ONOS_CLUSTER_BASENAME
Masayoshi Kobayashie9161902013-06-19 11:34:52 -070011## Shell Var can't handle "-" so replace it with "_"
12basename_var=`echo $ONOS_CLUSTER_BASENAME | sed 's/\-/_/g'`
13
Masayoshi Kobayashic18e3b62013-04-08 19:46:13 +000014NR_NODES=$ONOS_CLUSTER_NR_NODES
15hosts_file=$1
16
Masayoshi Kobayashif358ff52013-03-22 00:31:59 +000017for 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
24done
25cp template/onsdemo_core.py ${basename}1/onsdemo.py
26
Masayoshi Kobayashie9161902013-06-19 11:34:52 -070027## Shell var can't handle "-" so replace it with "_"
28cat $hosts_file | sed 's/\-/\_/g' | awk '{printf("%s=%s\n",$2,$1)}' > .tmp
29
Masayoshi Kobayashif358ff52013-03-22 00:31:59 +000030for 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 Kobayashie9161902013-06-19 11:34:52 -070033 sed "s/__TUNNEL__/TUNNEL\=\(\"1 $n ${basename_var}1\"\)/g" > ${basename}${n}/tunnel_onsdemo.sh
Masayoshi Kobayashif358ff52013-03-22 00:31:59 +000034 chmod 755 ${basename}${n}/tunnel_onsdemo.sh
35done
36
37cat template/tunnel_onsdemo_core_template.sh | awk '{if(NR==2){system("cat .tmp")}else{print $0}}' |\
Masayoshi Kobayashie9161902013-06-19 11:34:52 -070038 sed "s/__basename__/${basename_var}/g" > ${basename}1/tunnel_onsdemo.sh
Masayoshi Kobayashif358ff52013-03-22 00:31:59 +000039 chmod 755 ${basename}1/tunnel_onsdemo.sh