[augeas-devel] How to create a new tree node with more than one subnode (key)?
Mol, Xavier (SCC)
xavier.mol at kit.edu
Mon Mar 7 14:40:28 UTC 2016
Hi Joe.
> Am I overlooking something really simple, or am what I'm attempting not possible?
I'd say the former. ;-)
> let testbranch =
> [ key /testbranch/i . Sep.space . attribute . Util.eol ]
Here you have stated that you want to have a testbranch with exactly one subnode (matched by attribute), finished by the end of the
line. So you need to change at least two things: allow several attributes for your testbranch and consider that you have several lines
in your configuration file.
Ciao,
Xavier.
From: augeas-devel-bounces at redhat.com [mailto:augeas-devel-bounces at redhat.com] On Behalf Of Joe Nuts
Sent: Monday, March 07, 2016 3:30 PM
To: augeas-devel at redhat.com
Subject: [augeas-devel] How to create a new tree node with more than one subnode (key)?
I'm having trouble building a lens that creates branches with multiple keys inside. My configuration file has unique lines which
dictate which tree and branch a value is to be associated with, but the lens configuration I've build insists on building a sequence
where one is not desired.
I've seen where a single line in a configuration file can be built to create multiple keys in a branch.
test_logrotate.aug shows single line "create 0664 root utmp" converted to
{.../create/mode = 0664
.../create/owner = root
.../create/group = utmp
}
Is this same result possible if the configuration file contains the values across multiple lines ( sometimes seperated by other
configuration values )?
I've built the following lens and test as an example to show my (currently unachieved ) desired results.
-- simpletestconf.aug --
module Simpletestconf =
autoload xfm
let attribute = [ key /key[1-3]/i . Sep.space . store /value[1-3]/i ]
let testbranch =
[ key /testbranch/i . Sep.space . attribute . Util.eol ]
let lns = ( Util.comment | testbranch ) *
let filter = incl "/etc/simpletest.conf"
let xfm = transform lns filter
-- dist/tests/test_simpletestconf.aug --
module Test_simpletestconf =
let example = "testbranch key1 value1
testbranch key2 value2
testbranch key3 value3
"
test SimpletestConf.lns get example =
{ "testbranch"
{ "key1" = "value1" }
{ "key2" = "value2" }
{ "key3" = "value3" }
}
Running augparse tests/test_simpletestconf.aug gives :
Test failure:tests/test_simpletestconf.aug:9.0-14.1:
Expected:
{
{ "testbranch"
{ "key1" = "value1" }
{ "key2" = "value2" }
{ "key3" = "value3" }
}
}
Actual:
{
{ "testbranch"
{ "key1" = "value1" }
}
{ "testbranch"
{ "key2" = "value2" }
}
{ "testbranch"
{ "key3" = "value3" }
}
}
Syntax error in lens definition
Failed to load tests/test_simpletestconf.aug
Sincerely
-Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20160307/21cf85dd/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6401 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20160307/21cf85dd/attachment.p7s>
More information about the augeas-devel
mailing list