use pojos generated from yang to configure device

2019-07-25 05:38发布

I managed to generate Pojos from yang files, using OpenDayLight YangTools.

Next stage i managed to import netconf client to my application (using gradle), how do i use the generated pojos with netconfClient in my application to configure a device?

1条回答
Deceive 欺骗
2楼-- · 2019-07-25 05:45

Would be good if you explain what you want to achieve so I can help you more accurately, but if you want to configure your box programmatically using yang, you need to follow the steps below:

  1. From yang models generate your runtime configuration classes (this is what you have now)
  2. Write some logic to call those generated classes and create an object which defines your configuration. For instance, setting up a BGP config, you need to start from the router, bgp, address family, neighbour, and so on. The object will follow your device Yang model, or the 'openconfig' one like here: https://github.com/openconfig/public/blob/master/release/models/bgp/openconfig-bgp.yang
  3. After you have generated your 'configuration instance', then you need to serialise it (convert to XML)
  4. Use a netconf client (look for ncclient) to send it to the box.

If you are not much fussed about the language, I would suggest you use

https://github.com/CiscoDevNet/ydk-py

which has examples already.

A more Opendaylighty approach is,

  1. Start a maven project and yangtools in it, https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL:Startup_Project_Archetype#Starting_your_.27example.27_project_for_the_first_time
  2. Load netconf southbound application
  3. Add your yang models you want (optional)
  4. Do a maven build so it generates the API for you (you will have access to the device API directly).
  5. Then what extra you can do is to implement the logic where the provider classes are and provide your own API.

Hope this helps

查看更多
登录 后发表回答