Versions Compared

Key

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

This Quick Start describes a simple "local" workflow where you build and run ONOS on a single development machine.

Install Bazel and other dependencies

First of all, you should install

...

On Ubuntu/Debian, you can do the following:

Go to Oracle JDK download website, login and download the tar ball : jdk-8uxxx-linux-x64.tar.gz

...

languagebash
titleJava dependency

...

Bazel, an open-source build tool developed by Google. We will use Bazel to build and run ONOS. We suggest downloading and installing Bazel using the official instructions:

https://docs.bazel.build/versions/master/install.html

Some other dependencies are required as well. Use your package manager of choice to install these:

Code Block
languagebash
titleOther dependencies
git
zip
curl
unzip
python # CentOS installations only
python 2.7 required by some development scripts
python3 # VersionRequired 2.7 is requiredby Bazel
bzip2 # Needed by legacy GUI build

...

Info
titleJava Development Kit (JDK)

Do I need to install a JDK? The short answer is NO (smile)

Starting with ONOS 2.2 (master at the time of writing), we no longer require to install a JDK in your system to build and run ONOS. Instead, we use a version of OpenJDK 11 that comes with Bazel.

However, you might still need to install a Java Runtime Environment (JRE) or JDK if you want to run some of the development tools (e.g. onos-lib-gen, etc.). In this case, we suggest installing Amazon Corretto, a free, easy-to-install, production-grade OpenJDK build from Amazon:

https://aws.amazon.com/corretto/ 

If you plan to build and run a version of ONOS prior to 2.2, you should install JDK 8, otherwise, feel free to install the more recent JDK 11.

Get ONOS code

To get the source code and build ONOS, all you need to do it run the following commands from a Unix-like terminal (e.g. Linux, MacOS):

Code Block
languagebash
titleDownload ONOS code & Build ONOS
git clone https://gerrit.onosproject.org/onos
cd onos
bazel build onos		# or use 'op' alias after you 'source tools/dev/bash_profile'

This will compile all source code assemble and assemble the installable onos.tar.gz, which is located in the bazel-bin directory. 

...

Code Block
languagebash
titleRun ONOS
bazel run onos-local -- clean debug  # or use 'ok' alias
# 'clean' to delete all previous running status
# 'debug' to enable remote debugging


# --- The second method, only run ONOS in the background: ---
1. tar -zxvf $ONOS_ROOT/bazel-bin/onos.tar.gz (re-building ONOS if necessary) # e.g. unzip to /tmp
2. cd /tmp/onos-<your version>/apache-karaf-3.0.8/bin # e.g. onos-1.15.0-SNAPSHOT
3. ./start clean debug    # Start ONOS. 'clean' & 'debug' are optional parameters
4. ./client               # You can login ONOS CLI at any time. In CLI, type 'logout' to leave, and 'shutdown' to stop ONOS.
5. ./stop                 # Stop ONOS.

The above command will create a local installation from the onos.tar.gz file (re-building it if necessary) and will start the ONOS server in the background. In the foreground, it will display a continuous view of the ONOS (Apache Karaf) log file. Options following the double-dash (–) are passed through to the ONOS Apache Karaf and can be omitted. Here, the clean option forces a clean installation of ONOS and the debug option means that the default debug port 5005 will be available for attaching a remote Java debugger.

To attach to the ONOS CLI console, run:

...

Once connected, you can run various ONOS CLI and Apache Karaf commands. For example, to start up OpenFlow and reactive forwardingReactiveForwarding app, you could do the following:

...

Code Block
languagebash
titleOpen ONOS web page
tools/test/bin/onos-gui localhost

or alternatively, visit http://localhost:8181/onos/ui 

...

Code Block
languagebash
titleExecute ONOS unit tests
bazel query 'tests(//...)' | xargs bazel test		# or use 'ot' alias
Code Block
languagebash
titleImport ONOS into Intellij IDEA
1. File → Setting → Plugin, install the Bazel plugin. (Or download from https://plugins.jetbrains.com/plugin/8609-bazel, and install manually.)
2. restart Intellij IDEA
3. File → Import Bazel Project...
4. choose $ONOS_ROOT for Workspace
5. choose "Generate from BUILD file", and $ONOS_ROOT/BUILD
6. check and click Finish


To get access to a number of aliases (such as those mentioned above) and in general to make your development environment setup more conveniently for ONOS development, please put the following two lines in your ~/.bash_profile or ~/.bash_aliases

Code Block
languagebash
titleCustomize your Bash environment
export ONOS_ROOT=~/onos
source $ONOS_ROOT/tools/dev/bash_profile


Congratulations! The above should be enough to get you started. If you like more detailed instructions for importing the ONOS project into an IDE or contributing your changes back to the ONOS project, please consult the Development Environment Setup section.

...