Fixing a few tools to work with the new REST security stuff.
Change-Id: I1fcff24bf57e3198c16df5a6e42d721a004e9097
diff --git a/tools/dev/bash_profile b/tools/dev/bash_profile
index 453782b..d084c97 100644
--- a/tools/dev/bash_profile
+++ b/tools/dev/bash_profile
@@ -105,6 +105,8 @@
unset ONOS_CELL ONOS_NIC ONOS_IP ONOS_APPS ONOS_BOOT_FEATURES
unset OCI OCN OCT ONOS_INSTANCES ONOS_USER ONOS_GROUP ONOS_FEATURES
unset $(env | sed -n 's:\(^OC[0-9]\{1,\}\)=.*:\1 :g p')
+ 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)
@@ -115,7 +117,7 @@
env | egrep "OCI"
env | egrep "OC[0-9]+" | sort
env | egrep "OC[NT]"
- env | egrep "ONOS_" | egrep -v 'ONOS_ROOT|ONOS_CELL|ONOS_INSTANCES'
+ env | egrep "ONOS_" | egrep -v 'ONOS_ROOT|ONOS_CELL|ONOS_INSTANCES' | sort
fi
}
diff --git a/tools/dev/bin/onos-app b/tools/dev/bin/onos-app
index fd86a25..658a050 100755
--- a/tools/dev/bin/onos-app
+++ b/tools/dev/bin/onos-app
@@ -9,7 +9,7 @@
export URL=http://$node:8181/onos/v1/applications
export HDR="-HContent-Type:application/octet-stream"
-export curl="curl -sS"
+export curl="curl -sS --user $ONOS_WEB_USER:$ONOS_WEB_PASS"
# Prints usage help
function usage {
diff --git a/tools/package/bin/onos-form-cluster b/tools/package/bin/onos-form-cluster
index 925c6ff..7a0abda 100755
--- a/tools/package/bin/onos-form-cluster
+++ b/tools/package/bin/onos-form-cluster
@@ -5,6 +5,18 @@
[ $# -lt 2 ] && echo "usage: $(basename $0) ip1 ip2..." && exit 1
+# 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
+
ip=$1
shift
nodes=$*
@@ -22,5 +34,6 @@
for node in $ip $nodes; do
echo "Forming cluster on $node..."
- curl -X POST http://$node:8181/onos/v1/cluster/configuration -d @$aux
+ curl --user $user:$password -X POST \
+ http://$node:8181/onos/v1/cluster/configuration -d @$aux
done
\ No newline at end of file
diff --git a/tools/package/bin/onos-secure-ssh b/tools/package/bin/onos-secure-ssh
index ac94de5..3f541db 100755
--- a/tools/package/bin/onos-secure-ssh
+++ b/tools/package/bin/onos-secure-ssh
@@ -7,14 +7,14 @@
set -e
-# Scan argument for user/password or other options...
+# 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
-password=${password:-user} # password defaults to the user name if not specified
+password=${password:-$user} # password defaults to the user if not specified
let OPC=$OPTIND-1
shift $OPC
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"/>