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

 

 

Overview

If you have come across Installing and Running ONOS, you'll notice that there are several ways to install and run ONOS. This tutorial takes the aforementioned page, and focuses on showing you one useful deployment method - ONOS packaged from source, and deployed in an Ubuntu VM or on OS X.

By completing this tutorial, you will understand how to:

  • Use cell definitions to configure the ONOS build environment to customize the ONOS package
  • Configure which modules the ONOS binary loads by default
  • Install ONOS on a VM using the onos-install utility
  • Access the CLI and monitor ONOS remotely

Conventions

Commands at the shell of the VM begin with $:

$ sudo -s
#

And commands at the build machine shell begin with build:~$:

build:~$ sudo -s
build:~#

Prerequisites

You need a build machine for packaging ONOS and for running your VM. The build machine should be running a UNIX-like OS. This tutorial assumes that your build machine is running Ubuntu 14.04, 64-bit.

You should have some kind of VM hosting software, such as VirtualBox, installed on your build machine. This tutorial assumes you are using VirtualBox.

Finally, you should generate a SSH public key on your build machine if you hadn't done so in the past:

build:~$ ssh-keygen -t rsa

The default options and no password are fine for this tutorial.

1. Prepare the VM.

Download Ubuntu Server 14.04 LTS 64-bit. Create a VM using this image, with the following settings:

  • 2GB RAM
  • 2 processors
  • At least 5GB disk space
  • Two network interfaces, Adapter 1 attached to NAT, and Adapter 2 attached to host-only Adapter set to vboxnet0. Configure both to use DHCP.

During the Ubuntu installation:

  • create a user named sdn, with password rocks, and confirm that you want to use this password. This will be the primary account used for this tutorial.
  • when prompted to encrypt the disk, select No
  • For partitioning the disk, select Guided - use entire disk and follow with the defaults provided.
  • For configuring proxy information, follow what best suits your environment.
  • when prompted to install additional software (Software Install) choose OpenSSH server.

This tutorial calls the VM onos-scratch.

Once the VM starts up:

Log into your new VM as sdn and give the user passwordless sudo privileges. Run sudo visudo, and add the following line to the end of the file:

sdn ALL=(ALL) NOPASSWD:ALL

Then, update the package repository:

$ sudo apt-get update

You should also be able to verify that it has two network interfaces, eth0 and eth1:

