From fdeda92107076b18e73d022ced07e2a22a6db3be Mon Sep 17 00:00:00 2001 From: Thomas Vachuska Date: Mon, 16 May 2016 11:37:00 -0700 Subject: [PATCH] Clearing cell environment before borrowing and after returning cell. Change-Id: Ia8da10406a25e9687cef5d7f8e31e9ceb11d8af9 --- tools/dev/bash_profile | 28 ++++++++++++++++------------ utils/warden/bin/cell-def | 2 ++ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/tools/dev/bash_profile b/tools/dev/bash_profile index d60820d6bf..3eff8b0f9c 100644 --- a/tools/dev/bash_profile +++ b/tools/dev/bash_profile @@ -106,18 +106,27 @@ function setPrimaryInstance { # ON.Lab shared test cell warden address export CELL_WARDEN="10.254.1.19" +# Clears cell environment +function clearCell { + 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') +} + # 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") + clearCell aux="/tmp/cell-$$" + duration=${2:-0} spec=${3:-3+1} spec=${spec/+/%2B} user=${4:-$(id -un)} - curl -sS -X POST "http://$CELL_WARDEN:4321/?duration=${2:-0}&spec=${spec}&user=${user}" \ - -d "$(cat ~/.ssh/id_rsa.pub)" > $aux + query="duration=$duration&spec=$spec&user=$user" + curl -sS -X POST "http://$CELL_WARDEN:4321/?$query" -d "$(cat ~/.ssh/id_rsa.pub)" > $aux . $aux rm -f $aux export ONOS_INSTANCES=$(env | grep 'OC[0-9]*=' | sort | cut -d= -f2) @@ -126,9 +135,7 @@ function 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') + clearCell ;; "status") @@ -144,15 +151,12 @@ function cell { ;; *) - [ ! -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') + [ ! -f $ONOS_ROOT/tools/test/cells/$1 ] && echo "No such cell: $1" >&2 && return 1 + clearCell export ONOS_USER=${ONOS_USER:-sdn} export ONOS_GROUP=${ONOS_GROUP:-sdn} - export ONOS_WEB_USER=onos - export ONOS_WEB_PASS=rocks + export ONOS_WEB_USER=${ONOS_WEB_USER:-onos} + export ONOS_WEB_PASS=${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) diff --git a/utils/warden/bin/cell-def b/utils/warden/bin/cell-def index badad599c9..b92370791c 100755 --- a/utils/warden/bin/cell-def +++ b/utils/warden/bin/cell-def @@ -15,3 +15,5 @@ echo "export OCT=\"10.128.11.1\"" echo "export ONOS_USER=sdn" echo "export ONOS_USE_SSH=true" echo "export ONOS_APPS=${apps}" +echo "export ONOS_WEB_USER=onos" +echo "export ONOS_WEB_PASS=rocks"