[augeas-devel] file not being parsed?

David Lutterkort lutter at redhat.com
Thu Feb 18 21:55:43 UTC 2010


On Thu, 2010-02-18 at 21:47 +0100, Tim Stoop wrote:
> I've made a very simple nagios.cfg parser (basically, the puppet
> parser) and now I'm trying to test it. But I'm not really sure what
> I'm doing wrong here, it seems like augeas cannot load the file? Any
> help is appreciated!

If Augeas runs into any error loading the file, including when it's not
able to parse it, it won't show up in the tree. To make sure, type
'print /augeas//error' in augtool (with the double slash)

For lens development, it's usually much easier to use augparse,
especially since you need to write tests anyway if you want to submit
the lens here ;) Have a look at the lenses in /usr/share/augeas/lenses
and the corresponding tests in /usr/share/augeas/lenses/tests in your
augeas installation for lots of examples.

The Wiki[1] has a number of pages that talk about Lens Development - you
should have a quick look at them. In a nutshell, create a new file
'test_nagioscfg.aug' and add things like

        module Test_NagiosCfg =
        
        let s1 = "... some extremely basic Nagios config, maybe just one or two lines .."
        test NagiosCfg.lns get s1 = ?
        
and then run 'augparse -I DIR_WHERE_NAGIOS_CFG_IS test_nagioscfg.aug'

You'll either get a printout of the resulting tree (if the parse
succeeds) or an error message when something goes wrong. Some background
on the errors are at [2]

If you just want to see in more detail why the current nagios.cfg fails,
add the lines

        let cfg = Sys.read_file "/etc/nagios3/nagios.cfg"
        test lns get cfg = ?
        
to the end of nagioscfg.aug and run that with 'augparse nagioscfg.aug' -
that will give you essentially the same errors that
'print /augeas//error' gives you in augtool, though with a little more
detail.

But you should still write a proper test_nagioscfg.aug ;)

David

[1] http://augeas.net/page/Main_Page
[2] http://augeas.net/page/Ambiguities_or_what_do_those_error_messages_from_the_typechecker_mean





More information about the augeas-devel mailing list