Thomas Vachuska
Committed by Brian O'Connor

ONOS-1323 Upgrading environment to use Apache Karaf 3.0.3

Requires restart of any dev shell sessions that may have KARAF_VERSION=3.0.2 already set.

Developers that have their own local Karaf will have to run 'onos-setup-karaf <ip-address>' command

Change-Id: Iba234b3cd5af89de6dd249c97cac97525364cc34
......@@ -53,7 +53,7 @@ public class NetworkConfigReader implements NetworkConfigService {
private final Logger log = getLogger(getClass());
// Current working dir seems to be /opt/onos/apache-karaf-3.0.2
// Current working is /opt/onos/apache-karaf-*
// TODO: Set the path to /opt/onos/config
private static final String CONFIG_DIR = "../config";
private static final String DEFAULT_CONFIG_FILE = "addresses.json";
......
......@@ -81,7 +81,6 @@
<dependency>
<groupId>org.apache.karaf.features</groupId>
<artifactId>org.apache.karaf.features.core</artifactId>
<version>3.0.2</version>
</dependency>
</dependencies>
......
......@@ -67,6 +67,16 @@ public class FeaturesServiceAdapter implements org.apache.karaf.features.Feature
}
@Override
public Repository getRepository(URI uri) {
return null;
}
@Override
public String getRepositoryName(URI uri) {
return null;
}
@Override
public void installFeature(String name) throws Exception {
}
......@@ -132,6 +142,16 @@ public class FeaturesServiceAdapter implements org.apache.karaf.features.Feature
}
@Override
public Feature[] getFeatures(String name, String version) throws Exception {
return new Feature[0];
}
@Override
public Feature[] getFeatures(String name) throws Exception {
return new Feature[0];
}
@Override
public Feature getFeature(String name, String version) throws Exception {
return null;
}
......
......@@ -71,6 +71,8 @@
<netty4.version>4.0.23.Final</netty4.version>
<copycat.version>0.4.0.onos</copycat.version>
<openflowj.version>0.3.9.oe</openflowj.version>
<karaf.version>3.0.3</karaf.version>
<jersey.version>1.19</jersey.version>
</properties>
<distributionManagement>
......@@ -194,19 +196,19 @@
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>1.19</version>
<version>${jersey.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-core</artifactId>
<version>1.19</version>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-grizzly2</artifactId>
<version>1.19</version>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
......@@ -241,10 +243,18 @@
<version>1.9.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.karaf.features</groupId>
<artifactId>org.apache.karaf.features.core</artifactId>
<version>${karaf.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.karaf.shell</groupId>
<artifactId>org.apache.karaf.shell.console</artifactId>
<version>3.0.2</version>
<version>${karaf.version}</version>
<scope>provided</scope>
</dependency>
......
......@@ -82,7 +82,8 @@ public class NullLinkProvider extends AbstractProvider implements LinkProvider {
private final Logger log = getLogger(getClass());
// default topology file location and name.
private static final String CFG_PATH = "/opt/onos/apache-karaf-3.0.2/etc/linkGraph.cfg";
private static final String CFG_PATH = "etc/linkGraph.cfg";
// default number of workers. Eventually make this tunable
private static final int THREADS = (int) Math.max(1, Runtime.getRuntime().availableProcessors() * 0.8);
......
......@@ -5,7 +5,7 @@ export ONOS_ROOT=${ONOS_ROOT:-~/onos}
# M2 repository and Karaf gold bits
export M2_REPO=${M2_REPO:-~/.m2/repository}
export KARAF_VERSION=${KARAF_VERSION:-3.0.2}
export KARAF_VERSION=${KARAF_VERSION:-3.0.3}
export KARAF_ZIP=${KARAF_ZIP:-~/Downloads/apache-karaf-$KARAF_VERSION.zip}
export KARAF_TAR=${KARAF_TAR:-~/Downloads/apache-karaf-$KARAF_VERSION.tar.gz}
export KARAF_DIST=$(basename $KARAF_ZIP .zip)
......
......@@ -18,7 +18,7 @@ fi
export MAVEN=${MAVEN:-~/Applications/apache-maven-3.3.1}
export KARAF_VERSION=${KARAF_VERSION:-3.0.2}
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
......
......@@ -2,7 +2,7 @@
# ----------------------------------------------------------------------------
# Continuously watches the Apache Karaf log; survives 'karaf clean'
# ----------------------------------------------------------------------------
KARAF_LOG=${KARAF_LOG:-~/apache-karaf-3.0.2/data/log/karaf.log}
KARAF_LOG=${KARAF_LOG:-~/apache-karaf-$KARAF_VERSION/data/log/karaf.log}
while true; do
[ ! -f $KARAF_LOG ] && sleep 2 && continue
......
......@@ -27,7 +27,7 @@ if ( ! $?MAVEN ) then
setenv MAVEN $HOME/Applications/apache-maven-3.3.1
endif
if ( ! $?KARAF_VERSION ) then
setenv KARAF_VERSION 3.0.2
setenv KARAF_VERSION 3.0.3
endif
if ( ! $?KARAF_ROOT ) then
setenv KARAF_ROOT $HOME/Applications/apache-karaf-$KARAF_VERSION
......
......@@ -79,7 +79,7 @@
<dependency>
<groupId>org.apache.karaf.shell</groupId>
<artifactId>org.apache.karaf.shell.console</artifactId>
<version>3.0.2</version>
<version>3.0.3</version>
<scope>provided</scope>
</dependency>
</dependencies>
......
......@@ -81,7 +81,7 @@ org.ops4j.pax.url.mvn.defaultRepositories=\
# http://repository.springsource.com/maven/bundles/external@id=spring.ebr.external
# http://zodiac.springsource.com/maven/bundles/release@id=gemini
# http://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases
# https://oss.sonatype.org/content/repositories/snapshots@id=sonatype.snapshots.deploy@snapshots@norelease
# https://oss.sonatype.org/content/repositories/snapshots@id=sonatype.snapshots.deploy@snapshots@noreleases
# https://oss.sonatype.org/content/repositories/ops4j-snapshots@id=ops4j.sonatype.snapshots.deploy@snapshots@noreleases
# To add repositories to the default ones, prepend '+' to the list of repositories
# to add.
......@@ -97,5 +97,5 @@ org.ops4j.pax.url.mvn.repositories= \
http://repository.springsource.com/maven/bundles/external@id=spring.ebr.external, \
http://zodiac.springsource.com/maven/bundles/release@id=gemini, \
http://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases, \
https://oss.sonatype.org/content/repositories/snapshots@id=sonatype.snapshots.deploy@snapshots@norelease, \
https://oss.sonatype.org/content/repositories/snapshots@id=sonatype.snapshots.deploy@snapshots@noreleases, \
https://oss.sonatype.org/content/repositories/ops4j-snapshots@id=ops4j.sonatype.snapshots.deploy@snapshots@noreleases
......
#!/bin/bash
# -----------------------------------------------------------------------------
# Downloads and sets-up Apache Karaf as a basis for running ONOS locally
# as a single-instance.
# -----------------------------------------------------------------------------
[ ! -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)
# Clean the previous Karaf directory if requested and if it exists.
if [ "$1" = "clean" ]; then
shift
[ -d $KARAF_ROOT ] && rm -fr $KARAF_ROOT $STAGE/apps $STAGE/config
fi
if [ -z $1 ]; then
echo "usage: $(basename $0) [clean] <ip-address>"
echo "Available IP addresses are:"
ifconfig | grep 'inet ' | cut -d\ -f2 | grep -v "127.0.0.1"
exit 1
fi
IP="$1"
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-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
if [ ! -d $STAGE/apps -o ! -d $STAGE/config ]; then
echo "Creating local cluster configs for IP $IP..."
mkdir -p $STAGE/apps $STAGE/config
cat > $STAGE/config/cluster.json <<EOF
{ "ipPrefix": "$SUBNET.*",
"nodes":[ { "id": "$IP", "ip": "$IP", "tcpPort": 9876 }]}
EOF
cat > $STAGE/config/tablets.json <<EOF
{ "nodes": [ { "ip": "$IP", "id": "$IP", "tcpPort": 7238 }],
"partitions": { "p1": [ { "ip": "$IP", "id": "$IP", "tcpPort": 7238 }]}}
EOF
fi
echo "Setting up hazelcast.xml for subnet $SUBNET..."
cp $ONOS_ROOT/tools/package/etc/hazelcast.xml $KARAF_ROOT/etc/hazelcast.xml
perl -pi.old -e "s/192.168.56/$SUBNET/" $KARAF_ROOT/etc/hazelcast.xml
perl -pi.old -e "s/ <name>onos</ <name>$IP</" $KARAF_ROOT/etc/hazelcast.xml
......@@ -36,7 +36,7 @@ class ONOS( Controller ):
#self.checkListening()
self.onosDir = onosDir
self.karafDir = onosDir + 'apache-karaf-3.0.2/'
self.karafDir = onosDir + 'apache-karaf-3.0.3/'
self.instanceDir = self.karafDir
# add default modules
......