robshakir / pyangbind

A plugin for pyang that creates Python bindings for a YANG model.
Other
204 stars 121 forks source link

How to get a empty list objects use for query all sub-resources. #281

Closed jeffrey4l closed 1 year ago

jeffrey4l commented 3 years ago

How to get following xml output when i just wanna to query the all the static-routes resource ?

<openconfig-local-routing xmlns="http://openconfig.net/yang/local-routing">
  <local-routes>
    <static-routes>
    </static-routes>
  </local-routes>
</openconfig-local-routing>
JoseIgnacioTamayo commented 1 year ago

Hi jeffrey4,

Reproducing your issue is key to understand it and fix it.

How are you using pyangbind? An extract of your code would be helpful.

Using the OC-interfaces model, which also has a list, the following seems to work:

''' import openconfig_interfaces as oc_interfaces from pyangbind.lib import pybindJSON

ifaces = oc_interfaces().interfaces ifaces.interface.add("eth0") ifaces.interface.add("eth1") print(pybindJSON.dumps(ifaces, mode='ietf')) '''

JoseIgnacioTamayo commented 1 year ago

Closing, as there was no follow up on the issue.