Fixing a few tools to work with the new REST security stuff.

Change-Id: I1fcff24bf57e3198c16df5a6e42d721a004e9097
diff --git a/tools/test/bin/onos b/tools/test/bin/onos
index 63786d9..89197db 100755
--- a/tools/test/bin/onos
+++ b/tools/test/bin/onos
@@ -11,7 +11,7 @@
 
 [ -n "$1" ] && OCI=$(find_node $1) && shift
 
-if which client 2>/dev/null && [ -z "$ONOS_USE_SSH" ]; then
+if which client 1>/dev/null 2>&1 && [ -z "$ONOS_USE_SSH" ]; then
     # Use Karaf client only if we can and are allowed to
     unset KARAF_HOME
     client -h $OCI -u karaf "$@" 2>/dev/null
diff --git a/tools/test/bin/onos-form-cluster b/tools/test/bin/onos-form-cluster
index f1d3429..b6823b1 100755
--- a/tools/test/bin/onos-form-cluster
+++ b/tools/test/bin/onos-form-cluster
@@ -6,10 +6,22 @@
 [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
 . $ONOS_ROOT/tools/build/envDefaults
 
+# Scan arguments for user/password or other options...
+while getopts u:p: o; do
+    case "$o" in
+        u) user=$OPTARG;;
+        p) password=$OPTARG;;
+    esac
+done
+user=${user:-onos}           # user defaults to 'onos'
+password=${password:-$user}  # password defaults to user name if not specified
+let OPC=$OPTIND-1
+shift $OPC
+
 node=${1:-$OCI}
 
 if [ $node = "cell" ]; then
-    nodes=$(env | grep "OC[0-9]*=" | cut -d= -f2)
+    nodes=${ONOS_INSTANCES}
     node=${OCI}
 else
     nodes="$@"
@@ -17,4 +29,4 @@
 
 set -x
 
-ssh $ONOS_USER@$node /tmp/$ONOS_BITS/bin/onos-form-cluster $nodes
\ No newline at end of file
+ssh $ONOS_USER@$node /tmp/$ONOS_BITS/bin/onos-form-cluster -u $user -p $password $nodes
\ No newline at end of file
diff --git a/tools/test/bin/onos-topo-cfg b/tools/test/bin/onos-topo-cfg
index 258bfe7..5f40d8e 100755
--- a/tools/test/bin/onos-topo-cfg
+++ b/tools/test/bin/onos-topo-cfg
@@ -9,5 +9,6 @@
 node="${1:-$OCI}"
 file="${2:-$ONOS_ROOT/tools/test/topos/oe-linear-3.json}"
 
-curl -sS --fail -L -X POST -H 'Content-Type:application/json' \
+curl -sS --fail -L --user $ONOS_WEB_USER:$ONOS_WEB_PASS \
+    -X POST -H 'Content-Type:application/json' \
     http://$node:8181/onos/v1/config/topology -d@$file
diff --git a/tools/test/scenarios/setup.xml b/tools/test/scenarios/setup.xml
index bcc65d9..c26c0de 100644
--- a/tools/test/scenarios/setup.xml
+++ b/tools/test/scenarios/setup.xml
@@ -16,7 +16,7 @@
 <scenario name="setup" description="ONOS cluster setup">
     <group name="Setup">
         <step name="Push-Bits" exec="onos-push-bits-through-proxy" if="${OCT}"/>
-        <step name="Secure-SSH" exec="onos-secure-ssh -u onos -p rocks" if="${ONOS_USE_SSH}"/>
+        <step name="Secure-SSH" exec="onos-secure-ssh -u ${ONOS_WEB_USER} -p ${ONOS_WEB_PASS}" if="${ONOS_USE_SSH}"/>
 
         <parallel var="${OC#}">
             <step name="Push-Bits-${#}" exec="onos-push-bits ${OC#}"
diff --git a/tools/test/scenarios/tar-setup.xml b/tools/test/scenarios/tar-setup.xml
index 8420528..e330b2d 100644
--- a/tools/test/scenarios/tar-setup.xml
+++ b/tools/test/scenarios/tar-setup.xml
@@ -16,7 +16,7 @@
 <scenario name="tar-setup" description="ONOS cluster setup via onos.tar.gz">
     <group name="Setup-Instances">
         <step name="Push-Bits" exec="onos-push-bits-through-proxy" if="${OCT}"/>
-        <step name="Secure-SSH" exec="onos-secure-ssh" if="${ONOS_USE_SSH}"/>
+        <step name="Secure-SSH" exec="onos-secure-ssh -u ${ONOS_WEB_USER} -p ${ONOS_WEB_PASS}" if="${ONOS_USE_SSH}"/>
 
         <parallel var="${OC#}">
             <step name="Push-Bits-${#}" exec="onos-push-bits ${OC#}" unless="${OCT}"/>
@@ -44,7 +44,7 @@
     </group>
 
     <group name="Setup-Cluster" requires="Setup-Instances" unless="${NO_CLUSTER}">
-        <step name="Form-Cluster" exec="onos-form-cluster cell"/>
+        <step name="Form-Cluster" exec="onos-form-cluster -u ${ONOS_WEB_USER} -p ${ONOS_WEB_PASS} cell"/>
         <parallel var="${OC#}">
             <step name="Wait-for-Start-Again-${#}" exec="onos-wait-for-start ${OC#}"
                   requires="Form-Cluster"/>