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
Showing
13 changed files
with
135 additions
and
15 deletions
| ... | @@ -53,7 +53,7 @@ public class NetworkConfigReader implements NetworkConfigService { | ... | @@ -53,7 +53,7 @@ public class NetworkConfigReader implements NetworkConfigService { |
| 53 | 53 | ||
| 54 | private final Logger log = getLogger(getClass()); | 54 | private final Logger log = getLogger(getClass()); |
| 55 | 55 | ||
| 56 | - // Current working dir seems to be /opt/onos/apache-karaf-3.0.2 | 56 | + // Current working is /opt/onos/apache-karaf-* |
| 57 | // TODO: Set the path to /opt/onos/config | 57 | // TODO: Set the path to /opt/onos/config |
| 58 | private static final String CONFIG_DIR = "../config"; | 58 | private static final String CONFIG_DIR = "../config"; |
| 59 | private static final String DEFAULT_CONFIG_FILE = "addresses.json"; | 59 | private static final String DEFAULT_CONFIG_FILE = "addresses.json"; | ... | ... |
| ... | @@ -81,7 +81,6 @@ | ... | @@ -81,7 +81,6 @@ |
| 81 | <dependency> | 81 | <dependency> |
| 82 | <groupId>org.apache.karaf.features</groupId> | 82 | <groupId>org.apache.karaf.features</groupId> |
| 83 | <artifactId>org.apache.karaf.features.core</artifactId> | 83 | <artifactId>org.apache.karaf.features.core</artifactId> |
| 84 | - <version>3.0.2</version> | ||
| 85 | </dependency> | 84 | </dependency> |
| 86 | </dependencies> | 85 | </dependencies> |
| 87 | 86 | ... | ... |
| ... | @@ -67,6 +67,16 @@ public class FeaturesServiceAdapter implements org.apache.karaf.features.Feature | ... | @@ -67,6 +67,16 @@ public class FeaturesServiceAdapter implements org.apache.karaf.features.Feature |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | @Override | 69 | @Override |
| 70 | + public Repository getRepository(URI uri) { | ||
| 71 | + return null; | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @Override | ||
| 75 | + public String getRepositoryName(URI uri) { | ||
| 76 | + return null; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + @Override | ||
| 70 | public void installFeature(String name) throws Exception { | 80 | public void installFeature(String name) throws Exception { |
| 71 | 81 | ||
| 72 | } | 82 | } |
| ... | @@ -132,6 +142,16 @@ public class FeaturesServiceAdapter implements org.apache.karaf.features.Feature | ... | @@ -132,6 +142,16 @@ public class FeaturesServiceAdapter implements org.apache.karaf.features.Feature |
| 132 | } | 142 | } |
| 133 | 143 | ||
| 134 | @Override | 144 | @Override |
| 145 | + public Feature[] getFeatures(String name, String version) throws Exception { | ||
| 146 | + return new Feature[0]; | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + @Override | ||
| 150 | + public Feature[] getFeatures(String name) throws Exception { | ||
| 151 | + return new Feature[0]; | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + @Override | ||
| 135 | public Feature getFeature(String name, String version) throws Exception { | 155 | public Feature getFeature(String name, String version) throws Exception { |
| 136 | return null; | 156 | return null; |
| 137 | } | 157 | } | ... | ... |
| ... | @@ -71,6 +71,8 @@ | ... | @@ -71,6 +71,8 @@ |
| 71 | <netty4.version>4.0.23.Final</netty4.version> | 71 | <netty4.version>4.0.23.Final</netty4.version> |
| 72 | <copycat.version>0.4.0.onos</copycat.version> | 72 | <copycat.version>0.4.0.onos</copycat.version> |
| 73 | <openflowj.version>0.3.9.oe</openflowj.version> | 73 | <openflowj.version>0.3.9.oe</openflowj.version> |
| 74 | + <karaf.version>3.0.3</karaf.version> | ||
| 75 | + <jersey.version>1.19</jersey.version> | ||
| 74 | </properties> | 76 | </properties> |
| 75 | 77 | ||
| 76 | <distributionManagement> | 78 | <distributionManagement> |
| ... | @@ -194,19 +196,19 @@ | ... | @@ -194,19 +196,19 @@ |
| 194 | <dependency> | 196 | <dependency> |
| 195 | <groupId>com.sun.jersey</groupId> | 197 | <groupId>com.sun.jersey</groupId> |
| 196 | <artifactId>jersey-servlet</artifactId> | 198 | <artifactId>jersey-servlet</artifactId> |
| 197 | - <version>1.19</version> | 199 | + <version>${jersey.version}</version> |
| 198 | <scope>provided</scope> | 200 | <scope>provided</scope> |
| 199 | </dependency> | 201 | </dependency> |
| 200 | <dependency> | 202 | <dependency> |
| 201 | <groupId>com.sun.jersey.jersey-test-framework</groupId> | 203 | <groupId>com.sun.jersey.jersey-test-framework</groupId> |
| 202 | <artifactId>jersey-test-framework-core</artifactId> | 204 | <artifactId>jersey-test-framework-core</artifactId> |
| 203 | - <version>1.19</version> | 205 | + <version>${jersey.version}</version> |
| 204 | <scope>test</scope> | 206 | <scope>test</scope> |
| 205 | </dependency> | 207 | </dependency> |
| 206 | <dependency> | 208 | <dependency> |
| 207 | <groupId>com.sun.jersey.jersey-test-framework</groupId> | 209 | <groupId>com.sun.jersey.jersey-test-framework</groupId> |
| 208 | <artifactId>jersey-test-framework-grizzly2</artifactId> | 210 | <artifactId>jersey-test-framework-grizzly2</artifactId> |
| 209 | - <version>1.19</version> | 211 | + <version>${jersey.version}</version> |
| 210 | <scope>test</scope> | 212 | <scope>test</scope> |
| 211 | </dependency> | 213 | </dependency> |
| 212 | <dependency> | 214 | <dependency> |
| ... | @@ -241,10 +243,18 @@ | ... | @@ -241,10 +243,18 @@ |
| 241 | <version>1.9.8</version> | 243 | <version>1.9.8</version> |
| 242 | <scope>provided</scope> | 244 | <scope>provided</scope> |
| 243 | </dependency> | 245 | </dependency> |
| 246 | + | ||
| 247 | + <dependency> | ||
| 248 | + <groupId>org.apache.karaf.features</groupId> | ||
| 249 | + <artifactId>org.apache.karaf.features.core</artifactId> | ||
| 250 | + <version>${karaf.version}</version> | ||
| 251 | + <scope>provided</scope> | ||
| 252 | + </dependency> | ||
| 253 | + | ||
| 244 | <dependency> | 254 | <dependency> |
| 245 | <groupId>org.apache.karaf.shell</groupId> | 255 | <groupId>org.apache.karaf.shell</groupId> |
| 246 | <artifactId>org.apache.karaf.shell.console</artifactId> | 256 | <artifactId>org.apache.karaf.shell.console</artifactId> |
| 247 | - <version>3.0.2</version> | 257 | + <version>${karaf.version}</version> |
| 248 | <scope>provided</scope> | 258 | <scope>provided</scope> |
| 249 | </dependency> | 259 | </dependency> |
| 250 | 260 | ... | ... |
| ... | @@ -82,7 +82,8 @@ public class NullLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -82,7 +82,8 @@ public class NullLinkProvider extends AbstractProvider implements LinkProvider { |
| 82 | private final Logger log = getLogger(getClass()); | 82 | private final Logger log = getLogger(getClass()); |
| 83 | 83 | ||
| 84 | // default topology file location and name. | 84 | // default topology file location and name. |
| 85 | - private static final String CFG_PATH = "/opt/onos/apache-karaf-3.0.2/etc/linkGraph.cfg"; | 85 | + private static final String CFG_PATH = "etc/linkGraph.cfg"; |
| 86 | + | ||
| 86 | // default number of workers. Eventually make this tunable | 87 | // default number of workers. Eventually make this tunable |
| 87 | private static final int THREADS = (int) Math.max(1, Runtime.getRuntime().availableProcessors() * 0.8); | 88 | private static final int THREADS = (int) Math.max(1, Runtime.getRuntime().availableProcessors() * 0.8); |
| 88 | 89 | ... | ... |
| ... | @@ -5,7 +5,7 @@ export ONOS_ROOT=${ONOS_ROOT:-~/onos} | ... | @@ -5,7 +5,7 @@ export ONOS_ROOT=${ONOS_ROOT:-~/onos} |
| 5 | 5 | ||
| 6 | # M2 repository and Karaf gold bits | 6 | # M2 repository and Karaf gold bits |
| 7 | export M2_REPO=${M2_REPO:-~/.m2/repository} | 7 | export M2_REPO=${M2_REPO:-~/.m2/repository} |
| 8 | -export KARAF_VERSION=${KARAF_VERSION:-3.0.2} | 8 | +export KARAF_VERSION=${KARAF_VERSION:-3.0.3} |
| 9 | export KARAF_ZIP=${KARAF_ZIP:-~/Downloads/apache-karaf-$KARAF_VERSION.zip} | 9 | export KARAF_ZIP=${KARAF_ZIP:-~/Downloads/apache-karaf-$KARAF_VERSION.zip} |
| 10 | export KARAF_TAR=${KARAF_TAR:-~/Downloads/apache-karaf-$KARAF_VERSION.tar.gz} | 10 | export KARAF_TAR=${KARAF_TAR:-~/Downloads/apache-karaf-$KARAF_VERSION.tar.gz} |
| 11 | export KARAF_DIST=$(basename $KARAF_ZIP .zip) | 11 | export KARAF_DIST=$(basename $KARAF_ZIP .zip) | ... | ... |
| ... | @@ -18,7 +18,7 @@ fi | ... | @@ -18,7 +18,7 @@ fi |
| 18 | 18 | ||
| 19 | export MAVEN=${MAVEN:-~/Applications/apache-maven-3.3.1} | 19 | export MAVEN=${MAVEN:-~/Applications/apache-maven-3.3.1} |
| 20 | 20 | ||
| 21 | -export KARAF_VERSION=${KARAF_VERSION:-3.0.2} | 21 | +export KARAF_VERSION=${KARAF_VERSION:-3.0.3} |
| 22 | export KARAF_ROOT=${KARAF_ROOT:-~/Applications/apache-karaf-$KARAF_VERSION} | 22 | export KARAF_ROOT=${KARAF_ROOT:-~/Applications/apache-karaf-$KARAF_VERSION} |
| 23 | export KARAF_LOG=$KARAF_ROOT/data/log/karaf.log | 23 | export KARAF_LOG=$KARAF_ROOT/data/log/karaf.log |
| 24 | 24 | ... | ... |
| ... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
| 2 | # ---------------------------------------------------------------------------- | 2 | # ---------------------------------------------------------------------------- |
| 3 | # Continuously watches the Apache Karaf log; survives 'karaf clean' | 3 | # Continuously watches the Apache Karaf log; survives 'karaf clean' |
| 4 | # ---------------------------------------------------------------------------- | 4 | # ---------------------------------------------------------------------------- |
| 5 | -KARAF_LOG=${KARAF_LOG:-~/apache-karaf-3.0.2/data/log/karaf.log} | 5 | +KARAF_LOG=${KARAF_LOG:-~/apache-karaf-$KARAF_VERSION/data/log/karaf.log} |
| 6 | 6 | ||
| 7 | while true; do | 7 | while true; do |
| 8 | [ ! -f $KARAF_LOG ] && sleep 2 && continue | 8 | [ ! -f $KARAF_LOG ] && sleep 2 && continue | ... | ... |
| ... | @@ -27,7 +27,7 @@ if ( ! $?MAVEN ) then | ... | @@ -27,7 +27,7 @@ if ( ! $?MAVEN ) then |
| 27 | setenv MAVEN $HOME/Applications/apache-maven-3.3.1 | 27 | setenv MAVEN $HOME/Applications/apache-maven-3.3.1 |
| 28 | endif | 28 | endif |
| 29 | if ( ! $?KARAF_VERSION ) then | 29 | if ( ! $?KARAF_VERSION ) then |
| 30 | - setenv KARAF_VERSION 3.0.2 | 30 | + setenv KARAF_VERSION 3.0.3 |
| 31 | endif | 31 | endif |
| 32 | if ( ! $?KARAF_ROOT ) then | 32 | if ( ! $?KARAF_ROOT ) then |
| 33 | setenv KARAF_ROOT $HOME/Applications/apache-karaf-$KARAF_VERSION | 33 | setenv KARAF_ROOT $HOME/Applications/apache-karaf-$KARAF_VERSION | ... | ... |
| ... | @@ -79,7 +79,7 @@ | ... | @@ -79,7 +79,7 @@ |
| 79 | <dependency> | 79 | <dependency> |
| 80 | <groupId>org.apache.karaf.shell</groupId> | 80 | <groupId>org.apache.karaf.shell</groupId> |
| 81 | <artifactId>org.apache.karaf.shell.console</artifactId> | 81 | <artifactId>org.apache.karaf.shell.console</artifactId> |
| 82 | - <version>3.0.2</version> | 82 | + <version>3.0.3</version> |
| 83 | <scope>provided</scope> | 83 | <scope>provided</scope> |
| 84 | </dependency> | 84 | </dependency> |
| 85 | </dependencies> | 85 | </dependencies> | ... | ... |
| ... | @@ -81,7 +81,7 @@ org.ops4j.pax.url.mvn.defaultRepositories=\ | ... | @@ -81,7 +81,7 @@ org.ops4j.pax.url.mvn.defaultRepositories=\ |
| 81 | # http://repository.springsource.com/maven/bundles/external@id=spring.ebr.external | 81 | # http://repository.springsource.com/maven/bundles/external@id=spring.ebr.external |
| 82 | # http://zodiac.springsource.com/maven/bundles/release@id=gemini | 82 | # http://zodiac.springsource.com/maven/bundles/release@id=gemini |
| 83 | # http://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases | 83 | # http://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases |
| 84 | -# https://oss.sonatype.org/content/repositories/snapshots@id=sonatype.snapshots.deploy@snapshots@norelease | 84 | +# https://oss.sonatype.org/content/repositories/snapshots@id=sonatype.snapshots.deploy@snapshots@noreleases |
| 85 | # https://oss.sonatype.org/content/repositories/ops4j-snapshots@id=ops4j.sonatype.snapshots.deploy@snapshots@noreleases | 85 | # https://oss.sonatype.org/content/repositories/ops4j-snapshots@id=ops4j.sonatype.snapshots.deploy@snapshots@noreleases |
| 86 | # To add repositories to the default ones, prepend '+' to the list of repositories | 86 | # To add repositories to the default ones, prepend '+' to the list of repositories |
| 87 | # to add. | 87 | # to add. |
| ... | @@ -97,5 +97,5 @@ org.ops4j.pax.url.mvn.repositories= \ | ... | @@ -97,5 +97,5 @@ org.ops4j.pax.url.mvn.repositories= \ |
| 97 | http://repository.springsource.com/maven/bundles/external@id=spring.ebr.external, \ | 97 | http://repository.springsource.com/maven/bundles/external@id=spring.ebr.external, \ |
| 98 | http://zodiac.springsource.com/maven/bundles/release@id=gemini, \ | 98 | http://zodiac.springsource.com/maven/bundles/release@id=gemini, \ |
| 99 | http://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases, \ | 99 | http://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases, \ |
| 100 | - https://oss.sonatype.org/content/repositories/snapshots@id=sonatype.snapshots.deploy@snapshots@norelease, \ | 100 | + https://oss.sonatype.org/content/repositories/snapshots@id=sonatype.snapshots.deploy@snapshots@noreleases, \ |
| 101 | https://oss.sonatype.org/content/repositories/ops4j-snapshots@id=ops4j.sonatype.snapshots.deploy@snapshots@noreleases | 101 | https://oss.sonatype.org/content/repositories/ops4j-snapshots@id=ops4j.sonatype.snapshots.deploy@snapshots@noreleases | ... | ... |
tools/test/bin/onos-setup-karaf
0 → 100755
| 1 | +#!/bin/bash | ||
| 2 | +# ----------------------------------------------------------------------------- | ||
| 3 | +# Downloads and sets-up Apache Karaf as a basis for running ONOS locally | ||
| 4 | +# as a single-instance. | ||
| 5 | +# ----------------------------------------------------------------------------- | ||
| 6 | + | ||
| 7 | +[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 | ||
| 8 | +. $ONOS_ROOT/tools/build/envDefaults | ||
| 9 | + | ||
| 10 | +# TODO: consider putting this under ~/Applications/onos/apache-karaf-... | ||
| 11 | +export KARAF_ROOT=${KARAF_ROOT:-~/Applications/apache-karaf-$KARAF_VERSION} | ||
| 12 | +export STAGE=$(dirname $KARAF_ROOT) | ||
| 13 | + | ||
| 14 | +# Clean the previous Karaf directory if requested and if it exists. | ||
| 15 | +if [ "$1" = "clean" ]; then | ||
| 16 | + shift | ||
| 17 | + [ -d $KARAF_ROOT ] && rm -fr $KARAF_ROOT $STAGE/apps $STAGE/config | ||
| 18 | +fi | ||
| 19 | + | ||
| 20 | +if [ -z $1 ]; then | ||
| 21 | + echo "usage: $(basename $0) [clean] <ip-address>" | ||
| 22 | + echo "Available IP addresses are:" | ||
| 23 | + ifconfig | grep 'inet ' | cut -d\ -f2 | grep -v "127.0.0.1" | ||
| 24 | + exit 1 | ||
| 25 | +fi | ||
| 26 | + | ||
| 27 | +IP="$1" | ||
| 28 | +SUBNET="$(echo $IP | cut -d. -f1-3)" | ||
| 29 | + | ||
| 30 | +# Bail on any errors | ||
| 31 | +set -e | ||
| 32 | + | ||
| 33 | +# Check if Apache Karaf is already installed. | ||
| 34 | +if [ ! -d $KARAF_ROOT ]; then | ||
| 35 | + # Check if Apache Karaf bits are available and if not, fetch them. | ||
| 36 | + if [ ! -f $KARAF_TAR ]; then | ||
| 37 | + echo "Downloading $KARAF_TAR..." | ||
| 38 | + curl -sL http://downloads.onosproject.org/third-party/apache-karaf-$KARAF_VERSION.tar.gz > $KARAF_TAR | ||
| 39 | + fi | ||
| 40 | + [ ! -f $KARAF_ZIP -a ! -f $KARAF_TAR ] && \ | ||
| 41 | + echo "Apache Karaf bits $KARAF_ZIP or $KARAF_TAR not found" && exit 1 | ||
| 42 | + | ||
| 43 | + echo "Unpacking $KARAF_TAR to $STAGE..." | ||
| 44 | + mkdir -p $STAGE | ||
| 45 | + cd $STAGE | ||
| 46 | + tar zxf $KARAF_TAR | ||
| 47 | + rm -rf $KARAF_ROOT/demos | ||
| 48 | +fi | ||
| 49 | + | ||
| 50 | +if ! grep -q "/onos-features/" $KARAF_ROOT/etc/org.apache.karaf.features.cfg; then | ||
| 51 | + # Patch the Apache Karaf distribution file to add ONOS features repository | ||
| 52 | + echo "Adding ONOS feature repository..." | ||
| 53 | + perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.onosproject/onos-features/$ONOS_POM_VERSION/xml/features|" \ | ||
| 54 | + $KARAF_ROOT/etc/org.apache.karaf.features.cfg | ||
| 55 | +fi | ||
| 56 | + | ||
| 57 | +if ! grep -q ",onos-api," $KARAF_ROOT/etc/org.apache.karaf.features.cfg; then | ||
| 58 | + # Patch the Apache Karaf distribution file to load default ONOS boot features | ||
| 59 | + export BOOT_FEATURES="webconsole,onos-api,onos-core,onos-cli,onos-rest,onos-gui" | ||
| 60 | + echo "Adding ONOS boot features $BOOT_FEATURES..." | ||
| 61 | + perl -pi.old -e "s|^(featuresBoot=.*)|\1,$BOOT_FEATURES|" \ | ||
| 62 | + $KARAF_ROOT/etc/org.apache.karaf.features.cfg | ||
| 63 | +fi | ||
| 64 | + | ||
| 65 | +if [ ! -f $KARAF_ROOT/lib/onos-branding-$ONOS_POM_VERSION.jar ]; then | ||
| 66 | + # Patch the Apache Karaf distribution with ONOS branding bundle | ||
| 67 | + echo "Branding as ONOS..." | ||
| 68 | + rm -f $KARAF_ROOT/lib/onos-branding-*.jar | ||
| 69 | + cp $M2_REPO/org/onosproject/onos-branding/$ONOS_POM_VERSION/onos-branding-$ONOS_POM_VERSION.jar \ | ||
| 70 | + $KARAF_ROOT/lib | ||
| 71 | +fi | ||
| 72 | + | ||
| 73 | +if [ ! -d $STAGE/apps -o ! -d $STAGE/config ]; then | ||
| 74 | + echo "Creating local cluster configs for IP $IP..." | ||
| 75 | + mkdir -p $STAGE/apps $STAGE/config | ||
| 76 | + cat > $STAGE/config/cluster.json <<EOF | ||
| 77 | + { "ipPrefix": "$SUBNET.*", | ||
| 78 | + "nodes":[ { "id": "$IP", "ip": "$IP", "tcpPort": 9876 }]} | ||
| 79 | +EOF | ||
| 80 | + | ||
| 81 | + cat > $STAGE/config/tablets.json <<EOF | ||
| 82 | + { "nodes": [ { "ip": "$IP", "id": "$IP", "tcpPort": 7238 }], | ||
| 83 | + "partitions": { "p1": [ { "ip": "$IP", "id": "$IP", "tcpPort": 7238 }]}} | ||
| 84 | +EOF | ||
| 85 | +fi | ||
| 86 | + | ||
| 87 | +echo "Setting up hazelcast.xml for subnet $SUBNET..." | ||
| 88 | +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 | ||
| 90 | +perl -pi.old -e "s/ <name>onos</ <name>$IP</" $KARAF_ROOT/etc/hazelcast.xml |
| ... | @@ -36,7 +36,7 @@ class ONOS( Controller ): | ... | @@ -36,7 +36,7 @@ class ONOS( Controller ): |
| 36 | #self.checkListening() | 36 | #self.checkListening() |
| 37 | 37 | ||
| 38 | self.onosDir = onosDir | 38 | self.onosDir = onosDir |
| 39 | - self.karafDir = onosDir + 'apache-karaf-3.0.2/' | 39 | + self.karafDir = onosDir + 'apache-karaf-3.0.3/' |
| 40 | self.instanceDir = self.karafDir | 40 | self.instanceDir = self.karafDir |
| 41 | 41 | ||
| 42 | # add default modules | 42 | # add default modules | ... | ... |
-
Please register or login to post a comment