Thomas Vachuska

Clearing cell environment before borrowing and after returning cell.

Change-Id: Ia8da10406a25e9687cef5d7f8e31e9ceb11d8af9
...@@ -106,18 +106,27 @@ function setPrimaryInstance { ...@@ -106,18 +106,27 @@ function setPrimaryInstance {
106 # ON.Lab shared test cell warden address 106 # ON.Lab shared test cell warden address
107 export CELL_WARDEN="10.254.1.19" 107 export CELL_WARDEN="10.254.1.19"
108 108
109 +# Clears cell environment
110 +function clearCell {
111 + unset ONOS_CELL ONOS_NIC ONOS_IP ONOS_APPS ONOS_BOOT_FEATURES
112 + unset OCI OCN OCT ONOS_INSTANCES ONOS_FEATURES
113 + unset $(env | sed -n 's:\(^OC[0-9]\{1,\}\)=.*:\1 :g p')
114 +}
115 +
109 # Applies the settings in the specified cell file or lists current cell definition 116 # Applies the settings in the specified cell file or lists current cell definition
110 # if no cell file is given. 117 # if no cell file is given.
111 function cell { 118 function cell {
112 cell=${1:-""} 119 cell=${1:-""}
113 case "$cell" in 120 case "$cell" in
114 "borrow") 121 "borrow")
122 + clearCell
115 aux="/tmp/cell-$$" 123 aux="/tmp/cell-$$"
124 + duration=${2:-0}
116 spec=${3:-3+1} 125 spec=${3:-3+1}
117 spec=${spec/+/%2B} 126 spec=${spec/+/%2B}
118 user=${4:-$(id -un)} 127 user=${4:-$(id -un)}
119 - curl -sS -X POST "http://$CELL_WARDEN:4321/?duration=${2:-0}&spec=${spec}&user=${user}" \ 128 + query="duration=$duration&spec=$spec&user=$user"
120 - -d "$(cat ~/.ssh/id_rsa.pub)" > $aux 129 + curl -sS -X POST "http://$CELL_WARDEN:4321/?$query" -d "$(cat ~/.ssh/id_rsa.pub)" > $aux
121 . $aux 130 . $aux
122 rm -f $aux 131 rm -f $aux
123 export ONOS_INSTANCES=$(env | grep 'OC[0-9]*=' | sort | cut -d= -f2) 132 export ONOS_INSTANCES=$(env | grep 'OC[0-9]*=' | sort | cut -d= -f2)
...@@ -126,9 +135,7 @@ function cell { ...@@ -126,9 +135,7 @@ function cell {
126 ;; 135 ;;
127 "return") 136 "return")
128 curl -sS -X DELETE "http://$CELL_WARDEN:4321/?user=${2:-$(id -un)}" 137 curl -sS -X DELETE "http://$CELL_WARDEN:4321/?user=${2:-$(id -un)}"
129 - unset ONOS_CELL ONOS_NIC ONOS_IP ONOS_APPS ONOS_BOOT_FEATURES 138 + clearCell
130 - unset OCI OCN OCT ONOS_INSTANCES ONOS_FEATURES
131 - unset $(env | sed -n 's:\(^OC[0-9]\{1,\}\)=.*:\1 :g p')
132 ;; 139 ;;
133 140
134 "status") 141 "status")
...@@ -144,15 +151,12 @@ function cell { ...@@ -144,15 +151,12 @@ function cell {
144 ;; 151 ;;
145 152
146 *) 153 *)
147 - [ ! -f $ONOS_ROOT/tools/test/cells/$1 ] && \ 154 + [ ! -f $ONOS_ROOT/tools/test/cells/$1 ] && echo "No such cell: $1" >&2 && return 1
148 - echo "No such cell: $1" >&2 && return 1 155 + clearCell
149 - unset ONOS_CELL ONOS_NIC ONOS_IP ONOS_APPS ONOS_BOOT_FEATURES
150 - unset OCI OCN OCT ONOS_INSTANCES ONOS_FEATURES
151 - unset $(env | sed -n 's:\(^OC[0-9]\{1,\}\)=.*:\1 :g p')
152 export ONOS_USER=${ONOS_USER:-sdn} 156 export ONOS_USER=${ONOS_USER:-sdn}
153 export ONOS_GROUP=${ONOS_GROUP:-sdn} 157 export ONOS_GROUP=${ONOS_GROUP:-sdn}
154 - export ONOS_WEB_USER=onos 158 + export ONOS_WEB_USER=${ONOS_WEB_USER:-onos}
155 - export ONOS_WEB_PASS=rocks 159 + export ONOS_WEB_PASS=${ONOS_WEB_PASS:-rocks}
156 export ONOS_CELL=$1 160 export ONOS_CELL=$1
157 . $ONOS_ROOT/tools/test/cells/$1 161 . $ONOS_ROOT/tools/test/cells/$1
158 export ONOS_INSTANCES=$(env | grep 'OC[0-9]*=' | sort | cut -d= -f2) 162 export ONOS_INSTANCES=$(env | grep 'OC[0-9]*=' | sort | cut -d= -f2)
......
...@@ -15,3 +15,5 @@ echo "export OCT=\"10.128.11.1\"" ...@@ -15,3 +15,5 @@ echo "export OCT=\"10.128.11.1\""
15 echo "export ONOS_USER=sdn" 15 echo "export ONOS_USER=sdn"
16 echo "export ONOS_USE_SSH=true" 16 echo "export ONOS_USE_SSH=true"
17 echo "export ONOS_APPS=${apps}" 17 echo "export ONOS_APPS=${apps}"
18 +echo "export ONOS_WEB_USER=onos"
19 +echo "export ONOS_WEB_PASS=rocks"
......