Page tree

Have questions? Stuck? Please check our FAQ for some common questions and answers.

Skip to end of metadata
Go to start of metadata

The information on this page is deprecated.


Create an ONOS device behaviour interface and implementation from a YANG model. These classes enables app o CLI command to talk to the device and configure it.


Code generation

  • Use yangtools package provided ( how do give the yangtools project and pom file ? )
  • specify the input yang model folder at line 55 of pom.xml



  • specify output folder at line 62 of pom.xml

    <outputBaseDir> /Users/Andrea/yangBehavior </outputBaseDir>

  • open a shell to the translator project folder
  • execute 

    $ mvn generate-sources

  • generated java files are in <outputdir>/org/opendaylight/yang/gen/v1/<yang_specified_namespace>

Code editing

  • take the interface relative to your device (in our example and import it into the onosproject module in Intellij and put it into /core/api/src/main/java/org/onosproject/net/behaviour/

  • open it and do these operations:
    • remove all the packages and the imports. Example:

      import org.opendaylight.yangtools.yang.binding.ChildOf;
      import AbstractBehaviourData;
      import org.opendaylight.yangtools.yang.common.QName;
      import org.opendaylight.yangtools.yang.binding.Augmentable; 
    • insert if not already present.



  • go to public interface <your_interface_name> extends, remove all code from ChildOf to { and add HandlerBehaviour after the keyword extends


    public interface ControllerConfig
        Augmentable<> {


    public interface ControllerConfig
        extends HandlerBehaviour {
  • remove 

    public static final QName QNAME = org.opendaylight…

  • in case some of the method’s return type are different from what you need modify them.
  • put Javadoc on your interface.

You class should now look something like this:

* <...javadoc here..>
public interface <your_interface_name> extends HandlerBehaviour {

<...methods here…>


The interface we just built should be the only class from the generated ones that you need, but if there is something more, take it from the generated classes folder and put it (where ?)

Interface implementation

After the creation of the interface you have to implement the methods to operate on the device.

In order to do this you must create a class in <onos_base_directory>/drivers/src/main/java/org/onosproject/driver/netconf/ 

with this declaration:

public class <your_class_name> extends AbstractHandlerBehaviour
      implements <your_interface_name> {

Now let IntelliJ autogenerate the body of the interface’s methods for you and then put your code in it.


For an example of the whole infrastructure you can take a look at the ControllerConfig.Java class and it’s implementation in

Driver activation

In order to have your device recognized by ONOS you need to put the behavior and it's implementation in a <driver></driver> tag in <onos_home_directory>/drivers/src/main/resources/onos-drivers.xml.


<driver name="ovs-netconf"
        manufacturer="Nicira, Inc\." hwVersion="Open vSwitch" swVersion="2\..*">
    <behaviour api=""

See Also

NETCONF : wiki page on how to use the present NETCONF infrastructure to talk to the device

  • No labels