Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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.

Publish the artifacts to local repository

ONOS project started using BUCK from 1.7.0 hummingbird release. If you want to build ONOS application with maven archetype, you should publish the artifacts to local repository in ~/.m2:

Code Block
languagetext
onos-buck-publish-local

Generate your ONOS application project

...

Code Block
onos-create-app

 


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.

 


Code Block
languagetext
Define value for property 'groupId': : org.foo     
Define value for property 'artifactId': : foo-app
Define value for property 'version':  1.0-SNAPSHOT: : 
Define value for property 'package':  org.foo: : org.foo.app
Confirm properties configuration:
groupId: org.foo
artifactId: foo-app
version: 1.0-SNAPSHOT
package: org.foo.app
 Y: : 

...


After this you should see the following output:

...

Code Block
titleRebuild and reinstall the app
mvn clean install
onos-app localhost reinstall org.foo.app target/foo-app-1.0-SNAPSHOT.oar

 


Using the ONOS command line, restart the application (or use reinstall! in the command above):

Code Block
onos> app activate org.foo.app

 


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

Code Block
onos> sample
Hello World

 


You can use the CLI overlay to add your own commands to the CLI for your app.  Edit the file src/main/java/org/foo/app/AppCommand.java to see how the sample command is implemented and the file src/main/resources/OSGI-INF/blueprint/shell-config.xml to see how new commands are integrated into the existing CLI.

...

Code Block
languagetext
titleCreating a REST interface
onos-create-app rest org.foo.app 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:

...

ONOS can automatically generate SwaggerUI documentation for the URIs exposed in your RESTful application. After activating the application, you can visit the SwaggerUI at http://localhost:8181/v1/docs/ . You need to select Sample app REST API to test the URIs of your application.

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.

Publish the artifacts to local repository

If you wish to build an application against the current ONOS master, i.e. an unreleased version, you will need to first build ONOS yourself and then publish the resulting artifacts in the Maven repository under ~/.m2/repository by running the following command:


Code Block
languagetext
onos-publish -l		# publish libraries only (faster)

Happy coding 

Learn more about the Application Subsystem.

Here is a post on Sample PortStatistics Application tutorial based on template application tutorial .

 

 



...

Return To : Tutorials and Walkthroughs

...

...