Creating build of a small bundle of remote administrative tools that
can be installed separately from the ONOS source or ONOS runtime.
Change-Id: I0f8a7e2739010f34d913d79ab40390aef3fc07e2
diff --git a/tools/package/runtime/bin/_find-node b/tools/package/runtime/bin/_find-node
index 3f65474..744d955 100644
--- a/tools/package/runtime/bin/_find-node
+++ b/tools/package/runtime/bin/_find-node
@@ -24,30 +24,26 @@
validate_number () {
local re="^[0-9]+$"
if [[ ! $1 =~ $re ]] ; then
- return 1
+ return 1
fi
-
return 0
}
find_node () {
if validate_number $1 ; then
- # input is a number, try to find if an OC node is defined
+ # input is a number, try to find if an OC node is defined
+ oc_try="OC$1"
+ node=${!oc_try}
- oc_try="OC$1"
- node=${!oc_try}
-
- if [ -n "$node" ]; then
+ if [ -n "$node" ]; then
# node lookup succeeded, return node
- echo $node
- else
+ echo $node
+ else
# node lookup failed, return original input
+ echo $1
+ fi
+ else
echo $1
fi
-
- else
- echo $1
- fi
-
return 0
}
diff --git a/tools/package/runtime/bin/onos-app b/tools/package/runtime/bin/onos-app
index 1c30c42..7ea93a7 100755
--- a/tools/package/runtime/bin/onos-app
+++ b/tools/package/runtime/bin/onos-app
@@ -20,14 +20,10 @@
# Tool to manage ONOS applications using REST API.
# -----------------------------------------------------------------------------
-# If ONOS_HOME is set, respect its value.
-# If ONOS_HOME is not set (e.g. in the init or service environment),
-# set it based on this script's path.
-ONOS_HOME=${ONOS_HOME:-$(cd $(dirname $0)/.. >/dev/null 2>&1 && pwd)}
-ONOS_WEB_USER=${ONOS_WEB_USER:-onos} # ONOS WEB User defaults to 'onos'
+ONOS_WEB_USER=${ONOS_WEB_USER:-onos} # ONOS WEB User defaults to 'onos'
ONOS_WEB_PASS=${ONOS_WEB_PASS:-rocks} # ONOS WEB Password defaults to 'rocks'
-. ${ONOS_HOME}/bin/_find-node
+. $(dirname $0)/_find-node
node=$(find_node $1)
cmd=${2:-list}
diff --git a/tools/package/runtime/bin/onos-cfg b/tools/package/runtime/bin/onos-cfg
index 6b02dfa..6855d03 100755
--- a/tools/package/runtime/bin/onos-cfg
+++ b/tools/package/runtime/bin/onos-cfg
@@ -20,19 +20,15 @@
# Tool to manage ONOS component configurations using REST API.
# -----------------------------------------------------------------------------
-# If ONOS_HOME is set, respect its value.
-# If ONOS_HOME is not set (e.g. in the init or service environment),
-# set it based on this script's path.
-ONOS_HOME=${ONOS_HOME:-$(cd $(dirname $0)/.. >/dev/null 2>&1 && pwd)}
-ONOS_WEB_USER=${ONOS_WEB_USER:-onos} # ONOS WEB User defaults to 'onos'
+ONOS_WEB_USER=${ONOS_WEB_USER:-onos} # ONOS WEB User defaults to 'onos'
ONOS_WEB_PASS=${ONOS_WEB_PASS:-rocks} # ONOS WEB Password defaults to 'rocks'
+. $(dirname $0)/_find-node
+. $(dirname $0)/_check-json
+
fail="--fail"
[ "$1" == "-v" ] && shift && fail=""
-. ${ONOS_HOME}/bin/_find-node
-. ${ONOS_HOME}/bin/_check-json
-
node=$(find_node $1)
cmd=${2:-list}
component=${3}
diff --git a/tools/package/runtime/bin/onos-compile-yang b/tools/package/runtime/bin/onos-compile-yang
index 855167c..e1bb987 100755
--- a/tools/package/runtime/bin/onos-compile-yang
+++ b/tools/package/runtime/bin/onos-compile-yang
@@ -20,14 +20,10 @@
# Tool to compile the specified YANG file(s) using the ONOS live compilation.
# -----------------------------------------------------------------------------
-# If ONOS_HOME is set, respect its value.
-# If ONOS_HOME is not set (e.g. in the init or service environment),
-# set it based on this script's path.
-ONOS_HOME=${ONOS_HOME:-$(cd $(dirname $0)/.. >/dev/null 2>&1 && pwd)}
-ONOS_WEB_USER=${ONOS_WEB_USER:-onos} # ONOS WEB User defaults to 'onos'
+ONOS_WEB_USER=${ONOS_WEB_USER:-onos} # ONOS WEB User defaults to 'onos'
ONOS_WEB_PASS=${ONOS_WEB_PASS:-rocks} # ONOS WEB Password defaults to 'rocks'
-. ${ONOS_HOME}/bin/_find-node
+. $(dirname $0)/_find-node
node=$(find_node $1)
yang=$2
diff --git a/tools/package/runtime/bin/onos-diagnostics b/tools/package/runtime/bin/onos-diagnostics
index 442b1fd..4ab9bf5 100755
--- a/tools/package/runtime/bin/onos-diagnostics
+++ b/tools/package/runtime/bin/onos-diagnostics
@@ -19,6 +19,12 @@
# -----------------------------------------------------------------------------
# Tool to collect cluster-wide diagnostics into a single tar stream.
# -----------------------------------------------------------------------------
+
+ONOS_WEB_USER=${ONOS_WEB_USER:-onos} # ONOS WEB User defaults to 'onos'
+ONOS_WEB_PASS=${ONOS_WEB_PASS:-rocks} # ONOS WEB Password defaults to 'rocks'
+
+. $(dirname $0)/_find-node
+
function usage() {
echo "usage: $(basename $0) [-x] [-n name] [-u user] [-p password] [ip1 ip2...]"
echo ""
@@ -69,6 +75,9 @@
"ports -e"
"portstats -nz"
+ "packet-processors"
+ "packet-requests"
+
"intents"
"flows -s"
"groups"
@@ -93,8 +102,7 @@
*) usage;;
esac
done
-ONOS_WEB_USER=${ONOS_WEB_USER:-onos} # ONOS WEB User defaults to 'onos'
-ONOS_WEB_PASS=${ONOS_WEB_PASS:-rocks} # ONOS WEB Password defaults to 'rocks'
+
user=${user:-$ONOS_WEB_USER}
password=${password:-$ONOS_WEB_PASS}
let OPC=$OPTIND-1
@@ -118,7 +126,7 @@
printf "logs "
curl -sS --fail --user $user:$password \
http://$node:8181/onos/v1/diagnostics > ../$node.tar.gz
- tar zxf ../$node.tar.gz
+ tar zxf ../$node.tar.gz && rm ../$node.tar.gz
# Acquire remotely obtained diagnostics via ssh CLI
for cmd in "${CLI_COMMANDS[@]}"; do
@@ -127,9 +135,7 @@
onos $node $cmd 2>/dev/null >$cmdLog
done
- # Tar-up local and remote diagnostics together
printf " Done.\n"
- tar zcf ../$node.tar.gz *
done
# Tar-up diagnostics from all the nodes
diff --git a/tools/package/runtime/bin/onos-netcfg b/tools/package/runtime/bin/onos-netcfg
index 17552ac..5e22836 100755
--- a/tools/package/runtime/bin/onos-netcfg
+++ b/tools/package/runtime/bin/onos-netcfg
@@ -20,15 +20,11 @@
# ONOS network configuration uploader.
# -----------------------------------------------------------------------------
-# If ONOS_HOME is set, respect its value.
-# If ONOS_HOME is not set (e.g. in the init or service environment),
-# set it based on this script's path.
-ONOS_HOME=${ONOS_HOME:-$(cd $(dirname $0)/.. >/dev/null 2>&1 && pwd)}
-ONOS_WEB_USER=${ONOS_WEB_USER:-onos} # ONOS WEB User defaults to 'onos'
+ONOS_WEB_USER=${ONOS_WEB_USER:-onos} # ONOS WEB User defaults to 'onos'
ONOS_WEB_PASS=${ONOS_WEB_PASS:-rocks} # ONOS WEB Password defaults to 'rocks'
-. ${ONOS_HOME}/bin/_find-node
-. ${ONOS_HOME}/bin/_check-json
+. $(dirname $0)/_find-node
+. $(dirname $0)/_check-json
fail="--fail"
[ "$1" == "-v" ] && shift && fail=""
diff --git a/tools/package/runtime/bin/onos-node-diagnostics b/tools/package/runtime/bin/onos-node-diagnostics
index 1cb18b5..f5dd520 100755
--- a/tools/package/runtime/bin/onos-node-diagnostics
+++ b/tools/package/runtime/bin/onos-node-diagnostics
@@ -20,10 +20,7 @@
# Tool to collect node-specific diagnostics into a single tar stream.
# -----------------------------------------------------------------------------
-# If ONOS_HOME is set, respect its value.
-# If ONOS_HOME is not set (e.g. in the init or service environment),
-# set it based on this script's path.
-ONOS_HOME=${ONOS_HOME:-$(cd $(dirname $0)/.. >/dev/null 2>&1 && pwd)}
+ONOS_HOME=$(cd $(dirname $0)/.. >/dev/null 2>&1 && pwd)
diag=/tmp/diag$$
mkdir -p $diag; cd $diag