$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:15:7e:e1  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe15:7ee1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:35 errors:0 dropped:0 overruns:0 frame:0
          TX packets:43 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:3535 (3.5 KB)  TX bytes:3749 (3.7 KB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:b7:18:47  
          inet addr:192.168.56.101  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:feb7:1847/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:157 errors:0 dropped:0 overruns:0 frame:0
          TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:19323 (19.3 KB)  TX bytes:7379 (7.3 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

From the build machine you should be able to SSH to the VM using the IP address assigned to eth1:

build:~$ ssh -l sdn 192.168.56.101

If the ssh connection failed make sure that the openssh-server is installed by running:

$ sudo apt-get install openssh-server

2. Install required software

On the Build machine

Install Git:

build:~$ sudo apt-get install git-core

Create two directories called ~/Downloads and ~/Applications. Download the Karaf 3.0.3 and Maven 3.3.1 binaries (the tar.gz versions of both) into ~/Downloads and extract it to ~/Applications. Keep the tar archives in ~/Downloads; we'll need that later.

build:~$ cd; mkdir Downloads Applications
build:~$ cd Downloads
build:~$ wget http://archive.apache.org/dist/karaf/3.0.3/apache-karaf-3.0.3.tar.gz
build:~$ wget http://archive.apache.org/dist/maven/maven-3/3.3.1/binaries/apache-maven-3.3.1-bin.tar.gz
build:~$ tar -zxvf apache-karaf-3.0.3.tar.gz -C ../Applications/
build:~$ tar -zxvf apache-maven-3.3.1-bin.tar.gz -C ../Applications/ 

Next, install Oracle Java 8:

build:~$ sudo apt-get install software-properties-common -y
build:~$ sudo add-apt-repository ppa:webupd8team/java -y
build:~$ sudo apt-get update
build:~$ sudo apt-get install oracle-java8-installer oracle-java8-set-default -y
It will ask you to acknowledge the license; do so when prompted.

The second step above may prompt for the installation of python-software-properties. If prompted, do so. 

Finally, clone the ONOS source to the build machine's home directory:

build:~$ git clone https://gerrit.onosproject.org/onos

This will create a directory called onos, with the source code in it.

On the Ubuntu VM

The VM only requires Java 8 - follow the instructions for Java 8 above.

3. Set up your build environment

Environment variables

First off, you will need to export several environment variables. The ONOS source comes with a sample bash_profile that can set these variables for you. 

This file can be sourced from the interactive portion of .bashrc, or .bash_aliases (or .profile if /bin/sh is bash) of user sdn, by adding the following line to it at the end:

. ~/onos/tools/dev/bash_profile

Warning: technically any bash-specific code should not go in .profile. If you have a Debian-based system (e.g. Raspbian) where .profile may be executed by a shell that is not bash (e.g. /bin/sh is dash or some other POSIX-like shell), make sure you put the above line in .bash_aliases or the interactive portion of .bashrc rather than .profile to avoid problems (such as startx not working on Raspbian.)

Once the line is added, source the user's .profile (or just log out and log back in):

build:~$ . ~/.profile

Once you run the above command, you will see in the output of env that several new variables, such as ONOS_ROOT, OCI, and KARAF_ROOT, have been set.

Use different user name or group

Make sure you also setup ONOS_USER If you used a user name other than "sdn" during the Ubuntu installation. You can also customize the ONOS_GROUP (typically, the user name and group name will be identical.)

$ export ONOS_USER=<username>
$ export ONOS_GROUP=<groupname>

Build ONOS

Edit ~/Applications/apache-karaf-3.0.3/etc/org.apache.karaf.features.cfg by appending the following line to  featuresRepositories:

mvn:org.onosproject/onos-features/1.2.0-SNAPSHOT/xml/features

Now we are ready to build ONOS with Maven:

build:~$ cd ~/onos
build:~$ mvn clean install  # or use the alias 'mci'

Now we are ready to start customizing, creating, and installing ONOS packages.

If previous version of ONOS is running, the service should be stopped (sudo service onos stop) before building with mvn. Otherwise, the test on onlab.nio package would fail with "address already in use" error.

4. Create a custom cell definition

A quick intro to cells

Under ONOS terminology, a cell is a collection of environment variables that are used:

  • by the utility scripts included with ONOS, including the ones that we are about to talk about
  • for telling the packaging process how we want to customize our ONOS package

Cells make it easy to use the utility scripts to package, configure, install, and run ONOS.

Here we will create an ONOS package that, when installed and launched, starts up a single-instance (non-clustering) ONOS instance that uses the intent-based forwarding application.

Create a cell definition file

A cell is defined in a cell definition file. We will create the following cell definition file called tutorial in ${ONOS_ROOT}/tools/test/cells/ :

# ONOS from Scratch tutorial cell

# the address of the VM to install the package onto
export OC1="192.168.56.101"

# the default address used by ONOS utilities when none are supplied
export OCI="192.168.56.101"

# the ONOS apps to load at startup
export ONOS_APPS="drivers,openflow,fwd,proxyarp,mobility"

# the Mininet VM (if you have one)
export OCN="192.168.56.102"
 
# pattern to specify which address to use for inter-ONOS node communication (not used with single-instance core)
export ONOS_NIC="192.168.56.*"

Note that:

  • OC1 and OCI are set to the address of eth1 in our VM
  • ONOS_APPS indicates the ONOS applications we want to activate, including OpenFlow protocol, reactive forwarding (fwd), proxy ARP, and mobility.

 

Applying a cell

This cell can be applied to your build environment with the cell command:

build:~$ cell tutorial

Now any ONOS package you will build will take up the ONOS_APPS setting. Additionally, if you need to create packages with other configurations (i.e. different applications or install targets), all you need to do is to apply a different cell definition to your environment before package creation and deployment. 

You can also use the vicell utility to create and edit your cell file. For example, to create a new cell file:

$ vicell -c -a mycell

the above command opens a new file named "mycell" in ${ONOS_ROOT}/tools/test/cells/ either in the editor specified by the EDITOR env variable, or vi otherwise. When you exit out of the editor, the cell is automatically created and then applied to your session.

See vicell -h for the list of options.

5. Package and deploy ONOS

Passwordless VM access

For convenience, before we can deploy anything to our VM, we will configure paswordless login to the VM from our build machine with onos-push-keys:

build:~$ onos-push-keys 192.168.56.101
sdn@192.168.56.101's password:

Older versions of the utility will ask you to authenticate multiple times; newer versions will require you to enter the password just once.

This tutorial deals with only 1 VM, but if you want to create a cluster of ONOS, cloning the 1st VM, onos-patch-vm script can be used to set the hostname, etc. to the cloned VM.

build:~$ onos-patch-vm $OC2 onos-scratch2
192.168.56.102: onos-scratch2

Creating the package

To create a ONOS binary, run onos-package (or op, for short):

build:~$ onos-package
-rw-rw-r--  1 onosuser  onosuser  33395409 Dec  4 16:12 /tmp/onos-1.2.0.onosuser.tar.gz

This creates a tar archive in /tmp .

Deploying the package

We can now deploy it to our VM:

build:~$ onos-install -f $OC1
onos start/running, process 2028

Once onos-install returns with the last message in the code block above, we can try logging on from our build machine: 

build:~$ onos $OC1
Logging in as karaf
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>

We are now actually logged into the ONOS CLI of the instance that we have deployed on the VM.

Use apps to list all installed applications. The one with asterisk sign indicates that it is activated (running).

onos> apps
  id=1, name=org.onosproject.bgprouter, version=1.2.0 ...
  id=2, name=org.onosproject.config, version=1.2.0 ...
  id=3, name=org.onosproject.demo, version=1.2.0 ...
* id=4, name=org.onosproject.drivers, version=1.2.0 ...
  id=5, name=org.onosproject.election, version=1.2.0 ...
* id=6, name=org.onosproject.fwd, version=1.2.0 ...
  id=7, name=org.onosproject.intentperf, version=1.2.0 ...
  id=8, name=org.onosproject.metrics, version=1.2.0 ...
* id=9, name=org.onosproject.mobility, version=1.2.0 ...
  id=10, name=org.onosproject.null, version=1.2.0 ...
* id=11, name=org.onosproject.openflow, version=1.2.0 ...
  id=12, name=org.onosproject.optical, version=1.2.0 ...
* id=13, name=org.onosproject.proxyarp, version=1.2.0 ...
  id=14, name=org.onosproject.routing, version=1.2.0 ...
  id=15, name=org.onosproject.sdnip, version=1.2.0 ...
  id=16, name=org.onosproject.segmentrouting, version=1.2.0 ...
onos>

Note that there will be many more modules than you have configured - these are part of the ONOS OpenFlow and core components. Refer to Appendix C : Source Tree Organization to see descriptions of the modules.

You can log out (detach) from the CLI with logout, or Ctrl-D.

The argument $OC1 can be replaced with $OCI, or even omitted; when omitted, the scripts will fall back to using the value stored in OCI.

Deploy on Mac OS X

On Ubuntu, onos-install uses the upstart/initctl system to start and stop onos semi-automatically.

OS X manages daemons using launchd/launchctl, which onos-install doesn't currently support, so we need to specify "nostart" (-n):

onos-install -fn $OC1 

and start ONOS manually using 

/opt/onos/apache-karaf-$KARAF_VERSION/bin/karaf clean

What's next?


Return To : Tutorials and Walkthroughs