In this tutorial we will show you how to generate an ONOS bundle template. This makes it easy for you to add either an ONOS service or application. We will be using maven archetypes to generate our template, therefore this link could be handy if you would like to know more about this process.

Generate your ONOS application project

Let's now generate an ONOS project which will be fully compilable and ready to be deployed. Although, you will still have to code up your application, we haven't yet figured out how to generate code that does exactly what you would like it to do (wink). So let's start by running the following:

mvn archetype:generate -DarchetypeGroupId=org.onosproject -DarchetypeArtifactId=onos-bundle-archetype

Alternatively, if you have the ONOS code checked out and available, you can use the onos-create-app tool to accomplish the same thing:



You will now be asked for several pieces of specific information about the bundle you would like to generate as you can see below. Make sure to enter parameters that are appropriate for you.


Define value for property 'groupId': :     
Define value for property 'artifactId': : foo-app
Define value for property 'version':  1.0-SNAPSHOT: : 
Define value for property 'package': :
Confirm properties configuration:
artifactId: foo-app
version: 1.0-SNAPSHOT
 Y: : 


After this you should see the following output:

[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: onos-bundle-archetype:1.2.0-SNAPSHOT
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value:
[INFO] Parameter: artifactId, Value: foo-app
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value:
[INFO] Parameter: packageInPathFormat, Value: org/foo/app
[INFO] Parameter: package, Value:
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value:
[INFO] Parameter: artifactId, Value: foo-app
[INFO] project created from Archetype in dir: /private/tmp/onos-app/foo-app
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:54 min
[INFO] Finished at: 2014-12-03T18:00:55-08:00
[INFO] Final Memory: 14M/245M
[INFO] ------------------------------------------------------------------------

This has now generated a new project for you. Let's move on to building it and loading it into ONOS.

Loading your generated component into ONOS

If you want to designated the newly created project as an ONOS application, rather than just an OSGi bundle, enter the directory of your generated component and edit the pom.xml file within.

$ cd foo-app
$ vi pom.xml

Uncomment the and properties as shown in the following snippet.

        <>Foo, Inc.</>

This will instruct the onos-maven-plugin to package the bundle as an ONOS application by producing an .oar (ONOS Application aRchive). After saving the changes, build the project as follows:

$ mvn clean install

When the build is complete, both the OSGi bundle and the application archive have been installed in your local maven repository. To install the application into running ONOS instance (or cluster), you can use the onos-app tool, which uses ONOS REST API within, to upload the .oar file as shown in the following example. If you need help running ONOS please refer to this page.

$ onos-app localhost install target/foo-app-1.0-SNAPSHOT.oar

Now, from the ONOS console, you should be able to see the application has been installed,

onos> apps -s
   29                      1.0.SNAPSHOT ONOS OSGi bundle archetype

and it is ready to be activated.

onos> app activate
onos> apps -s
*  29                      1.0.SNAPSHOT ONOS OSGi bundle archetype 


ONOS applications can hook into the ONOS CLI and GUI. When generating your application, you can use overlays to generate the classes needed to give your application access to these services.

Command Line Overlay

To allow your application to add commands to the ONOS CLI, overlay the CLI interface like this:

onos-create-app cli foo-app 1.0.0

Now, as before, we need to build and install our application.  Since we installed it once already, we will use the reinstall command to deploy it:

mvn clean install
onos-app localhost reinstall target/foo-app-1.0-SNAPSHOT.oar


Using the ONOS command line, restart the application:

onos> app activate


Using the ONOS command line, we now have access to the 'sample' command, which was defined by our overlay:

onos> sample
Hello World


User Interface Overlays

To allow your application to add to the ONOS web UI, overlay the UI interface like this:

onos-create-app ui foo-app 1.0.0

Happy coding 

Finally your application is loaded and running withing ONOS. Also, the generation process has generated an entire project which can be loaded into your favourite JAVA editor.



Return To : Tutorials and Walkthroughs