diff options
author | Ashlee Young <ashlee@onosfw.com> | 2015-09-09 22:15:21 -0700 |
---|---|---|
committer | Ashlee Young <ashlee@onosfw.com> | 2015-09-09 22:15:21 -0700 |
commit | 13d05bc8458758ee39cb829098241e89616717ee (patch) | |
tree | 22a4d1ce65f15952f07a3df5af4b462b4697cb3a /framework/src/onos/tools/package/bin | |
parent | 6139282e1e93c2322076de4b91b1c85d0bc4a8b3 (diff) |
ONOS checkin based on commit tag e796610b1f721d02f9b0e213cf6f7790c10ecd60
Change-Id: Ife8810491034fe7becdba75dda20de4267bd15cd
Diffstat (limited to 'framework/src/onos/tools/package/bin')
-rwxr-xr-x | framework/src/onos/tools/package/bin/onos-client | 17 | ||||
-rwxr-xr-x | framework/src/onos/tools/package/bin/onos-config | 2 | ||||
-rwxr-xr-x | framework/src/onos/tools/package/bin/onos-form-cluster | 39 | ||||
-rwxr-xr-x | framework/src/onos/tools/package/bin/onos-jpenable | 7 | ||||
-rwxr-xr-x | framework/src/onos/tools/package/bin/onos-secure-ssh | 38 | ||||
-rwxr-xr-x | framework/src/onos/tools/package/bin/onos-service | 44 | ||||
-rwxr-xr-x | framework/src/onos/tools/package/bin/onos-ssh | 6 | ||||
-rwxr-xr-x | framework/src/onos/tools/package/bin/onos-user-key | 20 |
8 files changed, 173 insertions, 0 deletions
diff --git a/framework/src/onos/tools/package/bin/onos-client b/framework/src/onos/tools/package/bin/onos-client new file mode 100755 index 00000000..2a37087a --- /dev/null +++ b/framework/src/onos/tools/package/bin/onos-client @@ -0,0 +1,17 @@ +#!/bin/bash +# ----------------------------------------------------------------------------- +# ONOS command-line client that uses the built-in Apache Karaf client. +# ----------------------------------------------------------------------------- + +if [ -z "${JAVA_HOME}" ]; then + if [ -x /usr/libexec/java_home ]; then + export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) + elif [ -d /usr/lib/jvm/java-8-oracle ]; then + export JAVA_HOME="/usr/lib/jvm/java-8-oracle" + elif [ -d /usr/lib/jvm/java-7-openjdk-amd64 ]; then + export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64" + fi +fi + +cd $(dirname $0)/../apache-karaf-$KARAF_VERSION/bin +./client -h localhost -u karaf "$@" diff --git a/framework/src/onos/tools/package/bin/onos-config b/framework/src/onos/tools/package/bin/onos-config new file mode 100755 index 00000000..2265d002 --- /dev/null +++ b/framework/src/onos/tools/package/bin/onos-config @@ -0,0 +1,2 @@ +#!/bin/bash +echo "This command has been deprecated as this step is no longer required."
\ No newline at end of file diff --git a/framework/src/onos/tools/package/bin/onos-form-cluster b/framework/src/onos/tools/package/bin/onos-form-cluster new file mode 100755 index 00000000..7a0abda6 --- /dev/null +++ b/framework/src/onos/tools/package/bin/onos-form-cluster @@ -0,0 +1,39 @@ +#!/bin/bash +# ----------------------------------------------------------------------------- +# Forms ONOS cluster using REST API of each separate instance. +# ----------------------------------------------------------------------------- + +[ $# -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=$* + +ipPrefix=${ip%.*} + +aux=/tmp/${ipPrefix}.cluster.json +trap "rm -f $aux" EXIT + +echo "{ \"nodes\": [ { \"ip\": \"$ip\" }" > $aux +for node in $nodes; do + echo ", { \"ip\": \"$node\" }" >> $aux +done +echo "], \"ipPrefix\": \"$ipPrefix.*\" }" >> $aux + +for node in $ip $nodes; do + echo "Forming cluster on $node..." + 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/framework/src/onos/tools/package/bin/onos-jpenable b/framework/src/onos/tools/package/bin/onos-jpenable new file mode 100755 index 00000000..7c69602a --- /dev/null +++ b/framework/src/onos/tools/package/bin/onos-jpenable @@ -0,0 +1,7 @@ +#!/bin/bash + +kpid=$(ps -ef | grep karaf.main.Main | grep -v grep | cut -c10-15 | tr -d ' ') + +[ -z "$kpid" ] && echo "No ONOS!" && exit 1 + +/opt/jprofiler8/bin/jpenable --gui --port=8849 --pid=$kpid diff --git a/framework/src/onos/tools/package/bin/onos-secure-ssh b/framework/src/onos/tools/package/bin/onos-secure-ssh new file mode 100755 index 00000000..3f541dbe --- /dev/null +++ b/framework/src/onos/tools/package/bin/onos-secure-ssh @@ -0,0 +1,38 @@ +#!/bin/bash +# ----------------------------------------------------------------------------- +# Enables secure access to ONOS console by removing default users & keys. +# ----------------------------------------------------------------------------- + +rm -f $(dirname $0)/onos + +set -e + +# 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 if not specified +let OPC=$OPTIND-1 +shift $OPC + +cd $(dirname $0)/../apache-karaf-*/etc +USERS=users.properties +KEYS=keys.properties + +# Remove the built-in users and keys to secure the access implicitly. +egrep -v "^(karaf|onos)[ ]*=" $USERS > $USERS.new && mv $USERS.new $USERS +egrep -v "^(#karaf|onos)[ ]*=" $KEYS > $KEYS.new && mv $KEYS.new $KEYS + +# Remove any previous known keys for the local host. +ssh-keygen -f "$HOME/.ssh/known_hosts" -R [localhost]:8101 + +# Swap the onos client to use the SSH variant. +ln -s $(dirname $0)/onos-ssh $(dirname $0)/onos + +# If user and password options were given, setup the user/password. +if [ -n "$user" -a -n "$password" ]; then + echo "$user = $password,_g_:admingroup" >> $USERS +fi
\ No newline at end of file diff --git a/framework/src/onos/tools/package/bin/onos-service b/framework/src/onos/tools/package/bin/onos-service new file mode 100755 index 00000000..2f00ca02 --- /dev/null +++ b/framework/src/onos/tools/package/bin/onos-service @@ -0,0 +1,44 @@ +#!/bin/bash +# ----------------------------------------------------------------------------- +# Starts ONOS Apache Karaf container +# ----------------------------------------------------------------------------- + +# uncomment the following line for performance testing +#export JAVA_OPTS="${JAVA_OPTS:--Xms8G -Xmx8G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+PrintGCDetails -XX:+PrintGCTimeStamps}" + +# uncomment the following line for Netty TLS encryption +# Do modify the keystore location/password and truststore location/password accordingly +#export JAVA_OPTS="${JAVA_OPTS:--DenableNettyTLS=true -Djavax.net.ssl.keyStore=/home/ubuntu/onos.jks -Djavax.net.ssl.keyStorePassword=222222 -Djavax.net.ssl.trustStore=/home/ubuntu/onos.jks -Djavax.net.ssl.trustStorePassword=222222}" + +ONOS_HOME=/opt/onos +KARAF_ARGS= +SYS_APPS=drivers + +[ -d $ONOS_HOME ] && cd $ONOS_HOME || ONOS_HOME=$(dirname $0)/.. + +# Parse out arguments destinted for karaf invocation v. arguments that +# will be processed in line +while [ $# -gt 0 ]; do + case $1 in + apps-clean) + # Deactivate all applications + find ${ONOS_HOME}/apps -name "active" -exec rm \{\} \; + ;; + *) + KARAF_ARGS+=" $1" + ;; + esac + shift +done + +# Activate the system required applications (SYS_APPS) as well as any +# specified applications in the var ONOS_APPS +for app in ${SYS_APPS//,/ } ${ONOS_APPS//,/ }; do + if [[ "$app" =~ \. ]]; then + touch ${ONOS_HOME}/apps/$app/active + else + touch ${ONOS_HOME}/apps/org.onosproject.$app/active + fi +done + +exec ${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf $KARAF_ARGS diff --git a/framework/src/onos/tools/package/bin/onos-ssh b/framework/src/onos/tools/package/bin/onos-ssh new file mode 100755 index 00000000..7e082aa5 --- /dev/null +++ b/framework/src/onos/tools/package/bin/onos-ssh @@ -0,0 +1,6 @@ +#!/bin/bash +# ----------------------------------------------------------------------------- +# ONOS command-line client that uses raw ssh. +# ----------------------------------------------------------------------------- + +ssh -p 8101 localhost "$@"
\ No newline at end of file diff --git a/framework/src/onos/tools/package/bin/onos-user-key b/framework/src/onos/tools/package/bin/onos-user-key new file mode 100755 index 00000000..db24da17 --- /dev/null +++ b/framework/src/onos/tools/package/bin/onos-user-key @@ -0,0 +1,20 @@ +#!/bin/bash +# ----------------------------------------------------------------------------- +# Adds or removes a user key for managing passwordless loging to ONOS console. +# ----------------------------------------------------------------------------- + +[ $# -lt 2 ] && echo "usage: $(basename $0) user {key|remove}" && exit 1 + +set -e + +user=$1 +[ -f $2 ] && key=$(cut -d\ -f2 $2) || key=$2 + +cd $(dirname $0)/../apache-karaf-*/etc +KEYS=keys.properties + +# Remove the user key first, in case one was already present +egrep -v "^$user[ ]*=" $KEYS > $KEYS.new && mv $KEYS.new $KEYS +if [ $key != "remove" ]; then + echo "$user=$key,_g_:admingroup" >> $KEYS +fi |