This tutorial is in progress, and it does not function on the current vm.
Welcome to the Distributed ONOS Tutorial.
In this tutorial you will learn to write a distributed ONOS application. The application you will be writing is called BYON (Bring Your Own Network). This tutorial will teach you how to implement an ONOS service, an ONOS store (both trivial and distributed) and how to use parts of the CLI and Northbound API. First, you will start with a single instance implementation which will be fully functional. After this, you will implement a distributed implementation of the service. The idea here will be for you to see how simple transitioning from a trivial single instance implementation to a distributed implementation. Believe it of not, most of your code does not change.
Introduction
Pre-requisites
You will need a computer with at least 2GB of RAM and at least 5GB of free hard disk space. A faster processor or solid-state drive will speed up the virtual machine boot time, and a larger screen will help to manage multiple terminal windows.
The computer can run Windows, Mac OS X, or Linux – all work fine with VirtualBox, the only software requirement.
To install VirtualBox, you will need administrative access to the machine.
The tutorial instructions require prior knowledge of SDN in general, and OpenFlow and Mininet in particular. So please first complete the OpenFlow tutorial and the Mininet walkthrough. Also being familiar with Apache Karaf would be helpful although not entirely required.
Stuck? Found a bug? Questions?
Email us if you’re stuck, think you’ve found a bug, or just want to send some feedback. Please have a look at the guidelines to learn how to efficiently submit a bug report.
Setup your environment
Install required software
You will need to acquire two files: a VirtualBox installer and the Tutorial VM.
After you have downloaded VirtualBox, install it, then go to the next section to verify that the VM is working on your system.
Create Virtual Machine
Double-click on the downloaded tutorial zipfile. This will give you an OVF file. Open the OVF file, this will open virtual box with an import dialog. Make sure you provision your VM with 4GB of RAM and if possible 4 CPUs if possible, if not 2 CPUs should be ok.
Click on import. When the import is finished start the VM and login using:
USERNAME: distributed
PASSWORD: distributed
Important Command Prompt Notes
In this tutorial, commands are shown along with a command prompt to indicate the subsystem for which they are intended.
For example,
onos>
indicates that you are in the ONOS command line, whereas
mininet>
indicates that you are in mininet.
Startup multiple docker instances
We will be using docker to spawn multiple ONOS instances. So before we dive into the code, let's provision some docker instances that will run ONOS. First, you should see that there is already an ONOS distributed tutorial images present on your system:
distributed@mininet-vm:~/onos$ sudo docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE onos/tutorial-dist latest 666b3c862984 13 hours ago 666.1 MB ubuntu-upstart 14.10 e2b2af39309a 7 days ago 264.2 MB
At this point you are ready to spawn your ONOS instances. To do this we will spawn three docker instances that will be detached and running in the background.
distributed@mininet-vm:~/onos$ sudo docker run -t -P -i -d --name onos-1 onos/tutorial-dist <docker-instance-id> distributed@mininet-vm:~/onos$ sudo docker run -t -P -i -d --name onos-2 onos/tutorial-dist <docker-instance-id> distributed@mininet-vm:~/onos$ sudo docker run -t -P -i -d --name onos-3 onos/tutorial-dist <docker-instance-id>
If you go the following error message:
distributed@mininet-vm:~$ sudo docker run -t -P -i -d --name onos-1 onos/tutorial-dist 2014/12/11 10:55:53 Error response from daemon: Conflict, The name onos-1 is already assigned to 26d8c84f8a50. You have to delete (or rename) that container to be able to assign onos-1 to a container again. distributed@mininet-vm:~$
which should only happen if you have already build your docker instance then you only need to start it:
distributed@mininet-vm:~$ sudo docker start onos-1
Now you should have three docker instances up and running
distributed@mininet-vm:~$ sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES fc08370eb3d0 onos/tutorial-dist:latest "/sbin/init" About a minute ago Up About a minute 0.0.0.0:49168->22/tcp, 0.0.0.0:49169->6633/tcp, 0.0.0.0:49170->8181/tcp onos-3 bc725b09deed onos/tutorial-dist:latest "/sbin/init" About a minute ago Up About a minute 0.0.0.0:49165->22/tcp, 0.0.0.0:49166->6633/tcp, 0.0.0.0:49167->8181/tcp onos-2 26d8c84f8a50 onos/tutorial-dist:latest "/sbin/init" About a minute ago Up About a minute 0.0.0.0:49162->22/tcp, 0.0.0.0:49163->6633/tcp, 0.0.0.0:49164->8181/tcp onos-1 distributed@mininet-vm:~$
Ok now that we have all our docker instances up and running we simply need to set them up with ONOS. To do this we will use the standard ONOS toolset which would be the same set of commands if you were to deploy ONOS on a VM or bare metal machine.
Setting up ONOS in spawned docker instances (also known as docking the docker )
First, let's start by making sure our environment is correctly setup.
distributed@mininet-vm:~$ cell docker ONOS_CELL=docker OCI=172.17.0.2 OC1=172.17.0.2 OC2=172.17.0.3 OC3=172.17.0.4 OCN=localhost ONOS_FEATURES=webconsole,onos-api,onos-core,onos-cli,onos-rest,onos-gui,onos-openflow,onos-app-fwd,onos-app-proxyarp,onos-app-mobility ONOS_USER=root ONOS_NIC=172.17.0.*