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 Bazelisk and other dependencies

First of all, you should install

...

Bazelisk (a wrapper for Bazel), both open-source build tools developed by Google. We will use Bazel to build and run ONOS. We suggest downloading and installing Bazelisk using the instructions at Installing required tools.


On Ubuntu/Debian, you can do the following:

Code Block
languagebash
titleJava dependency
sudo apt-get install software-properties-common -y && \
sudo add-apt-repository ppa:webupd8team/java -y && \
sudo apt-get update && \
echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-set-selections && \
sudo apt-get install oracle-java8-installer oracle-java8-set-default -y

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 # 2.7 required by some development scripts
python3 # CentOSRequired installationsby onlyBazel
pythonbzip2 # Needed Versionby 2.7legacy is required

ONOS is built with Buck, an open-source build tool created by Facebook and inspired by Google. It is also in use by number of well-known projects, including all Facebook’s mobile apps, Gerrit, etc. By relying on explicit dependencies between targets and SHA hashes of files (rather than on timestamps), Buck avoids unnecessary work by recognizing whether or not a target artifact requires a rebuild. This also helps to increase reproducibility of builds.

...

ONOS currently uses a modified version of Buck, which has been packaged with ONOS. Please use this version until our changes have been upstreamed and released as part of an official Buck release. 

...

titleRedHat installations
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, we no longer require to install a JDK in your system to build and run ONOS when using Bazel, as we use a version of OpenJDK 11 that is shipped 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.) or if you want to run ONOS without using Bazel. 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

Building with buck makes use of "shasum" for signatures. CentOS systems do not provide this command; but rather those for the direct algorithms. Just symlink the default algorithm (sha1sum) to the expected command:

...

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
export ONOS_ROOT=$(pwd)
source $ONOS_ROOT/tools/dev/bash_profile
tools/build/onos-buckbazel build onos --show-output

This will compile all source code assemble and assemble the installable onos.tar.gz, which is located in the buckbazel-out bin directory. Note the --show-output option, which can be omitted, will display the path to this file.

To run ONOS locally on the development machine, simply run the following command:

Code Block
languagebash
titleRun ONOS
tools/build/onos-buckbazel run onos-local -- clean debug  
# 'clean' to delete all previous running status;
# 'debug' to enable Remoteremote Debug functiondebugging

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 

To start up a Mininet network controlled by an ONOS instance that is already running on your development machine, you can use a command like:

Code Block
languagebash
titleRun mininet controlled by ONOS
sudo mn --controller remote,ip=<ONOS IP address> --topo torus,3,3

...

Code Block
languagebash
titleRun Execute ONOS unit tests for ONOS
tools/build/onos-buck test
bazel query 'tests(//...)' | xargs bazel test		# or use 'ot' alias


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_aliasesIf you want to import the project into IntelliJ, you can generate the hierarchical module structure via the following command:

Code Block
languagebash
titleCustomize your Bash environment
export ONOS_ROOT=~/onos
source $ONOS_ROOT/tools/build/onos-buck project

Then simply open the onos directory from IntelliJ IDEA.

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.

Building ONOS behind a web proxy

Bazel supports building behind a web proxy. Here are the steps to build with a proxy:

Code Block
languagebash
titleSteps to build ONOS with a web proxy
export HTTPS_PROXY=https://<proxy address>:<proxy port>
export HTTP_PROXY=http://<proxy address>:<proxy port>


bazel build onos --action_env=HTTP_PROXY=$HTTP_PROXY