Programming with Opendaylight

In this blog, I will cover internals of programming with Opendaylight.

Opendaylight is mainly written in Java. OSGI framework is used that allows for bundles to be dynamically loaded and unloaded.

Following are the different layers of software from the lowest layer

  • Plugins – Like openflow, ovsdb.
  • SAL layer – Abstracts core modules from plugins
  • Core modules – like Topology manager, switchmanager, hosttracker, statistics manager etc.
  • Northbound interfaces – These expose REST api for applications to hook on.
  • Web front-end uses Spring MVC framework and java script.

Programming Language choice:

  • Developing core modules would mean coding in Java.
  • For Opendaylight Web interface, need to have Spring MVC and Java script knowledge.
  • For writing SDN applications on top of the controller, either Python or Java can be used. Python can use the REST apis to talk to the controller. With Java, the application can be written as OSGI bundle. Writing application in Java has the advantage of asynchronous event handling and packet handling mechanisms which Python cannot provide.
  • For me, both Python and Java were new. I have done some Java programming many years back. I still found programming in Python a lot easier than Java because its very easy to try out new things and see the results immediately.


Similar to Makefile. Specifies modules that are part of a bundle and also specifies inter-bundle dependencies.
There is a pom.xml at 3 levels.

  • pom.xml at base controller directory specifies which modules are part of the controller.
  • pom.xml at distribution/opendaylight directory that specifies modules that are part of the distribution.
  • pom.xml at individual module level specifies packages that are to be imported as well as inter-module dependencies.

Following is relevant section from arphandler pom.xml.




ArtifactId is arphandler module and it has a version associated with it.
<import-package> specifies modules that are to be imported some of which are part of opendaylight and some of which are external dependencies. For example, switchmanager is an internal dependency and slf4j is external dependency.

Maven is used for build automation and it relies on pom.xml. Maven automatically downloads the latest jar files when the build is triggered. Jar files gets stored in <home>/.m2

Common maven commands:

mvn compile - to compile individual modules
mvn install - copy jar files to target
mvn clean
mvn package - creates package
mvn clean install -DskipTests - To skip tests(Tests are automatically built as part of each module)

Update dependencies:
mvn clean install -U (or)
rm -rf .m2 (in home directory)

Build specific module:
mvn clean install -DskipTests -pl :<module> -amd

Common OSGI commands:

pns - print nodes
ss - lists bundles
start - start bundle
stop - stop bundle
getLogLevel <bundle>
setLogLevel org.opendaylight.controller.helloworld DEBUG (sets level to DEBUG for helloworld module)
dm - dependencies for a module

Logs are stored in:
Logs also show up in OSGI console

Git reference:
Git is the source code control system used in Opendaylight.

Get new repository:
using username:
git clone ssh://<username>
git clone

In case changes are made to repository and we need to update workspace:
git stash
git pull
git stash pop

Apply specific patch:
git pull <patch>


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s