Reverting changes to onos-cell & cell
Change-Id: Ieb35fe2d51c1981f1d560bdfe072d5ccc6a26f90
diff --git a/tools/dev/bash_profile b/tools/dev/bash_profile
index 91a31f9..3034375 100644
--- a/tools/dev/bash_profile
+++ b/tools/dev/bash_profile
@@ -106,7 +106,57 @@
# ON.Lab shared test cell warden address
export CELL_WARDEN="10.254.1.19"
-alias cell='onos-cell'
+# Applies the settings in the specified cell file or lists current cell definition
+# if no cell file is given.
+function cell {
+ cell=$1
+ case "$cell" in
+ "borrow")
+ aux="/tmp/cell-$$"
+ curl -sS -X POST "http://$CELL_WARDEN:4321/?duration=${2:-0}&user=${3:-$(id -un)}" \
+ -d "$(cat ~/.ssh/id_rsa.pub)" > $aux
+ . $aux
+ rm -f $aux
+ export ONOS_INSTANCES=$(env | grep 'OC[0-9]*=' | sort | cut -d= -f2)
+ setPrimaryInstance 1 >/dev/null
+ onos-verify-cell
+ ;;
+ "return")
+ curl -sS -X DELETE "http://$CELL_WARDEN:4321/?user=${2:-$(id -un)}"
+ unset ONOS_CELL ONOS_NIC ONOS_IP ONOS_APPS ONOS_BOOT_FEATURES
+ unset OCI OCN OCT ONOS_INSTANCES ONOS_FEATURES
+ unset $(env | sed -n 's:\(^OC[0-9]\{1,\}\)=.*:\1 :g p')
+ ;;
+
+ "status")
+ curl -sS "http://$CELL_WARDEN:4321/" | sort
+ ;;
+
+ "")
+ env | egrep "ONOS_CELL"
+ env | egrep "OCI"
+ env | egrep "OC[0-9]+" | sort
+ env | egrep "OC[NT]"
+ env | egrep "ONOS_" | egrep -v 'ONOS_ROOT|ONOS_CELL|ONOS_INSTANCES' | sort
+ ;;
+
+ *)
+ [ ! -f $ONOS_ROOT/tools/test/cells/$1 ] && \
+ echo "No such cell: $1" >&2 && return 1
+ unset ONOS_CELL ONOS_NIC ONOS_IP ONOS_APPS ONOS_BOOT_FEATURES
+ unset OCI OCN OCT ONOS_INSTANCES ONOS_FEATURES
+ unset $(env | sed -n 's:\(^OC[0-9]\{1,\}\)=.*:\1 :g p')
+ export ONOS_USER=${ONOS_USER:-sdn}
+ export ONOS_GROUP=${ONOS_GROUP:-sdn}
+ export ONOS_WEB_USER=onos
+ export ONOS_WEB_PASS=rocks
+ export ONOS_CELL=$1
+ . $ONOS_ROOT/tools/test/cells/$1
+ export ONOS_INSTANCES=$(env | grep 'OC[0-9]*=' | sort | cut -d= -f2)
+ setPrimaryInstance 1 >/dev/null
+ cell
+ esac
+}
[ -n "$ONOS_CELL" -a "$ONOS_CELL" != "borrow" ] && cell $ONOS_CELL > /dev/null
diff --git a/tools/test/bin/onos-cell b/tools/test/bin/onos-cell
index 275ad23..45a68b9 100755
--- a/tools/test/bin/onos-cell
+++ b/tools/test/bin/onos-cell
@@ -1,59 +1,9 @@
#!/bin/bash
# -----------------------------------------------------------------------------
-# Applies the settings in the specified cell file or lists current cell
-# definition if no cell file is given.
+# List available ONOS cells configuration.
# -----------------------------------------------------------------------------
-# Sets the primary instance to the specified instance number.
-function setPrimaryInstance {
- export OCI=$(env | egrep "OC[0-9]+" | sort | egrep OC${1:-1} | cut -d= -f2)
- echo $OCI
-}
+[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
+. $ONOS_ROOT/tools/dev/bash_profile
-cell=$1
-case "$cell" in
-"borrow")
- aux="/tmp/cell-$$"
- curl -sS -X POST "http://$CELL_WARDEN:4321/?duration=${2:-0}&user=${3:-$(id -un)}" \
- -d "$(cat ~/.ssh/id_rsa.pub)" > $aux
- . $aux
- rm -f $aux
- export ONOS_INSTANCES=$(env | grep 'OC[0-9]*=' | sort | cut -d= -f2)
- setPrimaryInstance 1 >/dev/null
- onos-verify-cell
- ;;
-"return")
- curl -sS -X DELETE "http://$CELL_WARDEN:4321/?user=${2:-$(id -un)}"
- unset ONOS_CELL ONOS_NIC ONOS_IP ONOS_APPS ONOS_BOOT_FEATURES
- unset OCI OCN OCT ONOS_INSTANCES ONOS_FEATURES
- unset $(env | sed -n 's:\(^OC[0-9]\{1,\}\)=.*:\1 :g p')
- ;;
-
-"status")
- curl -sS "http://$CELL_WARDEN:4321/" | sort
- ;;
-
-"")
- env | egrep "ONOS_CELL"
- env | egrep "OCI"
- env | egrep "OC[0-9]+" | sort
- env | egrep "OC[NT]"
- env | egrep "ONOS_" | egrep -v 'ONOS_ROOT|ONOS_CELL|ONOS_INSTANCES' | sort
- ;;
-
-*)
- [ ! -f $ONOS_ROOT/tools/test/cells/$1 ] && \
- echo "No such cell: $1" >&2 && return 1
- unset ONOS_CELL ONOS_NIC ONOS_IP ONOS_APPS ONOS_BOOT_FEATURES
- unset OCI OCN OCT ONOS_INSTANCES ONOS_FEATURES
- unset $(env | sed -n 's:\(^OC[0-9]\{1,\}\)=.*:\1 :g p')
- export ONOS_USER=${ONOS_USER:-sdn}
- export ONOS_GROUP=${ONOS_GROUP:-sdn}
- export ONOS_WEB_USER=onos
- export ONOS_WEB_PASS=rocks
- export ONOS_CELL=$1
- . $ONOS_ROOT/tools/test/cells/$1
- export ONOS_INSTANCES=$(env | grep 'OC[0-9]*=' | sort | cut -d= -f2)
- setPrimaryInstance 1 >/dev/null
- onos-cell
-esac
\ No newline at end of file
+cell "$@"
\ No newline at end of file