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

Incorrect handling of multi-value nodes #8

Open
dmbaturin opened this issue Oct 25, 2019 · 1 comment
Open

Incorrect handling of multi-value nodes #8

dmbaturin opened this issue Oct 25, 2019 · 1 comment

Comments

@dmbaturin
Copy link

Some nodes can have multiple values, like "address" in interfaces. Your parser confuses them with tag nodes.
A useful rule of thumb is presence of a left curly brace on the same line. Leaf nodes never have them, tag nodes always do.

>>> import vyattaconfparser
>>> conf="""
... ethernet eth0 {
...   address 192.0.2.1/24
...   address 192.0.2.2/24
... }
... """
>>> 
>>> vyattaconfparser.parse_conf(conf)
{'ethernet': {'eth0': {'address': {'192.0.2.1/24': {}, '192.0.2.2/24': {}}}}}

For the record, there's now built-in, fully "anatomically correct" parser and Python3 bindings for it that power the migration scripts and in the latest rolling release, the vyos.config library, and it can manipulate the trees in memory (it's a part of the future config backend to replace libvyattacfg).

Installing it on random machine is not quite easy since it has native code dependencies (https://github.com/vyos/libvyosconfig/), so an independent pure Python "config to a dict" parser retains its value.

@miron0xff
Copy link
Owner

Hello, thanks for your time inspecting this lib.
Yes, I know about this behaviour. First test shows it.
https://github.com/hedin/vyatta-conf-parser/blob/master/test_vyattaconfparser.py#L33

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