Thomas Vachuska | de563cf | 2015-04-01 00:28:50 -0700 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Forms ONOS cluster using REST API. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
| 6 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 7 | . $ONOS_ROOT/tools/build/envDefaults |
| 8 | |
| 9 | ip=${1:-$OCI} |
| 10 | |
| 11 | if [ $ip = "cell" ]; then |
| 12 | ip=$OC1 |
| 13 | nodes=$(env | grep "OC[0-9]*=" | grep -v "OC1=" | cut -d= -f2) |
| 14 | else |
| 15 | shift |
| 16 | nodes=$* |
| 17 | fi |
| 18 | |
| 19 | ipPrefix=${ip%.*} |
| 20 | |
| 21 | aux=/tmp/${ipPrefix}.cluster.json |
| 22 | trap "rm -f $aux" EXIT |
| 23 | |
| 24 | echo "{ \"nodes\": [ { \"ip\": \"$ip\" }" > $aux |
| 25 | for node in $nodes; do |
| 26 | echo ", { \"ip\": \"$node\" }" >> $aux |
| 27 | done |
| 28 | echo "], \"ipPrefix\": \"$ipPrefix.*\" }" >> $aux |
| 29 | |
| 30 | for node in $ip $nodes; do |
| 31 | echo "Forming cluster on $node..." |
| 32 | curl -X POST http://$node:8181/onos/v1/cluster/configuration -d @$aux |
| 33 | done |