blob: 275ad23407289db730d2fb907356796d873bbceb [file] [log] [blame]
Thomas Vachuskab8261902016-05-04 00:10:42 -07001#!/bin/bash
2# -----------------------------------------------------------------------------
Thomas Vachuskaa25cda22016-05-09 15:46:48 -07003# Applies the settings in the specified cell file or lists current cell
4# definition if no cell file is given.
Thomas Vachuskab8261902016-05-04 00:10:42 -07005# -----------------------------------------------------------------------------
6
Thomas Vachuska77a63e62016-05-09 21:02:39 -07007# Sets the primary instance to the specified instance number.
8function setPrimaryInstance {
9 export OCI=$(env | egrep "OC[0-9]+" | sort | egrep OC${1:-1} | cut -d= -f2)
10 echo $OCI
11}
12
Thomas Vachuskaa25cda22016-05-09 15:46:48 -070013cell=$1
14case "$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 Vachuskab8261902016-05-04 00:10:42 -070031
Thomas Vachuskaa25cda22016-05-09 15:46:48 -070032"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 Vachuska77a63e62016-05-09 21:02:39 -070058 onos-cell
Thomas Vachuskaa25cda22016-05-09 15:46:48 -070059esac