blob: ea50968074e9a5ae4edef819ba0207f6aaf78adf [file] [log] [blame]
Thomas Vachuskade563cf2015-04-01 00:28:50 -07001#!/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
9ip=${1:-$OCI}
10
11if [ $ip = "cell" ]; then
12 ip=$OC1
13 nodes=$(env | grep "OC[0-9]*=" | grep -v "OC1=" | cut -d= -f2)
14else
15 shift
16 nodes=$*
17fi
18
19ipPrefix=${ip%.*}
20
21aux=/tmp/${ipPrefix}.cluster.json
22trap "rm -f $aux" EXIT
23
24echo "{ \"nodes\": [ { \"ip\": \"$ip\" }" > $aux
25for node in $nodes; do
26 echo ", { \"ip\": \"$node\" }" >> $aux
27done
28echo "], \"ipPrefix\": \"$ipPrefix.*\" }" >> $aux
29
30for node in $ip $nodes; do
31 echo "Forming cluster on $node..."
32 curl -X POST http://$node:8181/onos/v1/cluster/configuration -d @$aux
33done