Skip to content

Incorrect handling of multi-value nodes #8

@dmbaturin

Description

@dmbaturin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions