Ensure cluster metadata is setup as part of onos-run-karaf
Change-Id: I88e61459cec6af8a2762a439ece6fc4d33d87ee4
diff --git a/tools/package/onos-run-karaf b/tools/package/onos-run-karaf
index 48359ea..5da0ea6 100755
--- a/tools/package/onos-run-karaf
+++ b/tools/package/onos-run-karaf
@@ -25,6 +25,19 @@
# FIXME: for now we're running using the karaf client; later use raw SSH
unset ONOS_USE_SSH
+# Create config/cluster.json (cluster metadata)
+ONOS_IP=${ONOS_IP:-127.0.0.1}
+IP="${1:-$ONOS_IP}"
+echo "Creating local cluster configs for IP $IP..."
+[ -d $ONOS_HOME/config ] || mkdir -p $ONOS_HOME/config
+cat > $ONOS_HOME/config/cluster.json <<EOF
+{
+ "name": "default",
+ "nodes": [ {"id": "$IP", "ip": "$IP", "port": 9876 } ],
+ "partitions": [ { "id": 1, "members": [ "$IP" ] } ]
+}
+EOF
+
# Start ONOS as a server, but include any specified options
./bin/onos-service server "$@" &>onos.log &
echo "$!" > /tmp/onos.pid
@@ -41,4 +54,5 @@
RETRY_COUNT=$[$RETRY_COUNT-1]
sleep 1
done
-echo "Fail to open karaf.log"
\ No newline at end of file
+echo "Fail to open karaf.log"
+