[augeas-devel] exception: overlapping lenses in tree union.put

David Lutterkort lutter at redhat.com
Wed Jun 17 23:48:40 UTC 2009


Hi Bernhard,

On Wed, 2009-06-17 at 13:12 +0200, Bernhard Bock wrote:
> I’m trying to write a lens for keepalived.conf. Attached is an stripped
> down example for the config file and my lens for this file.
> 
> augtool can parse the file and get variables. Setting variables does not
> work – I guess for the same reason as augparse doesn’t like my lens:

Yeah, when augparse doesn't like your lens, all bets are off ;) See [1],
which talks about writing simple unit tests for your lens hand-in-hand
with the actual lens.

> It says “exception: optional expression matches the empty tree but does
> not consume a value” for all occurrences of spc?.

This essentially means that Augeas can't tell when it does the
transformation from tree to file, whether to use the spc lens or not.
Often, this can be addressed by avoiding the '?' on the lens level, and
using a regexp that matches the empty string (e.g., 'let spc =
Util.del_opt_ws " "'), or just rolling everything into one del, e.g.

        let end_sec = del /[ \t]*}\n/ "}\n"
        
> When I remove the indentation from the config file as well as from the
> lens, I get another error from augparse: “exception: overlapping lenses
> in tree union.put” for ‘entry’ and ‘subsubsubsection’.
> 
> How can I fix the second error and ideally keep the indentation?

The second error is caused by how you handle section nesting and how
Augeas matches a tree against the lens when it transforms the tree back
to a file; when Augeas sees a lens construct like 'l1|l2' it only looks
at the labels of the tree node it's currently at to decide whether to
use l1 or l2. IOW, if l1 and l2 both match tree nodes with the same
name, even if you could distinguish the trees by their depth, Augeas
complains with the above error message.

Fixing that would be nice little project, which I haven't had the time
to work on.

You can get the kind of nesting you need _if_ the names of the
subsections tell you how deeply nested the contents are - instead of a
generic lens that matches anystring followed by something enclosed in
'{ ... }', you'd have to write out e.g., that 'url' always the start of
a subsection without further nesting.

This is more work, but it also leads to a much 'tighter' lens, since it
knows much more about the structure of the config file - an example that
does that is the krb5.aug lens that parses krb5.conf.

David


[1] http://augeas.net/page/Creating_a_lens_step_by_step





More information about the augeas-devel mailing list