robshakir / pyangbind

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

Can not be directly used in ncclient? #326

Closed Dulin0411 closed 6 months ago

Dulin0411 commented 8 months ago

Hi,

I found the xml created by pyangbind can not uesd in ncclient directly. The xml pyangbing created is as follow `

Twe1/0/1 false

`

The xml ncclient can edit-config directly is as follow `

Twe1/0/1 false

`

The code I used is as follow, if I used in wrong way?

from pyangbind.lib.serialise import pybindIETFXMLEncoder from ietf_interfaces import ietf_interfaces configs = ietf_interfaces() ret = configs.interfaces.interface.add('Twe1/0/1') ret.enabled = 'false' config = str(pybindIETFXMLEncoder.serialise(configs)) print(config)

JoseIgnacioTamayo commented 6 months ago

Hi,

Have you tried with config = str(pybindIETFXMLEncoder.serialise(configs.interfaces))

My idea is to tell pyangbind to generate the output starting at the element.

Dulin0411 commented 6 months ago

Thanks for your suggestion,It‘s worked.