From 13d05bc8458758ee39cb829098241e89616717ee Mon Sep 17 00:00:00 2001 From: Ashlee Young Date: Wed, 9 Sep 2015 22:15:21 -0700 Subject: ONOS checkin based on commit tag e796610b1f721d02f9b0e213cf6f7790c10ecd60 Change-Id: Ife8810491034fe7becdba75dda20de4267bd15cd --- framework/src/onos/tools/dev/bash_profile | 189 +++++++++++++ framework/src/onos/tools/dev/bin/clean-branches.py | 51 ++++ framework/src/onos/tools/dev/bin/onos-app | 72 +++++ .../src/onos/tools/dev/bin/onos-build-selective | 44 +++ .../onos/tools/dev/bin/onos-build-selective-hook | 10 + .../tools/dev/bin/onos-build-selective.exclude | 9 + framework/src/onos/tools/dev/bin/onos-create-app | 42 +++ framework/src/onos/tools/dev/bin/onos-karaf | 7 + framework/src/onos/tools/dev/bin/onos-local-log | 10 + framework/src/onos/tools/dev/bin/onos-setup-karaf | 123 ++++++++ .../onos/tools/dev/bin/onos-setup-ubuntu-devenv | 21 ++ .../src/onos/tools/dev/bin/onos-update-bundle | 16 ++ framework/src/onos/tools/dev/eclipse-cleanup.xml | 77 +++++ framework/src/onos/tools/dev/eclipse-formatter.xml | 310 +++++++++++++++++++++ framework/src/onos/tools/dev/header.txt | 13 + framework/src/onos/tools/dev/idea-settings.jar | Bin 0 -> 13741 bytes framework/src/onos/tools/dev/onos.cshrc | 41 +++ 17 files changed, 1035 insertions(+) create mode 100644 framework/src/onos/tools/dev/bash_profile create mode 100755 framework/src/onos/tools/dev/bin/clean-branches.py create mode 100755 framework/src/onos/tools/dev/bin/onos-app create mode 100755 framework/src/onos/tools/dev/bin/onos-build-selective create mode 100755 framework/src/onos/tools/dev/bin/onos-build-selective-hook create mode 100644 framework/src/onos/tools/dev/bin/onos-build-selective.exclude create mode 100755 framework/src/onos/tools/dev/bin/onos-create-app create mode 100755 framework/src/onos/tools/dev/bin/onos-karaf create mode 100755 framework/src/onos/tools/dev/bin/onos-local-log create mode 100755 framework/src/onos/tools/dev/bin/onos-setup-karaf create mode 100755 framework/src/onos/tools/dev/bin/onos-setup-ubuntu-devenv create mode 100755 framework/src/onos/tools/dev/bin/onos-update-bundle create mode 100644 framework/src/onos/tools/dev/eclipse-cleanup.xml create mode 100644 framework/src/onos/tools/dev/eclipse-formatter.xml create mode 100644 framework/src/onos/tools/dev/header.txt create mode 100644 framework/src/onos/tools/dev/idea-settings.jar create mode 100644 framework/src/onos/tools/dev/onos.cshrc (limited to 'framework/src/onos/tools/dev') diff --git a/framework/src/onos/tools/dev/bash_profile b/framework/src/onos/tools/dev/bash_profile new file mode 100644 index 00000000..5e161ccd --- /dev/null +++ b/framework/src/onos/tools/dev/bash_profile @@ -0,0 +1,189 @@ +#!/bin/bash +# ONOS developer BASH profile conveniences +# Simply include in your own .bash_aliases or .bash_profile + +# Root of the ONOS source tree +export ONOS_ROOT=${ONOS_ROOT:-~/onos} + +# Setup some environmental context for developers +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-8-openjdk-amd64 ]; then + export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64" + fi +fi + +export MAVEN=${MAVEN:-~/Applications/apache-maven-3.3.1} + +export KARAF_VERSION=${KARAF_VERSION:-3.0.3} +export KARAF_ROOT=${KARAF_ROOT:-~/Applications/apache-karaf-$KARAF_VERSION} +export KARAF_LOG=$KARAF_ROOT/data/log/karaf.log + +# Setup a path +export PATH="$PATH:$ONOS_ROOT/tools/dev/bin" +export PATH="$PATH:$ONOS_ROOT/tools/test/bin:$ONOS_ROOT/tools/test/scenarios/bin" +export PATH="$PATH:$ONOS_ROOT/tools/build" +export PATH="$PATH:$MAVEN/bin:$KARAF_ROOT/bin" + +# Setup cell enviroment +export ONOS_CELL=${ONOS_CELL:-local} + +# Setup default web user/password +export ONOS_WEB_USER=onos +export ONOS_WEB_PASS=rocks + +# Setup default location of test scenarios +export ONOS_SCENARIOS=$ONOS_ROOT/tools/test/scenarios + +# Convenience utility to warp to various ONOS source projects +# e.g. 'o api', 'o dev', 'o' +function o { + cd $(find $ONOS_ROOT/ -type d | egrep -v '\.git|target|gen-src' | \ + egrep "${1:-$ONOS_ROOT}" | egrep -v "$ONOS_ROOT/.+/src/" | head -n 1) +} + +# Short-hand for 'mvn clean install' for us lazy folk +alias mci='mvn clean install' +alias mcis='mvn clean install -DskipTests -Dcheckstyle.skip -U -T 1C' +alias mis='mvn install -DskipTests -Dcheckstyle.skip -U -T 1C' + +# Short-hand for ONOS build, package and test. +alias ob='onos-build' +alias obi='onos-build -Dmaven.test.failure.ignore=true' +alias obs='onos-build-selective' +alias obd='onos-build-docs' +alias op='onos-package' +alias ok='onos-karaf' +alias ot='onos-test' +alias ol='onos-log' +alias ow='onos-watch' +alias ocl='onos-check-logs' +alias oi='setPrimaryInstance' +alias pub='onos-push-update-bundle' + +# Short-hand for tailing and searching the ONOS (karaf) log +alias tl='$ONOS_ROOT/tools/dev/bin/onos-local-log' +alias ll='less $KARAF_LOG' +alias gl='grep $KARAF_LOG --colour=auto -E -e ' + +function filterLocalLog { + tl | grep --colour=always -E -e "${1-org.onlab|org.onosproject}" +} +alias tlo='filterLocalLog' +alias tle='tlo "ERROR|WARN|Exception|Error"' + +function filterLog { + ol | grep --colour=always -E -e "${1-org.onlab|org.onosproject}" +} +alias olo='filterLog' +alias ole='olo "ERROR|WARN|Exception|Error"' + +# Pretty-print JSON output +alias pp='python -m json.tool' + +# Short-hand to launch Java API docs, REST API docs and ONOS GUI +alias docs='open $ONOS_ROOT/docs/target/site/apidocs/index.html' +alias rsdocs='onos-rsdocs' +alias gui='onos-gui' + + +# Test related conveniences + +# SSH to a specified ONOS instance +alias sshctl='onos-ssh' +alias sshnet='onos-ssh $OCN' + + +# Sets the primary instance to the specified instance number. +function setPrimaryInstance { + export OCI=$(env | egrep "OC[0-9]+" | sort | egrep OC${1:-1} | cut -d= -f2) + echo $OCI +} + +# Applies the settings in the specified cell file or lists current cell definition +# if no cell file is given. +function cell { + if [ -n "$1" ]; then + [ ! -f $ONOS_ROOT/tools/test/cells/$1 ] && \ + echo "No such cell: $1" >&2 && return 1 + 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) + setPrimaryInstance 1 >/dev/null + cell + else + env | egrep "ONOS_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' | sort + fi +} + +cell $ONOS_CELL > /dev/null + +# Lists available cells +function cells { + for cell in $(ls -1 $ONOS_ROOT/tools/test/cells); do + printf "%-16s %s\n" \ + "$([ $cell = $ONOS_CELL ] && echo $cell '*' || echo $cell)" \ + "$(grep '^#' $ONOS_ROOT/tools/test/cells/$cell | head -n 1)" + done +} + +# Miscellaneous +function spy { + ps -ef | egrep "$@" | grep -v egrep +} + +function nuke { + spy "$@" | cut -c7-11 | xargs kill +} + +# Edit a cell file by providing a cell name. Opens the cell file in $EDITOR. +function vicell() { + local apply=false + local create=false + local cdf="" + local cpath="${ONOS_ROOT}/tools/test/cells/" + + if [ -z "$1" ] || [ "$1" = "-h" ] ; then + printf "usage: vicell [file] [options]\n\noptions:\n" + printf "\t-a: apply the cell after editing\n" + printf "\t-e: [editor] set EDITOR to [editor] (default *vi*)\n" + printf "\t-c: create cell file if none exist\n\n" + return 1 + fi + + while [ $# -gt 0 ]; do + case "$1" in + -a) apply=true ;; + -e) EDITOR=$2; shift ;; + -c) create=true ;; + *) cdf="$1" ;; + esac + shift + done + + if [ ! -e "${cpath}${cdf}" ] && [ "$create" = "false" ]; then + printf "${cdf} : no such cell\n" && return 1 + fi + + if [ -z "${EDITOR}" ] || [ -x "$(which ${EDITOR})" ]; then + unset EDITOR && vi ${cpath}${cdf} + else + $EDITOR ${cpath}${cdf} + fi + ($apply) && cell ${cdf} +} + +# autocomplete for certain utilities +. ${ONOS_ROOT}/tools/test/bin/ogroup-opts diff --git a/framework/src/onos/tools/dev/bin/clean-branches.py b/framework/src/onos/tools/dev/bin/clean-branches.py new file mode 100755 index 00000000..3de7cb70 --- /dev/null +++ b/framework/src/onos/tools/dev/bin/clean-branches.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python + +from subprocess import check_output +import sys + +def get_merged_branches_by_change_id(): + '''a list of merged branches, by change id excluding support branches and master''' + raw_changeIds = check_output('git log origin/master | grep -i change-id | awk {\' print $2 \'}', shell=True) + changeIds = [b.strip() for b in raw_changeIds.split('\n') if b.strip()] + raw_branches = check_output('git branch -a', shell=True) + branches = [b.strip() for b in raw_branches.split('\n') + if b.strip() and not b.startswith('*') and \ + not b.strip().startswith('onos') and not b.strip().startswith('remotes') and b.strip() != 'master'] + to_delete = [] + for branch in branches: + raw_local_change_ids = check_output('git show %s | grep -i change-id | awk {\' print $2 \'}' % branch, shell=True) + local_change_ids = [ b.strip() for b in raw_local_change_ids.split('\n') if b.strip() ] + for local_change_id in local_change_ids: + if local_change_id in changeIds and branch not in to_delete: + to_delete.append(branch) + + return to_delete + + +def delete_branch(branch): + return check_output('git branch -D %s' % branch, shell=True).strip() + + +if __name__ == '__main__': + dry_run = '--confirm' not in sys.argv + one_by_one = '--one-by-one' in sys.argv + to_delete = get_merged_branches_by_change_id() + if len(to_delete) == 0: + print "Nothing to clean" + sys.exit(0) + for branch in to_delete: + if dry_run: + print branch + else: + if one_by_one: + print 'Do you want to delete branch %s [y/N]' % branch + ans = raw_input() + if ans == 'y' or ans == 'Y': + print delete_branch(branch) + else: + print delete_branch(branch) + + if dry_run: + print '*****************************************************************' + print 'Did not actually delete anything yet, pass in --confirm to delete' + print diff --git a/framework/src/onos/tools/dev/bin/onos-app b/framework/src/onos/tools/dev/bin/onos-app new file mode 100755 index 00000000..d6fe562b --- /dev/null +++ b/framework/src/onos/tools/dev/bin/onos-app @@ -0,0 +1,72 @@ +#!/bin/bash +# ----------------------------------------------------------------------------- +# Tool to manage ONOS applications using REST API. +# ----------------------------------------------------------------------------- + +node=${1:-$OCI} +cmd=${2:-list} +app=${3} + +export URL=http://$node:8181/onos/v1/applications +export HDR="-HContent-Type:application/octet-stream" +export curl="curl -sS --user $ONOS_WEB_USER:$ONOS_WEB_PASS" + +# Prints usage help +function usage { + echo "usage: onos-app list" >&2 + echo " onos-app {install|install!} " >&2 + echo " onos-app {reinstall|reinstall!} [] " >&2 + echo " onos-app {activate|deactivate|uninstall} " >&2 + exit 1 +} + +# Extract app name from the specified *.oar file +function appName { + aux=/tmp/aux$$.jar + cp $1 $aux + pushd /tmp >/dev/null + jar xf $aux app.xml && grep name= app.xml | cut -d\" -f2 + rm -f $aux /tmp/app.xml + popd >/dev/null +} + +[ -z $node -o "$node" = "-h" -o "$node" = "--help" -o "$node" = "-?" ] && usage + +case $cmd in + list) $curl -X GET $URL;; + install!|install) + [ $cmd = "install!" ] && activate="?activate=true" + [ $# -lt 3 -o ! -f $app ] && usage + $curl -X POST $HDR $URL$activate --data-binary @$app + ;; + + reinstall!|reinstall) + [ $cmd = "reinstall!" ] && activate="?activate=true" + [ $# -lt 4 -a ! -f "$3" ] && usage + [ $# -eq 4 -a ! -f "$4" ] && usage + oar=$4 + [ $# -lt 4 ] && oar=$3 && app=$(appName $oar) + $curl -X DELETE $URL/$app + $curl -X POST $HDR $URL$activate --data-binary @$oar + ;; + + uninstall) + [ $# -lt 3 ] && usage + $curl -X DELETE $URL/$app + ;; + activate) + [ $# -lt 3 ] && usage + $curl -X POST $URL/$app/active + ;; + deactivate) + [ $# -lt 3 ] && usage + $curl -X DELETE $URL/$app/active + ;; + + *) usage;; +esac + + +status=$? +echo # new line for prompt +exit $status diff --git a/framework/src/onos/tools/dev/bin/onos-build-selective b/framework/src/onos/tools/dev/bin/onos-build-selective new file mode 100755 index 00000000..ac2dec8e --- /dev/null +++ b/framework/src/onos/tools/dev/bin/onos-build-selective @@ -0,0 +1,44 @@ +#!/bin/bash +# ---------------------------------------------------------------------------- +# Selectively builds only those projects that contained modified Java files. +# ---------------------------------------------------------------------------- + +cd $ONOS_ROOT + +projects=$(find $ONOS_ROOT -type f -path '*/src/*' \ + -exec $ONOS_ROOT/tools/dev/bin/onos-build-selective-hook {} \; | \ + grep -v -f $ONOS_ROOT/tools/dev/bin/onos-build-selective.exclude | \ + sort -u | sed "s:$ONOS_ROOT::g" | tr '\n' ',' | \ + sed 's:/,:,:g;s:,/:,:g;s:^/::g;s:,$::g') + +if [ -n "$projects" ]; then + # Ascertain artifact IDs of the projects to be rebuilt + modulesERE="" + for pd in ${projects//,/ }; do + artifactId=$(grep -E "^ .*$" ${pd}/pom.xml | \ + sed 's/.[^>]*>//;s/<.*//') + modulesERE="$modulesERE|$artifactId" + done + modulesERE=${modulesERE#|*} + + # Search through staged app.xml files for any apps that require one or + # more of the modified artifacts. + appProjects=$(find $ONOS_ROOT -type f -path '*/target/oar/app.xml' | \ + xargs grep '' | grep -E "/($modulesERE)/" | \ + cut -d: -f1 | sed 's:/target/oar/.*::g' | \ + sort -u | sed "s:$ONOS_ROOT::g" | tr '\n' ',' | \ + sed 's:/,:,:g;s:,/:,:g;s:^/::g;s:,$::g') + + # If we found any, append those app projects to the list of projects to + # be built. + [ -n "$appProjects" ] && projects=$projects,$appProjects + + echo Building projects $projects + cd $ONOS_ROOT && mvn --projects $projects ${@:-clean install} + status=$? + + [ -n "$appProjects" ] && echo "App staging required for projects $appProjects" + exit $status +else + exit 0 +fi diff --git a/framework/src/onos/tools/dev/bin/onos-build-selective-hook b/framework/src/onos/tools/dev/bin/onos-build-selective-hook new file mode 100755 index 00000000..fbe77522 --- /dev/null +++ b/framework/src/onos/tools/dev/bin/onos-build-selective-hook @@ -0,0 +1,10 @@ +#!/bin/bash +# ---------------------------------------------------------------------------- +# Echoes project-level directory if a source file within is newer than the +# target directory. +# ---------------------------------------------------------------------------- + +[ ${1/*\//} = "package-info.java" ] && exit 0 + +project=${1/src*/} +[ ${project}target -nt $1 ] || echo ${project} diff --git a/framework/src/onos/tools/dev/bin/onos-build-selective.exclude b/framework/src/onos/tools/dev/bin/onos-build-selective.exclude new file mode 100644 index 00000000..1265494e --- /dev/null +++ b/framework/src/onos/tools/dev/bin/onos-build-selective.exclude @@ -0,0 +1,9 @@ +.*/archetypes/.* +.*/maven-plugin/.* +.*/build/conf/.* +.*/docs/.* +.*/openflow/drivers/.* +.*/cord-gui/.* +.*/jdvue/.* +.*/ovsdb/api/.* +.*/netconf/flow/.* \ No newline at end of file diff --git a/framework/src/onos/tools/dev/bin/onos-create-app b/framework/src/onos/tools/dev/bin/onos-create-app new file mode 100755 index 00000000..65b00b65 --- /dev/null +++ b/framework/src/onos/tools/dev/bin/onos-create-app @@ -0,0 +1,42 @@ +#!/bin/bash +# ----------------------------------------------------------------------------- +# Tool to create an application from scratch using ONOS Maven archetypes. +# ----------------------------------------------------------------------------- + +[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 +. $ONOS_ROOT/tools/build/envDefaults + +type=${1:-bundle} + +[ $type = app ] && archetype=bundle || archetype=$type + +if [ "$1" = "-?" -o "$1" = "-h" -o "$1" = "--help" ]; then + echo "usage: $(basename $0) {app|bundle|ui|cli|api} groupId artifactId version package mvn-options" + echo " All arguments are optional" + exit 1 +fi + +otherOptions="" +[ -n "$1" ] && shift +[ -n "$1" ] && otherOptions="$otherOptions -DgroupId=$1" && shift +[ -n "$1" ] && otherOptions="$otherOptions -DartifactId=$1" && dir=$1 && shift +[ -n "$1" ] && otherOptions="$otherOptions -Dversion=$1" && shift +[ -n "$1" ] && otherOptions="$otherOptions -Dpackage=$1" && shift + +mvn archetype:generate -DarchetypeGroupId=org.onosproject \ + -DarchetypeArtifactId=onos-$archetype-archetype \ + -DarchetypeVersion=$ONOS_POM_VERSION $otherOptions "$@" + +# Patch the pom.xml file to make this an app. +if [ $type = app ]; then + # We need to add a few lines to the pom.xml to make this an app + if [ -n "$dir" ] && [ -d $dir ]; then + egrep -v " ()" $dir/pom.xml > $dir/pom.app.xml + mv $dir/pom.app.xml $dir/pom.xml + else + echo + echo "IMPORTANT:" + echo "To build the application, you need to uncomment the 'onos.app.name' and 'onos.app.origin' properties in the pom.xml" + echo + fi +fi diff --git a/framework/src/onos/tools/dev/bin/onos-karaf b/framework/src/onos/tools/dev/bin/onos-karaf new file mode 100755 index 00000000..9c575fb4 --- /dev/null +++ b/framework/src/onos/tools/dev/bin/onos-karaf @@ -0,0 +1,7 @@ +#!/bin/bash +# ----------------------------------------------------------------------------- +# Makes sure local ONOS karaf instance is primed & staged and then launches +# karaf using the supplied arguments. +# ----------------------------------------------------------------------------- + +onos-setup-karaf && karaf "$@" \ No newline at end of file diff --git a/framework/src/onos/tools/dev/bin/onos-local-log b/framework/src/onos/tools/dev/bin/onos-local-log new file mode 100755 index 00000000..a17d3b9c --- /dev/null +++ b/framework/src/onos/tools/dev/bin/onos-local-log @@ -0,0 +1,10 @@ +#!/bin/bash +# ---------------------------------------------------------------------------- +# Continuously watches the Apache Karaf log; survives 'karaf clean' +# ---------------------------------------------------------------------------- +KARAF_LOG=${KARAF_LOG:-~/apache-karaf-$KARAF_VERSION/data/log/karaf.log} + +while true; do + [ ! -f $KARAF_LOG ] && sleep 2 && continue + tail -n 512 -f -F $KARAF_LOG +done diff --git a/framework/src/onos/tools/dev/bin/onos-setup-karaf b/framework/src/onos/tools/dev/bin/onos-setup-karaf new file mode 100755 index 00000000..3323d9d1 --- /dev/null +++ b/framework/src/onos/tools/dev/bin/onos-setup-karaf @@ -0,0 +1,123 @@ +#!/bin/bash +# ----------------------------------------------------------------------------- +# Downloads and sets-up Apache Karaf as a basis for running ONOS locally +# as a single-instance. +# +# Note that this in no way impacts the method for running ONOS remotely. +# For that, one should use onos-package and onos-install tools. +# ----------------------------------------------------------------------------- + +[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 +. $ONOS_ROOT/tools/build/envDefaults + +# TODO: consider putting this under ~/Applications/onos/apache-karaf-... +export KARAF_ROOT=${KARAF_ROOT:-~/Applications/apache-karaf-$KARAF_VERSION} +export STAGE=$(dirname $KARAF_ROOT) + +# Validates the specified IP regular expression against existing adapters. +# Excludes local-loopback. +function validateIp { + ifconfig | awk '{ print $2}' | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | grep $1 +} + +# Clean the previous Karaf directory if requested and if it exists. +if [ "$1" = "clean" ]; then + shift + CLEAN="true" + [ -d $KARAF_ROOT ] && rm -fr $KARAF_ROOT $STAGE/apps $STAGE/config +fi + +ONOS_IP=${ONOS_IP:-127.0.0.1} +IP="${1:-$ONOS_IP}" + +# If IP was not given, nor configured attempt to use ONOS_NIC env. variable +if [ -z "$IP" -a -n "$ONOS_NIC" ]; then + IP=$(validateIp $ONOS_NIC) + [ -z "$IP" ] && echo "No adapter with IP matching $ONOS_NIC found!" +else + # Otherwise, verify that the IP address given exists among the adapters. + saveIp=$IP + IP=$(validateIp $IP) + [ -z "$IP" ] && echo "No adapter with IP $saveIp found!" +fi + +# If IP is still not surmised or if usage was requested, show usage and IPs. +if [ -z "$IP" -o "$1" = "-?" -o "$1" = "-h" -o "$1" = "--help" ]; then + echo "usage: $(basename $0) [clean] " + echo "Available IP addresses are:" + validateIp . + exit 1 +fi + +SUBNET="$(echo $IP | cut -d. -f1-3)" + +# Bail on any errors +set -e + +# Check if Apache Karaf is already installed. +if [ ! -d $KARAF_ROOT ]; then + # Check if Apache Karaf bits are available and if not, fetch them. + if [ ! -f $KARAF_TAR ]; then + echo "Downloading $KARAF_TAR..." + curl -sL http://downloads.onosproject.org/third-party/apache-karaf-$KARAF_VERSION.tar.gz > $KARAF_TAR + fi + [ ! -f $KARAF_ZIP -a ! -f $KARAF_TAR ] && \ + echo "Apache Karaf bits $KARAF_ZIP or $KARAF_TAR not found" && exit 1 + + echo "Unpacking $KARAF_TAR to $STAGE..." + mkdir -p $STAGE + cd $STAGE + tar zxf $KARAF_TAR + rm -rf $KARAF_ROOT/demos +fi + +if ! grep -q "/onos-features/" $KARAF_ROOT/etc/org.apache.karaf.features.cfg; then + # Patch the Apache Karaf distribution file to add ONOS features repository + echo "Adding ONOS feature repository..." + perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.onosproject/onos-features/$ONOS_POM_VERSION/xml/features|" \ + $KARAF_ROOT/etc/org.apache.karaf.features.cfg +fi + +if ! grep -q ",onos-api," $KARAF_ROOT/etc/org.apache.karaf.features.cfg; then + # Patch the Apache Karaf distribution file to load default ONOS boot features + export BOOT_FEATURES="webconsole,onos-api,onos-core,onos-incubator,onos-cli,onos-rest,onos-gui" + echo "Adding ONOS boot features $BOOT_FEATURES..." + perl -pi.old -e "s|^(featuresBoot=.*)|\1,$BOOT_FEATURES|" \ + $KARAF_ROOT/etc/org.apache.karaf.features.cfg +fi + +if [ ! -f $KARAF_ROOT/lib/onos-branding-$ONOS_POM_VERSION.jar ]; then + # Patch the Apache Karaf distribution with ONOS branding bundle + echo "Branding as ONOS..." + rm -f $KARAF_ROOT/lib/onos-branding-*.jar + cp $M2_REPO/org/onosproject/onos-branding/$ONOS_POM_VERSION/onos-branding-$ONOS_POM_VERSION.jar \ + $KARAF_ROOT/lib +fi + +echo "Creating local cluster configs for IP $IP..." +[ -d $STAGE/config ] || mkdir -p $STAGE/config +cat > $STAGE/config/cluster.json < $STAGE/config/tablets.json <&2 && exit 1 +. $ONOS_ROOT/tools/build/envDefaults + +cd ~/.m2/repository +jar=$(find org/onosproject -type f -name '*.jar' | grep -e $1 | grep -v -e -tests | head -n 1) + +[ -z "$jar" ] && echo "No bundle $1 found for" && exit 1 + +bundle=$(echo $(basename $jar .jar) | sed 's/-[0-9].*//g') + +client "bundle:update -f $bundle" 2>/dev/null diff --git a/framework/src/onos/tools/dev/eclipse-cleanup.xml b/framework/src/onos/tools/dev/eclipse-cleanup.xml new file mode 100644 index 00000000..ee0f302d --- /dev/null +++ b/framework/src/onos/tools/dev/eclipse-cleanup.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/framework/src/onos/tools/dev/eclipse-formatter.xml b/framework/src/onos/tools/dev/eclipse-formatter.xml new file mode 100644 index 00000000..4383b5ab --- /dev/null +++ b/framework/src/onos/tools/dev/eclipse-formatter.xml @@ -0,0 +1,310 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/framework/src/onos/tools/dev/header.txt b/framework/src/onos/tools/dev/header.txt new file mode 100644 index 00000000..6c18c92c --- /dev/null +++ b/framework/src/onos/tools/dev/header.txt @@ -0,0 +1,13 @@ +Copyright $today.year Open Networking Laboratory + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/framework/src/onos/tools/dev/idea-settings.jar b/framework/src/onos/tools/dev/idea-settings.jar new file mode 100644 index 00000000..ad1826d9 Binary files /dev/null and b/framework/src/onos/tools/dev/idea-settings.jar differ diff --git a/framework/src/onos/tools/dev/onos.cshrc b/framework/src/onos/tools/dev/onos.cshrc new file mode 100644 index 00000000..e5d8e628 --- /dev/null +++ b/framework/src/onos/tools/dev/onos.cshrc @@ -0,0 +1,41 @@ +#!/bin/tcsh +# ONOS developer csh/tcsh profile conveniences +# Simply include in your own $HOME/.cshrc file. E.g.: +# +# setenv ONOS_ROOT $HOME/onos +# if ( -f $ONOS_ROOT/tools/dev/onos.cshrc ) then +# source $ONOS_ROOT/tools/dev/onos.cshrc +# endif +# + +# Root of the ONOS source tree +if ( ! $?ONOS_ROOT ) then + setenv ONOS_ROOT $HOME/onos +endif + +# Setup some environmental context for developers +if ( ! $?JAVA_HOME ) then + if ( -x /usr/libexec/java_home ) then + setenv JAVA_HOME `/usr/libexec/java_home -v 1.8` + else if ( -d /usr/lib/jvm/java-8-oracle ) then + setenv JAVA_HOME /usr/lib/jvm/java-8-oracle + else if ( -d /usr/lib/jvm/java-7-openjdk-amd64 ) then + setenv JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64 + endif +endif +if ( ! $?MAVEN ) then + setenv MAVEN $HOME/Applications/apache-maven-3.3.1 +endif +if ( ! $?KARAF_VERSION ) then + setenv KARAF_VERSION 3.0.3 +endif +if ( ! $?KARAF_ROOT ) then + setenv KARAF_ROOT $HOME/Applications/apache-karaf-$KARAF_VERSION +endif +setenv KARAF_LOG $KARAF_ROOT/data/log/karaf.log + +alias onos-setup-cell ' ( env ONOS_CELL=\!^ $ONOS_ROOT/tools/test/bin/onos-show-cell \!^ ) && setenv ONOS_CELL \!^' + +set path=( $path $ONOS_ROOT/tools/dev/bin $ONOS_ROOT/tools/test/bin ) +set path=( $path $ONOS_ROOT/tools/build ) +set path=( $path $KARAF_ROOT/bin ) -- cgit 1.2.3-korg