On 06/01/2011 05:11 PM, Francis Giraldeau wrote:
>> I'm using Augeas 0.7.4 and wrote a little stub lens to use
>> ShellVars_list on
>> /etc/conf.d/modules in Gentoo.
>>
>> I'm trying to put a value to the modules_2_6 variable; this is the
>> output of a
>> test session (there is currently no modules_2_6 set):
>>
>> # augtool
>> augtool> set /files/etc/conf.d/modules/modules_2_6[last()+1] junk0
>> augtool> save
>> Saving failed
>> augtool> ls /augeas/files/etc/conf.d/modules/error/
>> path = /files/etc/conf.d/modules
>> lens = /usr/share/augeas/lenses/dist/shellvars_list.aug:40.12-.37:
>> message = Malformed child node 'modules_2_6'
>
> Here is a small lens that shows the parsing of the text with
> shellvars_list.aug:
>
> module Gentoo =
>
> test Shellvars_list.lns get "modules_2_6=\"junk0\"\n" = ?
> test Shellvars_list.lns get "modules_2_6=junk0\n" = ?
>
> It produces this:
>
> Test result: gentoo.aug:3.0-.57:
> { "modules_2_6"
> { "quote" = """ }
> { "value" = "junk0" }
> }
>
> Test result: gentoo.aug:4.0-.53:
> { "modules_2_6"
> { "quote" = "" }
> { "value" = "junk0" }
> }
>
> Hense, three nodes must be set. The first one, "modules_2_6" doesn't
> have a value. Children nodes "quote" and "value" must exists, and quote
> node must be before any value nodes (the order matters).
>
> Here is an example to create this string from scratch:
>
> test Shellvars_list.lns put "" after
> clear "/modules_2_6";
> set "/modules_2_6/quote" "\"";
> set "/modules_2_6/value" "junk0" = "modules_2_6=\"junk0\"\n"
>
> For multiple values:
>
> test Shellvars_list.lns put "" after
> clear "/modules_2_6";
> set "/modules_2_6/quote" "\"";
> set "/modules_2_6/value" "junk0";
> set "/modules_2_6/value[last()+1]" "junk1" = "modules_2_6=\"junk0 junk1
> \""
>
> Cheer,
>
> FrancisFrancis, Thanks for the explanation on how to better use this lens. I had done some playing around with it yesterday w.r.t. working with Gentoo's new /etc/conf.d/net format and saw the quote & value trees but didn't put them together. I was able to replicate your example and will work on getting them into my puppet stuff next; thanks! -Doug # augtool augtool> ls /files/etc/conf.d/modules/modules_2_6 augtool> clear /files/etc/conf.d/modules/modules_2_6 augtool> set /files/etc/conf.d/modules/modules_2_6/quote '"' augtool> set /files/etc/conf.d/modules/modules_2_6/value[last()+1] junk0 augtool> ls /files/etc/conf.d/modules/modules_2_6 quote = " value = junk0 augtool> save Saved 1 file(s) augtool> # tail -n1 /etc/conf.d/modules modules_2_6="junk0" # augtool augtool> set /files/etc/conf.d/modules/modules_2_6/value[last()+1] junk1 augtool> save Saved 1 file(s) augtool> # tail -n1 /etc/conf.d/modules modules_2_6="junk0 junk1"
signature.asc
Description: OpenPGP digital signature
_______________________________________________ augeas-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/augeas-devel
