This is an archive of the ONOS 1.4 wiki. For the current ONOS wiki, look here.

YouTube Video

Overview

In this brief screencast, we will show you how to check-out the ONOS codebase and how to tailor your shell environment to get access to a number of shell tools, aliases and other conveniences that aim to make working with ONOS very easy. Of course, we will also show you how to build and package ONOS.

This demonstration assumes that your development environment has the required tool chain installed already.

Checking out the code

Let us start with checking out the ONOS code. You can find the instructions on how to do this on the ONOS wiki, where you can also find the git repository URL. Let’s open the browser, navigate to ONOS wiki and then search for Getting ONOS. Once there, let’s copy the git URL and paste it in our shell window. We are opting to check-out the code directly under our home directory, but you can choose an alternate location if you wish.

Modify Bash profile

Once the code has been checked out, we are ready to build it. However, before we do that, let’s modify our bash profile to import the ONOS developer bash profile. While this is not strictly required, I would highly recommend doing this, because it will augment your  environment with path configuration and with various shell aliases and shortcuts that make working with ONOS a breeze. Depending on what OS you are using for development, you should make your changes in either .bash_profile or .bash_aliases file. Since we are on OS/X, we will edit our .bash_profile file. We will first export ONOS_ROOT environment variable to point to the root of ONOS source tree and then we will source-in the ONOS developer profile.

After saving the changes, we will source-in our new profile and we are now ready to build and package ONOS.

Building ONOS via Maven

ONOS is built with Apache Maven using a hierarchical structure with the overall ONOS pom (or Project Object Model) file located at the root of the ONOS source tree. To build onos we just need to change to the ONOS_ROOT directory and type mvn clean install to build the entire ONOS. Alternatively we can use the shell tool onos-build to do this from anywhere. A shortcut alias ob has been provided for even further brevity.

Note, that you can build only sections or even just individual modules by simply warping into the appropriate location of the source tree where a pom.xml file is located and then type ‘mvn clean install’.

If you are invoking Maven for the very first time, the first build may take a bit more time, since Maven needs to download the various plugins and required artifacts from the Maven central repository. Subsequent builds should be much faster however.

Packaging ONOS tarball

Once the build has completed, we can use the onos-package shell tool to produce an installable compressed tarball, 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 tarball.

As with onos-build, onos-package also has an alias called op’. This allows the lazy typists, myself included, to simply type ob && opto get ONOS built and packaged in under 10 keystrokes.

Conclusion

Hopefully, you have found this screencast useful. Have a great day… and happy coding!


  • No labels