Enhanced onos-setup-karaf to be more robust and more friendly. It will validate …
…the specified IP, if given. Otherwise, it will attempt to use ONOS_IP and if that's not available ONOS_NIC to find an adapter with a matching IP address. Usage is backwards compatible. Also added new onos-karaf command which runs onos-setup-karaf && karaf $@ as a convenience; aliased to 'ok'. Corrected onos-build-selective to propagate error status only if the build fails. Change-Id: I920b06fa21edc95b7d651270efe2f95da90ff010
Showing
4 changed files
with
34 additions
and
5 deletions
| ... | @@ -45,6 +45,7 @@ alias obi='onos-build -Dmaven.test.failure.ignore=true' | ... | @@ -45,6 +45,7 @@ alias obi='onos-build -Dmaven.test.failure.ignore=true' |
| 45 | alias obs='onos-build-selective' | 45 | alias obs='onos-build-selective' |
| 46 | alias obd='onos-build-docs' | 46 | alias obd='onos-build-docs' |
| 47 | alias op='onos-package' | 47 | alias op='onos-package' |
| 48 | +alias ok='onos-karaf' | ||
| 48 | alias ot='onos-test' | 49 | alias ot='onos-test' |
| 49 | alias ol='onos-log' | 50 | alias ol='onos-log' |
| 50 | alias ow='onos-watch' | 51 | alias ow='onos-watch' | ... | ... |
| ... | @@ -33,6 +33,10 @@ if [ -n "$projects" ]; then | ... | @@ -33,6 +33,10 @@ if [ -n "$projects" ]; then |
| 33 | 33 | ||
| 34 | echo Building projects $projects | 34 | echo Building projects $projects |
| 35 | cd $ONOS_ROOT && mvn --projects $projects ${@:-clean install} | 35 | cd $ONOS_ROOT && mvn --projects $projects ${@:-clean install} |
| 36 | + status=$? | ||
| 36 | 37 | ||
| 37 | [ -n "$appProjects" ] && echo "App staging required for projects $appProjects" | 38 | [ -n "$appProjects" ] && echo "App staging required for projects $appProjects" |
| 39 | + exit $status | ||
| 40 | +else | ||
| 41 | + exit 0 | ||
| 38 | fi | 42 | fi | ... | ... |
tools/test/bin/onos-karaf
0 → 100755
| 1 | +#!/bin/bash | ||
| 2 | +# ----------------------------------------------------------------------------- | ||
| 3 | +# Makes sure local ONOS karaf instance is primed & staged and then launches | ||
| 4 | +# karaf using the supplied arguments. | ||
| 5 | +# ----------------------------------------------------------------------------- | ||
| 6 | + | ||
| 7 | +onos-setup-karaf && karaf "$@" | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -2,6 +2,9 @@ | ... | @@ -2,6 +2,9 @@ |
| 2 | # ----------------------------------------------------------------------------- | 2 | # ----------------------------------------------------------------------------- |
| 3 | # Downloads and sets-up Apache Karaf as a basis for running ONOS locally | 3 | # Downloads and sets-up Apache Karaf as a basis for running ONOS locally |
| 4 | # as a single-instance. | 4 | # as a single-instance. |
| 5 | +# | ||
| 6 | +# Note that this in no way impacts the method for running ONOS remotely. | ||
| 7 | +# For that, one should use onos-package and onos-install tools. | ||
| 5 | # ----------------------------------------------------------------------------- | 8 | # ----------------------------------------------------------------------------- |
| 6 | 9 | ||
| 7 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 | 10 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| ... | @@ -17,14 +20,27 @@ if [ "$1" = "clean" ]; then | ... | @@ -17,14 +20,27 @@ if [ "$1" = "clean" ]; then |
| 17 | [ -d $KARAF_ROOT ] && rm -fr $KARAF_ROOT $STAGE/apps $STAGE/config | 20 | [ -d $KARAF_ROOT ] && rm -fr $KARAF_ROOT $STAGE/apps $STAGE/config |
| 18 | fi | 21 | fi |
| 19 | 22 | ||
| 20 | -if [ -z $1 ]; then | 23 | +IP="${1:-$ONOS_IP}" |
| 24 | + | ||
| 25 | +# If IP was not given, nor configured attempt to use ONOS_NIC env. variable | ||
| 26 | +if [ -z "$IP" -a -n "$ONOS_NIC" ]; then | ||
| 27 | + IP=$(ifconfig | grep 'inet ' | cut -d\ -f2 | grep $ONOS_NIC) | ||
| 28 | + [ -z "$IP" ] && echo "No adapter with IP matching $ONOS_NIC found!" | ||
| 29 | +else | ||
| 30 | + # Otherwise, verify that the IP address given exists among the adapters. | ||
| 31 | + saveIp=$IP | ||
| 32 | + IP=$(ifconfig | grep 'inet ' | cut -d\ -f2 | grep $IP) | ||
| 33 | + [ -z "$IP" ] && echo "No adapter with IP $saveIp found!" | ||
| 34 | +fi | ||
| 35 | + | ||
| 36 | +# If IP is still not surmised or if usage was requested, show usage and IPs. | ||
| 37 | +if [ -z "$IP" -o "$1" = "-?" -o "$1" = "-h" -o "$1" = "--help" ]; then | ||
| 21 | echo "usage: $(basename $0) [clean] <ip-address>" | 38 | echo "usage: $(basename $0) [clean] <ip-address>" |
| 22 | echo "Available IP addresses are:" | 39 | echo "Available IP addresses are:" |
| 23 | ifconfig | grep 'inet ' | cut -d\ -f2 | grep -v "127.0.0.1" | 40 | ifconfig | grep 'inet ' | cut -d\ -f2 | grep -v "127.0.0.1" |
| 24 | exit 1 | 41 | exit 1 |
| 25 | fi | 42 | fi |
| 26 | 43 | ||
| 27 | -IP="$1" | ||
| 28 | SUBNET="$(echo $IP | cut -d. -f1-3)" | 44 | SUBNET="$(echo $IP | cut -d. -f1-3)" |
| 29 | 45 | ||
| 30 | # Bail on any errors | 46 | # Bail on any errors |
| ... | @@ -84,7 +100,7 @@ EOF | ... | @@ -84,7 +100,7 @@ EOF |
| 84 | EOF | 100 | EOF |
| 85 | fi | 101 | fi |
| 86 | 102 | ||
| 87 | -echo "Setting up hazelcast.xml for subnet $SUBNET..." | 103 | +echo "Setting up hazelcast.xml for subnet $SUBNET.*..." |
| 88 | cp $ONOS_ROOT/tools/package/etc/hazelcast.xml $KARAF_ROOT/etc/hazelcast.xml | 104 | cp $ONOS_ROOT/tools/package/etc/hazelcast.xml $KARAF_ROOT/etc/hazelcast.xml |
| 89 | perl -pi.old -e "s/192.168.56/$SUBNET/" $KARAF_ROOT/etc/hazelcast.xml | 105 | perl -pi.old -e "s/192.168.56/$SUBNET/" $KARAF_ROOT/etc/hazelcast.xml |
| 90 | perl -pi.old -e "s/ <name>onos</ <name>$IP</" $KARAF_ROOT/etc/hazelcast.xml | 106 | perl -pi.old -e "s/ <name>onos</ <name>$IP</" $KARAF_ROOT/etc/hazelcast.xml |
| ... | @@ -93,7 +109,8 @@ echo "Staging builtin apps..." | ... | @@ -93,7 +109,8 @@ echo "Staging builtin apps..." |
| 93 | rm -fr $STAGE/apps | 109 | rm -fr $STAGE/apps |
| 94 | onos-stage-apps $STAGE/apps $KARAF_ROOT/system | 110 | onos-stage-apps $STAGE/apps $KARAF_ROOT/system |
| 95 | 111 | ||
| 96 | -echo "Customizing apps to be auto-activated..." | 112 | +ACTIVE_APPS=${ONOS_APPS:-drivers,openflow} |
| 97 | -for app in $(echo ${ONOS_APPS:-drivers,openflow} | tr ',' ' '); do | 113 | +echo "Customizing apps to be auto-activated: $ACTIVE_APPS..." |
| 114 | +for app in ${ACTIVE_APPS//,/ }; do | ||
| 98 | touch $STAGE/apps/org.onosproject.$app/active | 115 | touch $STAGE/apps/org.onosproject.$app/active |
| 99 | done | 116 | done | ... | ... |
-
Please register or login to post a comment