Have questions? Stuck? Please check our FAQ for some common questions and answers.

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 27 Next »

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

First of all, you should install software dependencies, starting with Java. You can download, extract, and install Oracle Java 8 on most platforms.  

On Ubuntu/Debian, you can do the following:

Java 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:

Other dependencies
git
zip
curl
unzip # CentOS installations only
python # Version 2.7 is required

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

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

Download ONOS code & Build ONOS
git clone https://gerrit.onosproject.org/onos
cd onos
export ONOS_ROOT=$(pwd)
source $ONOS_ROOT/tools/dev/bash_profile
bazel build onos		# or use 'op' alias

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

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

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

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 debugger.

To attach to the ONOS CLI console, run:

Login into ONOS CLI
tools/test/bin/onos localhost

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

Activate applications by ONOS CLI
onos> app activate org.onosproject.openflow
onos> app activate org.onosproject.fwd

To open your default browser on the ONOS GUI page, simply type:

Open 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:

sudo mn --controller remote,ip=<ONOS IP address> --topo torus,3,3

Note that you should replace <ONOS IP address> with the IP address of your development machine where ONOS is running.


To execute ONOS unit tests, including code Checkstyle validation, run the following command:


bazel query '\''tests(//...)'\'' | xargs bazel test		# or use 'ot' alias


If you want to import the project into IntelliJ, please install the Bazel plugin and then import the project using File → Import Bazel Project... option.


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


export ONOS_ROOT=~/onos
source $ONOS_ROOT/tools/dev/bash_profile

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.

  • No labels