Thomas Vachuska | b826190 | 2016-05-04 00:10:42 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
Thomas Vachuska | a25cda2 | 2016-05-09 15:46:48 -0700 | [diff] [blame] | 3 | # Applies the settings in the specified cell file or lists current cell |
| 4 | # definition if no cell file is given. |
Thomas Vachuska | b826190 | 2016-05-04 00:10:42 -0700 | [diff] [blame] | 5 | # ----------------------------------------------------------------------------- |
| 6 | |
Thomas Vachuska | 77a63e6 | 2016-05-09 21:02:39 -0700 | [diff] [blame^] | 7 | # Sets the primary instance to the specified instance number. |
| 8 | function setPrimaryInstance { |
| 9 | export OCI=$(env | egrep "OC[0-9]+" | sort | egrep OC${1:-1} | cut -d= -f2) |
| 10 | echo $OCI |
| 11 | } |
| 12 | |
Thomas Vachuska | a25cda2 | 2016-05-09 15:46:48 -0700 | [diff] [blame] | 13 | cell=$1 |
| 14 | case "$cell" in |
| 15 | "borrow") |
| 16 | aux="/tmp/cell-$$" |
| 17 | curl -sS -X POST "http://$CELL_WARDEN:4321/?duration=${2:-0}&user=${3:-$(id -un)}" \ |
| 18 | -d "$(cat ~/.ssh/id_rsa.pub)" > $aux |
| 19 | . $aux |
| 20 | rm -f $aux |
| 21 | export ONOS_INSTANCES=$(env | grep 'OC[0-9]*=' | sort | cut -d= -f2) |
| 22 | setPrimaryInstance 1 >/dev/null |
| 23 | onos-verify-cell |
| 24 | ;; |
| 25 | "return") |
| 26 | curl -sS -X DELETE "http://$CELL_WARDEN:4321/?user=${2:-$(id -un)}" |
| 27 | unset ONOS_CELL ONOS_NIC ONOS_IP ONOS_APPS ONOS_BOOT_FEATURES |
| 28 | unset OCI OCN OCT ONOS_INSTANCES ONOS_FEATURES |
| 29 | unset $(env | sed -n 's:\(^OC[0-9]\{1,\}\)=.*:\1 :g p') |
| 30 | ;; |
Thomas Vachuska | b826190 | 2016-05-04 00:10:42 -0700 | [diff] [blame] | 31 | |
Thomas Vachuska | a25cda2 | 2016-05-09 15:46:48 -0700 | [diff] [blame] | 32 | "status") |
| 33 | curl -sS "http://$CELL_WARDEN:4321/" | sort |
| 34 | ;; |
| 35 | |
| 36 | "") |
| 37 | env | egrep "ONOS_CELL" |
| 38 | env | egrep "OCI" |
| 39 | env | egrep "OC[0-9]+" | sort |
| 40 | env | egrep "OC[NT]" |
| 41 | env | egrep "ONOS_" | egrep -v 'ONOS_ROOT|ONOS_CELL|ONOS_INSTANCES' | sort |
| 42 | ;; |
| 43 | |
| 44 | *) |
| 45 | [ ! -f $ONOS_ROOT/tools/test/cells/$1 ] && \ |
| 46 | echo "No such cell: $1" >&2 && return 1 |
| 47 | unset ONOS_CELL ONOS_NIC ONOS_IP ONOS_APPS ONOS_BOOT_FEATURES |
| 48 | unset OCI OCN OCT ONOS_INSTANCES ONOS_FEATURES |
| 49 | unset $(env | sed -n 's:\(^OC[0-9]\{1,\}\)=.*:\1 :g p') |
| 50 | export ONOS_USER=${ONOS_USER:-sdn} |
| 51 | export ONOS_GROUP=${ONOS_GROUP:-sdn} |
| 52 | export ONOS_WEB_USER=onos |
| 53 | export ONOS_WEB_PASS=rocks |
| 54 | export ONOS_CELL=$1 |
| 55 | . $ONOS_ROOT/tools/test/cells/$1 |
| 56 | export ONOS_INSTANCES=$(env | grep 'OC[0-9]*=' | sort | cut -d= -f2) |
| 57 | setPrimaryInstance 1 >/dev/null |
Thomas Vachuska | 77a63e6 | 2016-05-09 21:02:39 -0700 | [diff] [blame^] | 58 | onos-cell |
Thomas Vachuska | a25cda2 | 2016-05-09 15:46:48 -0700 | [diff] [blame] | 59 | esac |