Added ability to form a cluster via REST API.

Change-Id: Ib71f6b4caed1b1c4b9db78596ee35bf5cab05184
diff --git a/tools/test/bin/onos-form-cluster b/tools/test/bin/onos-form-cluster
new file mode 100755
index 0000000..ea50968
--- /dev/null
+++ b/tools/test/bin/onos-form-cluster
@@ -0,0 +1,33 @@
+#!/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
\ No newline at end of file