Thomas Vachuska

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

Change-Id: I1fcff24bf57e3198c16df5a6e42d721a004e9097
......@@ -105,6 +105,8 @@ function cell {
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 @@ function 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'
env | egrep "ONOS_" | egrep -v 'ONOS_ROOT|ONOS_CELL|ONOS_INSTANCES' | sort
fi
}
......
......@@ -9,7 +9,7 @@ app=${3}
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 {
......
......@@ -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 @@ echo "], \"ipPrefix\": \"$ipPrefix.*\" }" >> $aux
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
......
......@@ -7,14 +7,14 @@ rm -f $(dirname $0)/onos
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
......
......@@ -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
......
......@@ -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 @@ fi
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
......
......@@ -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
......
......@@ -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#}"
......
......@@ -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"/>
......