pyangbind icon indicating copy to clipboard operation
pyangbind copied to clipboard

Add support for 'anyxml' element - seen in ietf-netconf.yang rpc model

Open eduardpo opened this issue 3 years ago • 4 comments

Hi,

ietf-netconf.yang --> ietf_netconf.py
Traceback (most recent call last):
  File "/local/home/eduardp/devices/siklu-tests/pyang-binder/bin/pyang", line 545, in <module>
    run()
  File "/local/home/eduardp/devices/siklu-tests/pyang-binder/bin/pyang", line 514, in run
    emit_obj.emit(ctx, modules, fd)
  File "/local/home/eduardp/devices/siklu-tests/pyang-binder/src/pyangbind/pyangbind/plugin/pybind.py", line 203, in emit
    build_pybind(ctx, modules, fd)
  File "/local/home/eduardp/devices/siklu-tests/pyang-binder/src/pyangbind/pyangbind/plugin/pybind.py", line 427, in build_pybind
    ctx, fd, rpcs, module, module, register_paths=False, path="/%s_rpc" % (safe_name(module.arg))
  File "/local/home/eduardp/devices/siklu-tests/pyang-binder/src/pyangbind/pyangbind/plugin/pybind.py", line 760, in get_children
    register_paths=register_paths,
  File "/local/home/eduardp/devices/siklu-tests/pyang-binder/src/pyangbind/pyangbind/plugin/pybind.py", line 1463, in get_element
    register_paths=register_paths,
  File "/local/home/eduardp/devices/siklu-tests/pyang-binder/src/pyangbind/pyangbind/plugin/pybind.py", line 760, in get_children
    register_paths=register_paths,
  File "/local/home/eduardp/devices/siklu-tests/pyang-binder/src/pyangbind/pyangbind/plugin/pybind.py", line 1463, in get_element
    register_paths=register_paths,
  File "/local/home/eduardp/devices/siklu-tests/pyang-binder/src/pyangbind/pyangbind/plugin/pybind.py", line 760, in get_children
    register_paths=register_paths,
  File "/local/home/eduardp/devices/siklu-tests/pyang-binder/src/pyangbind/pyangbind/plugin/pybind.py", line 1522, in get_element
    cls, elemtype = copy.deepcopy(build_elemtype(ctx, element.search_one("type")))
  File "/local/home/eduardp/devices/siklu-tests/pyang-binder/src/pyangbind/pyangbind/plugin/pybind.py", line 1205, in build_elemtype
    pattern_stmt = et.search_one("pattern") if not et.search_one("pattern") is None else False
AttributeError: 'NoneType' object has no attribute 'search_one'
Bindings failed!

Is it a normal behavior?

Thanks, Ed

eduardpo avatar Jan 20 '22 10:01 eduardpo

Hi eduardpo,

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

I looked for a fresh version of ietf-netconf.yang and found https://yangcatalog.org/yang-search/module_details/ietf-netconf

With this model, there seems to be no issues:

pyang --plugindir $PYBINDPLUGIN -f pybind -o outputs/binding.py models/[email protected]

How are you calling pyang and pyangbind from pyang-binder? An equivalent call to pyang works?

Looking forward to helping you with the issue.

JoseIgnacioTamayo avatar Aug 02 '23 20:08 JoseIgnacioTamayo

Hi eduardpo,

My bad, I missed the title of the issue, stating that you use '--build-rpc' option. Then I have the same error as you reported.

'pyang --build-rpcs' would ' Generate class bindings for the input and output of RPCs defined in each module. These are placed at the root of each module'. I have first need to understand this to track and identify the Exception you reported.

JoseIgnacioTamayo avatar Aug 02 '23 21:08 JoseIgnacioTamayo

I think the problem is that pyangbind expects the childless elements to have a 'type' defined, but 'anyxml' and 'anydata' do not have it.

Checking for the presence of 'type' before trying to build the element would fix this.

JoseIgnacioTamayo avatar Aug 02 '23 22:08 JoseIgnacioTamayo

I was reading https://www.rfc-editor.org/rfc/rfc6020.html#section-7.10, and it seems this Issue is about implementing the 'anyxml' statement.

JoseIgnacioTamayo avatar Feb 19 '24 20:02 JoseIgnacioTamayo