Versions Compared

Key

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

Table of Contents

Introduction

In this tutorial we will show you how to generate an ONOS component 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 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:

Code Block
$ mvn archetype:generate -Dfilter=org.onosproject: -DarchetypeGroupId=org.onosproject  -DarchetypeArtifactId=onos-bundle-archetype -DarchetypeVersion=1.0.0-SNAPSHOT

 

This will ask you several specific information about the bundle you would like to generate as you can see below. Make sure to entire parameters that are appropriate for you.

 

Code Block
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
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: onos-bundle-archetype:1.0.0-SNAPSHOT
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.foo
[INFO] Parameter: artifactId, Value: foo-app
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: org.foo.app
[INFO] Parameter: packageInPathFormat, Value: org/foo/app
[INFO] Parameter: package, Value: org.foo.app
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: org.foo
[INFO] Parameter: artifactId, Value: foo-app
[INFO] project created from Archetype in dir: /private/tmp/onos-app/foo-app
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[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 loading it into ONOS.

Loading your generated component into ONOS

First start by entering the directory of your generated component and then building it.

Code Block
$ cd foo-app
$ mvn clean install

Now this has been installed in your local maven repository and it is ready to be loaded into your ONOS instance. If you need help running ONOS please refer to this page.

Code Block
onos> bundle:install mvn:org.foo/foo-app/1.0-SNAPSHOT

Now you should be able to see the bundle has been loaded,

Code Block
onos> list
...
154 | Installed |  80 | 1.0.0.SNAPSHOT | foo-app 

and it is ready to start.

Code Block
onos> start foo-app
onos> list
...
154 | Active |  80 | 1.0.0.SNAPSHOT | foo-app 

 

Finally your component is loaded and running into ONOS.

 

Happy coding!