[augeas-devel] cobbersettings lense

Dominic Cleal dcleal at redhat.com
Wed Apr 4 20:32:53 UTC 2012


On 04/04/12 14:14, Greg Swift wrote:
> I was just working with jimi_c over in cobbler about him using augeas
> to manage the cobbler settings file from the webui.  We ran into some
> parsing and consistency issues.  When he was trying to edit a value
> that had multilines with indents he would end up with a tab indent
> instead of the existing space.  I looked in the lens and this is
> fairly obvious.  indent is defined as /[ \t]+/ being replaced with \t.
>  The problem with this is two fold:
> 
> 1) generally the file is using spaces by default, so unless someone
> changed it there wouldn't be tabs and augeas doesn't rewrite the whole
> file with this change for consistency
> 
> 2) Apparently YAML or pyYAML doesn't like the tabs anyway.

Yes, for YAML it's invalid:
http://www.yaml.org/spec/1.2/spec.html#id2777534

> I'm also slightly confused by the fact that these two expressions
> seems to overlap, but augeas doesn't complain, and if I change the ws
> one to not use a *, it blows up.
> 
>    let indent = del /^[ \t]+/ "    "
>    let ws = del /[ \t]*/ " "

These two don't seem to be used in combination with each other - they're
just defined side by side.  The only error I can generate by changing
"ws" to require a space is where it's used for lists of entries to
permit whitespace next to square brackets.  I don't think you want to
change this, only "indent".

If you're working on a patch to tidy up and fix the indentation, that
would be great.  I hadn't realised we had this lens which implemented
plain YAML, it would be nice to complete and copy it to become a generic
YAML lens (to sit with other lenses such as XML, JSON etc).  I think
some parts such as the [] lists are Cobbler extensions.

As mentioned on IRC, it would be nice to have Cobbler adopt the lenses
as part of their source tree.  There are some projects (libvirt,
corosync) that ship their own lenses, so this one could equally
"graduate" into Cobbler itself if they'd like it - preventing lag in
changes and fixes.

-- 
Dominic Cleal
Red Hat Consulting
m: +44 (0)7817 878113




More information about the augeas-devel mailing list