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

Data tree example is not working #65

Open
tias77 opened this issue Jun 9, 2023 · 0 comments
Open

Data tree example is not working #65

tias77 opened this issue Jun 9, 2023 · 0 comments

Comments

@tias77
Copy link

tias77 commented Jun 9, 2023

cffi==1.15.1
libyang==2.7.1
pycparser==2.21

Python 3.10.12 (main, Jun  7 2023, 20:12:10) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import libyang
>>> ctx = libyang.Context()
>>> module = ctx.parse_module_str('''
... module example {
...   namespace "urn:example";
...   prefix "ex";
...   container data {
...     list interface {
...       key name;
...       leaf name {
...         type string;
...       }
...       leaf address {
...         type string;
...       }
...     }
...     leaf hostname {
...       type string;
...     }
...   }
... }
... ''')
>>> print(module.print_mem('tree'))
module: example
  +--rw data
     +--rw interface* [name]
     |  +--rw name       string
     |  +--rw address?   string
     +--rw hostname?   string

>>> node = module.parse_data_dict({
...     'data': {
...         'hostname': 'foobar',
...         'interface': [
...             {'name': 'eth0', 'address': '1.2.3.4/24'},
...             {'name': 'lo', 'address': '127.0.0.1'},
...         ],
...     },
... })
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.10/site-packages/libyang/schema.py", line 215, in parse_data_dict
    return dict_to_dnode(
  File "/usr/local/lib/python3.10/site-packages/libyang/data.py", line 1277, in dict_to_dnode
    result.root().validate(
  File "/usr/local/lib/python3.10/site-packages/libyang/data.py", line 430, in validate
    self.validate_all(no_state, validate_present)
  File "/usr/local/lib/python3.10/site-packages/libyang/data.py", line 449, in validate_all
    raise self.context.error("validation failed")
libyang.util.LibyangError: validation failed: Mandatory node "content-id" instance does not exist.
>>>

It seems to be related to config store:
93676bc
#21

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

1 participant