blob: a9f6a5bcae4b28f7ab7bcf7f6262e3ea7e4afcc0 [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
Thomas Vachuska3c831fa2015-08-17 18:44:15 -07009# Scan arguments for user/password or other options...
Thiago Santos7a174cf2016-09-01 14:56:54 -030010while getopts u:p:s: o; do
Thomas Vachuska3c831fa2015-08-17 18:44:15 -070011 case "$o" in
12 u) user=$OPTARG;;
13 p) password=$OPTARG;;
Thiago Santos7a174cf2016-09-01 14:56:54 -030014 s) partitionsize=$OPTARG;;
Thomas Vachuska3c831fa2015-08-17 18:44:15 -070015 esac
16done
Phil Huang5f9603d2016-01-21 01:01:09 +080017ONOS_WEB_USER=${ONOS_WEB_USER:-onos} # ONOS WEB User defaults to 'onos'
18ONOS_WEB_PASS=${ONOS_WEB_PASS:-rocks} # ONOS WEB Password defaults to 'rocks'
19user=${user:-$ONOS_WEB_USER}
20password=${password:-$ONOS_WEB_PASS}
Thomas Vachuska3c831fa2015-08-17 18:44:15 -070021let OPC=$OPTIND-1
22shift $OPC
23
Thomas Vachuska132001a2015-06-09 02:50:33 -070024node=${1:-$OCI}
Thomas Vachuskade563cf2015-04-01 00:28:50 -070025
Thomas Vachuska132001a2015-06-09 02:50:33 -070026if [ $node = "cell" ]; then
Thomas Vachuska3c831fa2015-08-17 18:44:15 -070027 nodes=${ONOS_INSTANCES}
Thomas Vachuska132001a2015-06-09 02:50:33 -070028 node=${OCI}
Thomas Vachuskade563cf2015-04-01 00:28:50 -070029else
Thomas Vachuska132001a2015-06-09 02:50:33 -070030 nodes="$@"
Thomas Vachuskade563cf2015-04-01 00:28:50 -070031fi
32
Thiago Santos7a174cf2016-09-01 14:56:54 -030033if ! [ -z ${partitionsize} ]; then
34 partitionarg="-s ${partitionsize}"
35else
36 partitionarg=
37fi
38
Thomas Vachuska132001a2015-06-09 02:50:33 -070039set -x
Thomas Vachuskade563cf2015-04-01 00:28:50 -070040
Thiago Santos7a174cf2016-09-01 14:56:54 -030041ssh $ONOS_USER@$node $ONOS_INSTALL_DIR/bin/onos-form-cluster -u $user -p $partitionarg $password $nodes