blob: ea50968074e9a5ae4edef819ba0207f6aaf78adf [file] [log] [blame]
#!/bin/bash
# -----------------------------------------------------------------------------
# Forms ONOS cluster using REST API.
# -----------------------------------------------------------------------------
[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
. $ONOS_ROOT/tools/build/envDefaults
ip=${1:-$OCI}
if [ $ip = "cell" ]; then
ip=$OC1
nodes=$(env | grep "OC[0-9]*=" | grep -v "OC1=" | cut -d= -f2)
else
shift
nodes=$*
fi
ipPrefix=${ip%.*}
aux=/tmp/${ipPrefix}.cluster.json
trap "rm -f $aux" EXIT
echo "{ \"nodes\": [ { \"ip\": \"$ip\" }" > $aux
for node in $nodes; do
echo ", { \"ip\": \"$node\" }" >> $aux
done
echo "], \"ipPrefix\": \"$ipPrefix.*\" }" >> $aux
for node in $ip $nodes; do
echo "Forming cluster on $node..."
curl -X POST http://$node:8181/onos/v1/cluster/configuration -d @$aux
done