Yuta HIGUCHI

Support running onos-config in parallel against each hosts in cell

Change-Id: Ifc2145068b92d320d42178afb05cd1bb825f86d2
...@@ -9,13 +9,14 @@ ...@@ -9,13 +9,14 @@
9 remote=$ONOS_USER@${1:-$OCI} 9 remote=$ONOS_USER@${1:-$OCI}
10 10
11 # Generate a cluster.json from the ON* environment variables 11 # Generate a cluster.json from the ON* environment variables
12 -CDEF_FILE=/tmp/cluster.json 12 +CDEF_FILE=/tmp/${remote}.cluster.json
13 echo "{ \"nodes\":[" > $CDEF_FILE 13 echo "{ \"nodes\":[" > $CDEF_FILE
14 for node in $(env | sort | egrep "OC[2-9]+" | cut -d= -f2); do 14 for node in $(env | sort | egrep "OC[2-9]+" | cut -d= -f2); do
15 echo " { \"id\": \"$node\", \"ip\": \"$node\", \"tcpPort\": 9876 }," >> $CDEF_FILE 15 echo " { \"id\": \"$node\", \"ip\": \"$node\", \"tcpPort\": 9876 }," >> $CDEF_FILE
16 done 16 done
17 echo " { \"id\": \"$OC1\", \"ip\": \"$OC1\", \"tcpPort\": 9876 }" >> $CDEF_FILE 17 echo " { \"id\": \"$OC1\", \"ip\": \"$OC1\", \"tcpPort\": 9876 }" >> $CDEF_FILE
18 echo "]}" >> $CDEF_FILE 18 echo "]}" >> $CDEF_FILE
19 +scp -q $CDEF_FILE $remote:$ONOS_INSTALL_DIR/config/cluster.json
19 20
20 ssh $remote " 21 ssh $remote "
21 sudo perl -pi.bak -e \"s/ <interface>.*</ <interface>${ONOS_NIC:-192.168.56.*}</g\" \ 22 sudo perl -pi.bak -e \"s/ <interface>.*</ <interface>${ONOS_NIC:-192.168.56.*}</g\" \
...@@ -26,17 +27,22 @@ ssh $remote " ...@@ -26,17 +27,22 @@ ssh $remote "
26 echo \"onos.ip = \$(ifconfig | grep $ONOS_NIC | cut -d: -f2 | cut -d\\ -f1)\" \ 27 echo \"onos.ip = \$(ifconfig | grep $ONOS_NIC | cut -d: -f2 | cut -d\\ -f1)\" \
27 >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/system.properties 28 >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/system.properties
28 " 29 "
29 -scp -q $CDEF_FILE $remote:$ONOS_INSTALL_DIR/config/
30 30
31 # Generate a default tablets.json from the ON* environment variables 31 # Generate a default tablets.json from the ON* environment variables
32 -TDEF_FILE=/tmp/tablets.json 32 +TDEF_FILE=/tmp/${remote}.tablets.json
33 +nodes=( $(env | sort | egrep "OC[0-9]+" | cut -d= -f2) )
33 echo "{ \"default\":[" > $TDEF_FILE 34 echo "{ \"default\":[" > $TDEF_FILE
34 -for node in $(env | sort | egrep "OC[2-9]+" | cut -d= -f2); do 35 +while [ ${#nodes[@]} -gt 0 ]; do
35 - echo " { \"id\": \"$node\", \"ip\": \"$node\", \"tcpPort\": 9876 }," >> $TDEF_FILE 36 + node=${nodes[0]}
37 + nodes=( ${nodes[@]:1} )
38 + if [ "${#nodes[@]}" -ne "0" ]; then
39 + echo " { \"id\": \"$node\", \"ip\": \"$node\", \"tcpPort\": 9876 }," >> $TDEF_FILE
40 + else
41 + echo " { \"id\": \"$node\", \"ip\": \"$node\", \"tcpPort\": 9876 }" >> $TDEF_FILE
42 + fi
36 done 43 done
37 -echo " { \"id\": \"$OC1\", \"ip\": \"$OC1\", \"tcpPort\": 9876 }" >> $TDEF_FILE
38 echo "]}" >> $TDEF_FILE 44 echo "]}" >> $TDEF_FILE
39 -scp -q $TDEF_FILE $remote:$ONOS_INSTALL_DIR/config/ 45 +scp -q $TDEF_FILE $remote:$ONOS_INSTALL_DIR/config/tablets.json
40 46
41 47
42 # copy tools/package/config/ to remote 48 # copy tools/package/config/ to remote
......