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

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

  • 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 63 of pom.xml

  • 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>

  • take the interface relative to your device (in our example ControllerConfig.java) 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

 

package org.opendaylight.yang.gen.v1.org.onosproget.driver.test.rev691231;
import org.opendaylight.yangtools.yang.binding.ChildOf;
import org.opendaylight.yang.gen.v1.org.onosproget.driver.test.rev691231. AbstractBehaviourData;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.binding.Augmentable; 

- insert if not already present:

package org.onosproject.net.behaviour; 
import org.onosproject.net.driver.HandlerBehaviour;


 

  • go to public interface <your_interface_name> extends and remove all code from ChildOf to {

  • add HandlerBehaviour after the keyword extends

  • 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:


package org.onosproject.net.behaviour;

import org.onosproject.net.driver.HandlerBehaviour;

/**

* <...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 ?)


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 NetconfControllerConfig.java


  • No labels