[augeas-devel] set for multiple entries?
Frederik Wagner
fnerdwq at googlemail.com
Sun Mar 14 13:08:24 UTC 2010
On Fri, Feb 26, 2010 at 12:43 AM, David Lutterkort <lutter at redhat.com> wrote:
> On Thu, 2010-02-25 at 19:19 +0100, Frederik Wagner wrote:
>> Hi .*,
>>
>> I would like to append definitions for the console to _all_ kernel
>> lines ins the grub configuration. Is there a way to do that without
>> knowing howmany entries there are? E.g. using something like:
>>
>> augtool> set /files/boot/grub/menu.lst/title[*]/kernel/console[1] ttyS0
>> or
>> augtool> set /files/boot/grub/menu.lst/*/kernel/console[1] ttyS1
>>
>> I.e. so every title entry containing a kernel line would get
>> "console=..." parameters appended.
>> It is not working like I wrote, but there hopefully is away (btw. I'm
>> using augeas normally through puppet!).
Hi David,
> There's actually no way to do that through the API in one call - you can
> do it, e.g. in Ruby with something like
>
> aug.match("/files/boot/grub/menu.lst/*/kernel/console").each do
> |p|
> aug.set(p, "ttyS1")
> end
>
> It would not be very hard to add a aug_set_all call to the API (it would
> be a slight variation on aug_set in augeas.c) If you feel up to it, I'd
> happily take a patch ;)
while playing around in the code: this is actually quite simple as long
the node (in the example '../console') exists. When the node or the
path to the node does not exists (there might be kernel settings which
do not yet have a 'console' parameter), the match won't find them and
the aug_set() will not create the node.
The way to do this - as far as I understand - would be to somehow
delete the last node in the path/pattern (the node which value hast to
be set), match for the resulting patj and do a set on each match+node
to set. But for this I'm lost in the code, I don't want to introduce
arbitrary string manipulation in augeas.c ;-)
I'm anyway not sure, if the result would allow for all matching
operation, e.g. matches on the last part of the path, like
"/file/some/path/*[somematch]"
Including this in ruby or the ruby API seems more simple, but since I
would like to use it in puppet, I don't want to make a change in all
the interfaces for a 'dirty hack'.
Bye,
Frederik
More information about the augeas-devel
mailing list