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