Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
eduardpo opened this issue Jan 20, 2022 · 4 comments
Open

Comments

@eduardpo
Copy link

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

@JoseIgnacioTamayo
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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 JoseIgnacioTamayo self-assigned this Aug 7, 2023
@JoseIgnacioTamayo JoseIgnacioTamayo removed their assignment Feb 19, 2024
@JoseIgnacioTamayo JoseIgnacioTamayo changed the title bindings generation for "ietf-netconf.yang" with --build-rpcs option causes an exeption Add support for 'anyxml' element - seen in ietf-netconf.yang rpc model Feb 19, 2024
@JoseIgnacioTamayo
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants