Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Tip
titleAdding Karaf related commands to PATH

To use karaf or onos command described in following sections, $KARAF_ROOT/bin needs be added to the PATH environment variable.

By default $ONOS_ROOT/tools/dev/bash_profile expects $KARAF_ROOT to be ~/Applications/apache-karaf-$KARAF_VERSION and add them to the PATH.

If you have installed Apache Karaf to a different path, define $KARAF_ROOT pointing to the correct path before including $ONOS_ROOT/tools/dev/bash_profile

Building and packaging ONOS 
Anchor
#build-onos
#build-onos

Build using Maven

ONOS uses Maven for managing the build process. To build the ONOS code-base from the top-most level, and from scratch, simply type the following: 

...

This triggers a full build, complete with unit testing. This may take several minutes, depending on the compute resources of the machine used. ONOS developer took-kit also includes onos-build command and alias ob, both of which build the entire code tree from any location.

When complete, there should be an output similar to the following:

Code Block
languagetext
[INFO] --- maven-bundle-plugin:2.5.3:install (default-install) @ onos-branding ---
[INFO] Installing org/onlab/onos/onos-branding/1.1.0-SNAPSHOT/onos-branding-1.1.0-SNAPSHOT.jar
[INFO] Writing OBR metadata
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] onos-build-conf ................................... SUCCESS [0.697s]
[INFO] onos .............................................. SUCCESS [2.549s]
[INFO] onlab-utils ....................................... SUCCESS [1.521s]
[INFO] onlab-junit ....................................... SUCCESS [4.707s]
[INFO] onlab-misc ........................................ SUCCESS [8.002s]
[INFO] onlab-netty ....................................... SUCCESS [3.119s]
[INFO] onlab-nio ......................................... SUCCESS [2.048s]
[INFO] onlab-osgi ........................................ SUCCESS [0.635s]
[INFO] onlab-rest ........................................ SUCCESS [0.637s]
[INFO] onlab-thirdparty .................................. SUCCESS [2.212s]
[INFO] onos-core ......................................... SUCCESS [0.481s]
[INFO] onos-api .......................................... SUCCESS [6.186s]
[INFO] onos-core-store ................................... SUCCESS [0.641s]
[INFO] onos-core-trivial ................................. SUCCESS [3.002s]
[INFO] onos-core-net ..................................... SUCCESS [5.778s]
[INFO] onos-core-serializers ............................. SUCCESS [2.788s]
[INFO] onos-core-dist .................................... SUCCESS [8.149s]
[INFO] onos-json ......................................... SUCCESS [0.615s]
[INFO] onos-web .......................................... SUCCESS [0.533s]
[INFO] onos-gui .......................................... SUCCESS [0.888s]
[INFO] onos-rest ......................................... SUCCESS [1.886s]
[INFO] onos-cli .......................................... SUCCESS [1.163s]
[INFO] onos-of ........................................... SUCCESS [0.457s]
[INFO] onos-of-api ....................................... SUCCESS [8.798s]
[INFO] onos-providers .................................... SUCCESS [0.431s]
[INFO] onos-of-providers ................................. SUCCESS [0.473s]
[INFO] onos-of-provider-device ........................... SUCCESS [1.940s]
[INFO] onos-of-provider-link ............................. SUCCESS [2.042s]
[INFO] onos-of-provider-host ............................. SUCCESS [1.562s]
[INFO] onos-of-provider-packet ........................... SUCCESS [1.946s]
[INFO] onos-of-provider-flow ............................. SUCCESS [0.821s]
[INFO] onos-lldp-provider ................................ SUCCESS [1.824s]
[INFO] onos-host-provider ................................ SUCCESS [1.672s]
[INFO] onos-of-ctl ....................................... SUCCESS [2.213s]
[INFO] onos-of-drivers ................................... SUCCESS [0.560s]
[INFO] onos-apps ......................................... SUCCESS [0.436s]
[INFO] onos-app-tvue ..................................... SUCCESS [0.625s]
[INFO] onos-app-fwd ...................................... SUCCESS [0.618s]
[INFO] onos-app-ifwd ..................................... SUCCESS [0.592s]
[INFO] onos-app-foo ...................................... SUCCESS [0.814s]
[INFO] onos-app-mobility ................................. SUCCESS [0.611s]
[INFO] onos-app-proxyarp ................................. SUCCESS [0.579s]
[INFO] onos-app-config ................................... SUCCESS [0.626s]
[INFO] onos-app-sdnip .................................... SUCCESS [5.847s]
[INFO] onos-app-calendar ................................. SUCCESS [0.631s]
[INFO] onos-app-optical .................................. SUCCESS [0.732s]
[INFO] onos-app-metrics .................................. SUCCESS [0.435s]
[INFO] onos-app-metrics-intent ........................... SUCCESS [0.639s]
[INFO] onos-app-metrics-topology ......................... SUCCESS [0.681s]
[INFO] onos-app-oecfg .................................... SUCCESS [1.282s]
[INFO] onos-features ..................................... SUCCESS [0.442s]
[INFO] onos-branding ..................................... SUCCESS [0.486s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:40.113s
[INFO] Finished at: Sat Nov 08 13:49:43 PST 2014
[INFO] Final Memory: 120M/1453M
[INFO] ------------------------------------------------------------------------
$ 

Running ONOS locally on development machine

ONOS may be run on the build machine directly, or packaged and launched on remote machines or VMs. This section describes both launching ONOS on the build machine locally.

First, we need to copy several config files to the local karaf directory. This can be easily done by running the following command:

Code Block
$ onos-setup-karaf clean <node-ip>

karaf can be used to start ONOS and attach to its CLI:

Code Block
languagetext
$ karaf clean
Welcome to Open Network Operating System (ONOS)!
     ____  _  ______  ____   
    / __ \/ |/ / __ \/ __/    
   / /_/ /    / /_/ /\ \       
   \____/_/|_/\____/___/      

                             
Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown ONOS.

onos>

At this point, typing help onos at the prompt should still bring up a list of available commands. Ctrl-D or logout will exit the CLI.

...

Launching karaf may bring up the default karaf prompt, without the 'ONOS' ASCII art. This is purely cosmetic, and shouldn't affect functionality.

If the branding is desired, one can move the branding bundle created during the build process to karaf's lib directory:

Code Block
languagetext
$ cp ${ONOS_ROOT}/tools/package/branding/target/onos-branding-1.2.0.jar ${KARAF_ROOT}/lib/

...

Packaging ONOS tar.gz or zip distributions

Once the build has completed, we can use the onos-package shell tool to produce an installable compressed tar file, which contains ONOS artifacts as well as ONOS-branded distribution of Apache Karaf. If your development machine has the zip command available, the onos-package tool will also produce a ZIP file variant with the same contents as the tar file. As with onos-buildonos-package also has an alias called op. The following shows what one should expect to see when running onos-package command:

Code Block
$ op
-rw-r--r--  1 tom  wheel  101196349 Apr 30 14:39 /tmp/onos-1.2.0.user.tar.gz
-rw-r--r--  1 tom  wheel  101763602 Apr 30 14:39 /tmp/onos-1.2.0.user.zip
$

Running ONOS locally on development machine

This section describes both launching ONOS on the build machine locally, which can be useful when developing functionality that does not require an ONOS cluster. To allow running ONOS directly on the development machine, ONOS toolbox comes with onos-karaf command, and corresponding ok alias, which makes sure that Apache Karaf is installed and properly configured to run ONOS before starting it.

Note: This tool is purposefully designed for development machines and is not intended to be used for production environments. It accepts the same arguments as does the original karaf command.

Selecting IP address

For the time-being, in order to run ONOS locally, we have to export ONOS_IP or ONOS_NIC environment variables with either the IP address or IP address prefix to configure ONOS clustering component. This requirement will disappear before the Cardinal release however. For example:

Code Block
$ export ONOS_IP=10.1.9.247

SelectingONOS apps to activate

To configure ONOS with a set of applications that should be automatically activated on startup, use the ONOS_APPS environment variable as follows:

Code Block
$ export ONOS_APPS=drivers,openflow,proxyarp,mobility,fwd

Starting ONOS

To pre-stage applications and appropriately configure ONOS, use the onos-karaf tool using the same arguments as would normally be used for the stock karaf command:

Code Block
languagetext
$ ok clean
Creating local cluster configs for IP 10.1.9.247...
Setting up hazelcast.xml for subnet 10.1.9.*...
Staging builtin apps...
Customizing apps to be auto-activated: drivers,openflow,proxyarp,mobility,fwd...
Welcome to Open Network Operating System (ONOS)!
     ____  _  ______  ____
    / __ \/ |/ / __ \/ __/
   / /_/ /    / /_/ /\ \
   \____/_/|_/\____/___/

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown ONOS.
onos>

At this point, typing help onos at the prompt should still bring up a list of available commands. Pressing Ctrl-D or logout will exit the CLI.

Deploying ONOS remotely using ONOS test tools

...