mbj4668 / pyang

An extensible YANG validator and converter in python
ISC License
530 stars 343 forks source link

Empty RPC XML Serialisation will not work #783

Closed eduardpo closed 2 years ago

eduardpo commented 2 years ago

Empty RPC is legal AFAIK, input/output are optional...

print(pybindIETFXMLEncoder.serialise(system_reset))

Exception:

Exception has occurred: AttributeError
'yc_reset_radio_bridge_tg_system__radio_bridge_tg_s' object has no attribute '_yang_name'
  File "/local/home/eduardp/siklu_pyang/tg_yang_models/src/pyangbind/pyangbind/lib/serialise.py", line 375, in encode
    return cls.generate_xml_tree(obj._yang_name, obj._yang_namespace, preprocessed)
  File "/local/home/eduardp/siklu_pyang/tg_yang_models/src/pyangbind/pyangbind/lib/serialise.py", line 380, in serialise
    doc = cls.encode(obj, filter=filter)
  File "/home/eduardp/siklu_pyang/pygen/test_system.py", line 37, in <module>
    print(pybindIETFXMLEncoder.serialise(system_reset))

Yang RPC:

rpc reset {
    description
        "RPC for rebooting the unit";
}

Corresponding python binding class:

class yc_reset_radio_bridge_tg_system__radio_bridge_tg_system_rpc_reset(PybindBase):
    """
    This class was auto-generated by the PythonClass plugin for PYANG
    from YANG module radio-bridge-tg-system - based on the path /radio_bridge_tg_system_rpc/reset. Each member element of
    the container is represented as a class variable - with a specific
    YANG type.

    YANG Description: RPC for rebooting the unit
    """
    _pyangbind_elements = {}

Command being used to generate bindings:

pyang --plugindir "$PYBINDPLUGIN" -f pybind --build-rpcs -o ../pygen/gen/system.py radio-bridge-tg-system.yang

Please advise, Ed

mbj4668 commented 2 years ago

This seems to be an issue in pyangbind, which is not part of pyang.

eduardpo commented 2 years ago

sorry opened by mistake here :-) my bad