[augeas-devel] cobbersettings lense

Greg Swift gregswift at gmail.com
Wed Apr 4 22:44:36 UTC 2012


On Wed, Apr 4, 2012 at 15:32, Dominic Cleal <dcleal at redhat.com> wrote:
> 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

okay.. well then thats an easy change.

>> 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".

well my concern was that the two regex expressions should match
similar data.  and was suprised it wasn't breaking.  When I changed
the * in ws to a + i was unable to load /etc/cobbler/settings.

[root at infra1-rep network-scripts]# augtool
augtool> ls /files/etc/cobbler/settings
augtool> print /augeas/files/etc/cobbler/settings/error
/augeas/files/etc/cobbler/settings/error = "parse_failed"
/augeas/files/etc/cobbler/settings/error/pos = "2974"
/augeas/files/etc/cobbler/settings/error/line = "69"
/augeas/files/etc/cobbler/settings/error/char = "0"
/augeas/files/etc/cobbler/settings/error/lens =
"/usr/share/augeas/lenses/dist/cobblersettings.aug:65.14-.71:"
/augeas/files/etc/cobbler/settings/error/message = "Iterated lens
matched less than it should"


> 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.

Seems to me like this is a much more useful direction, although I
don't know that myself or the cobbler guys are up to the task of
implementing a YAML lens.

> 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.

That may be very doable.  although the 'getting there is an
interesting concept to me, although I guess they can do a required
augeas-libs >= version.




More information about the augeas-devel mailing list