Thomas Vachuska | 82e60a9 | 2015-04-30 01:15:58 -0700 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Forms ONOS cluster using REST API of each separate instance. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
| 6 | [ $# -lt 2 ] && echo "usage: $(basename $0) ip1 ip2..." && exit 1 |
| 7 | |
| 8 | ip=$1 |
| 9 | shift |
| 10 | nodes=$* |
| 11 | |
| 12 | ipPrefix=${ip%.*} |
| 13 | |
| 14 | aux=/tmp/${ipPrefix}.cluster.json |
| 15 | trap "rm -f $aux" EXIT |
| 16 | |
| 17 | echo "{ \"nodes\": [ { \"ip\": \"$ip\" }" > $aux |
| 18 | for node in $nodes; do |
| 19 | echo ", { \"ip\": \"$node\" }" >> $aux |
| 20 | done |
| 21 | echo "], \"ipPrefix\": \"$ipPrefix.*\" }" >> $aux |
| 22 | |
| 23 | for node in $ip $nodes; do |
| 24 | echo "Forming cluster on $node..." |
| 25 | curl -X POST http://$node:8181/onos/v1/cluster/configuration -d @$aux |
| 26 | done |