Thomas Vachuska
Committed by Gerrit Code Review

Adding ability to run ONOS locally via 'buck run onos'

Runs ONOS as a server and requires client connections with ONOS_USE_SSH unset.

Change-Id: Id0aedccbfddfb8f3f17b2ef7f73e805066976315
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
6 target_level = 8 6 target_level = 8
7 7
8 [alias] 8 [alias]
9 - onos = //tools/package:onos-package 9 + onos = //tools/package:onos-run
10 package = //tools/package:onos-package 10 package = //tools/package:onos-package
11 11
12 [download] 12 [download]
......
...@@ -106,3 +106,12 @@ genrule( ...@@ -106,3 +106,12 @@ genrule(
106 bash = '$(exe //buck-tools:onos-stage) $OUT $(location :onos-karaf) ' + ' '.join(sources), 106 bash = '$(exe //buck-tools:onos-stage) $OUT $(location :onos-karaf) ' + ' '.join(sources),
107 visibility = [ 'PUBLIC' ], 107 visibility = [ 'PUBLIC' ],
108 ) 108 )
109 +
110 +genrule(
111 + name = 'onos-run',
112 + out = 'onos-run',
113 + srcs = [ 'onos-run-karaf' ],
114 + bash = 'sed "s#ONOS_TAR=#ONOS_TAR=$(location :onos-package)#" $SRCS > $OUT; chmod +x $OUT',
115 + executable = True,
116 + visibility = [ 'PUBLIC' ],
117 +)
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -54,7 +54,7 @@ mv $KARAF_DIR $PREFIX ...@@ -54,7 +54,7 @@ mv $KARAF_DIR $PREFIX
54 # Stage the ONOS admin scripts and patch in Karaf service wrapper extras 54 # Stage the ONOS admin scripts and patch in Karaf service wrapper extras
55 cp -r bin $PREFIX 55 cp -r bin $PREFIX
56 cp -r init $PREFIX 56 cp -r init $PREFIX
57 -cp -r etc $PREFIX/$KARAF_DIR/etc/ 57 +cp -r etc/* $PREFIX/$KARAF_DIR/etc/
58 58
59 zip -q -0 -r $OUT $PREFIX 59 zip -q -0 -r $OUT $PREFIX
60 60
......
1 +#!/bin/bash
2 +# -----------------------------------------------------------------------------
3 +# Runs ONOS from distributable onos.tar.gz
4 +# -----------------------------------------------------------------------------
5 +
6 +ONOS_TAR=
7 +
8 +cd /tmp
9 +
10 +# Kill any running instances
11 +[ -f /tmp/onos.pid ] && kill -9 $(cat /tmp/onos.pid) &>/dev/null
12 +
13 +set -e
14 +
15 +# Blitz previously unrolled onos- directory
16 +rm -fr onos-*
17 +
18 +# Unroll new image from the specified tar file
19 +[ -f $ONOS_TAR ] && tar zxf $ONOS_TAR
20 +
21 +# Change into the ONOS home directory
22 +cd onos-*
23 +export ONOS_HOME=$PWD
24 +
25 +# FIXME: for now we're running using the karaf client; later use raw SSH
26 +unset ONOS_USE_SSH
27 +
28 +# Start ONOS as a server, but include any specified options
29 +./bin/onos-service server "$@" &>onos.log &
30 +echo "$!" > /tmp/onos.pid
31 +
32 +# Hang-on a bit and then start tailing the ONOS log output
33 +sleep 1
34 +tail -f ./apache*/data/log/karaf.log