Thomas Vachuska | de563cf | 2015-04-01 00:28:50 -0700 | [diff] [blame] | 1 | #!/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 Vachuska | 3c831fa | 2015-08-17 18:44:15 -0700 | [diff] [blame] | 9 | # Scan arguments for user/password or other options... |
Thiago Santos | 7a174cf | 2016-09-01 14:56:54 -0300 | [diff] [blame] | 10 | while getopts u:p:s: o; do |
Thomas Vachuska | 3c831fa | 2015-08-17 18:44:15 -0700 | [diff] [blame] | 11 | case "$o" in |
| 12 | u) user=$OPTARG;; |
| 13 | p) password=$OPTARG;; |
Thiago Santos | 7a174cf | 2016-09-01 14:56:54 -0300 | [diff] [blame] | 14 | s) partitionsize=$OPTARG;; |
Thomas Vachuska | 3c831fa | 2015-08-17 18:44:15 -0700 | [diff] [blame] | 15 | esac |
| 16 | done |
Phil Huang | 5f9603d | 2016-01-21 01:01:09 +0800 | [diff] [blame] | 17 | ONOS_WEB_USER=${ONOS_WEB_USER:-onos} # ONOS WEB User defaults to 'onos' |
| 18 | ONOS_WEB_PASS=${ONOS_WEB_PASS:-rocks} # ONOS WEB Password defaults to 'rocks' |
| 19 | user=${user:-$ONOS_WEB_USER} |
| 20 | password=${password:-$ONOS_WEB_PASS} |
Thomas Vachuska | 3c831fa | 2015-08-17 18:44:15 -0700 | [diff] [blame] | 21 | let OPC=$OPTIND-1 |
| 22 | shift $OPC |
| 23 | |
Thomas Vachuska | 132001a | 2015-06-09 02:50:33 -0700 | [diff] [blame] | 24 | node=${1:-$OCI} |
Thomas Vachuska | de563cf | 2015-04-01 00:28:50 -0700 | [diff] [blame] | 25 | |
Thomas Vachuska | 132001a | 2015-06-09 02:50:33 -0700 | [diff] [blame] | 26 | if [ $node = "cell" ]; then |
Thomas Vachuska | 3c831fa | 2015-08-17 18:44:15 -0700 | [diff] [blame] | 27 | nodes=${ONOS_INSTANCES} |
Thomas Vachuska | 132001a | 2015-06-09 02:50:33 -0700 | [diff] [blame] | 28 | node=${OCI} |
Thomas Vachuska | de563cf | 2015-04-01 00:28:50 -0700 | [diff] [blame] | 29 | else |
Thomas Vachuska | 132001a | 2015-06-09 02:50:33 -0700 | [diff] [blame] | 30 | nodes="$@" |
Thomas Vachuska | de563cf | 2015-04-01 00:28:50 -0700 | [diff] [blame] | 31 | fi |
| 32 | |
Thiago Santos | 7a174cf | 2016-09-01 14:56:54 -0300 | [diff] [blame] | 33 | if ! [ -z ${partitionsize} ]; then |
| 34 | partitionarg="-s ${partitionsize}" |
| 35 | else |
| 36 | partitionarg= |
| 37 | fi |
| 38 | |
Thomas Vachuska | 132001a | 2015-06-09 02:50:33 -0700 | [diff] [blame] | 39 | set -x |
Thomas Vachuska | de563cf | 2015-04-01 00:28:50 -0700 | [diff] [blame] | 40 | |
Thiago Santos | 7a174cf | 2016-09-01 14:56:54 -0300 | [diff] [blame] | 41 | ssh $ONOS_USER@$node $ONOS_INSTALL_DIR/bin/onos-form-cluster -u $user -p $partitionarg $password $nodes |