blob: 925c6ff5a7d6b411e8ff42e0b1111a4d5ceb7f46 [file] [log] [blame]
Thomas Vachuska82e60a92015-04-30 01:15:58 -07001#!/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
8ip=$1
9shift
10nodes=$*
11
12ipPrefix=${ip%.*}
13
14aux=/tmp/${ipPrefix}.cluster.json
15trap "rm -f $aux" EXIT
16
17echo "{ \"nodes\": [ { \"ip\": \"$ip\" }" > $aux
18for node in $nodes; do
19 echo ", { \"ip\": \"$node\" }" >> $aux
20done
21echo "], \"ipPrefix\": \"$ipPrefix.*\" }" >> $aux
22
23for node in $ip $nodes; do
24 echo "Forming cluster on $node..."
25 curl -X POST http://$node:8181/onos/v1/cluster/configuration -d @$aux
26done