[augeas-devel] Problem with put direction on lens

Nathaniel Cook nvcook42 at gmail.com
Wed Jun 13 21:41:35 UTC 2012


I am writing a simple lens to manage the forward zones for power DNS.
What I have so far is pasted below. My problem is in the put
direction. Because the file cannot have any empty lines or even a new
line at the end of the I am having a hard time adding the first entry
from an empty file. If you run the tests you will get this error from
the put test.

tests/test_pdnsr_forward_zones.aug:30.1-35.35:exception thrown in test
tests/test_pdnsr_forward_zones.aug:30.7-34.70:exception: None of the
alternatives in the union match
    Lens: /usr/share/augeas/lenses/pdnsr_forward_zones.aug:27.13-.43:
    Error encountered at path


Any Ideas on how I can resolve this error?

Thanks,
Nathaniel

P.S. I took the book survey, I am excited to see its progress.  I
wouldn't be a good engineer if I didn't put in a plug for my employer
Qualtrics.  We provide an online survey solution and obviously use
augeas. The free trial would be more than enough to conduct further
surveys for the book. You can sign up here http://www.qualtrics.com
Just had to get that out there.



(* PowerDNS Recursor Forward-Zones module for Augeas
 Author: Nathaniel Cook <nathanielc at qualtrics.com>

 forward-zones is a file with zone=<list of servers> entries
 There must be one entry per line without any empty lines, comments or
trailing white space
*)

module Pdnsr_forward_zones =
	autoload xfm

(************************************************************************
 *                       PARTS
 *************************************************************************)
	let server = [ label "server" . store Rx.ipv4 ]
	let zone = store Rx.word
	let eol = [ Util.del_str "\n" ]
	
(************************************************************************
 *                       ENTRY
 *************************************************************************)
	let entry =  [ label "zone" . zone . Sep.equal .  Build.opt_list
server Sep.comma ]


(************************************************************************
 *                        LENS & FILTER
 *************************************************************************)
	let lns  =  ((entry . eol)* . entry) | eol

	let filter = incl "/etc/pdns-recursor/forward-zones"
	let xfm = transform lns filter



module Test_Pdnsr_forward_zones = 	

let conf0 = "zone1.com=10.2.3.5,10.35.32.235,250.25.23.0
zone2.com=10.2.3.5"

	test Pdnsr_forward_zones.lns get conf0 =
	{ "zone" = "zone1.com"
		{ "server" = "10.2.3.5" }
		{ "server" = "10.35.32.235" }
		{ "server" = "250.25.23.0" }
	}
	{ }
	{ "zone" = "zone2.com"
		{ "server" = "10.2.3.5" }
	}


	let conf1 = "zone2.com=10.2.3.5"
	test Pdnsr_forward_zones.lns get conf1 =
	{ "zone" = "zone2.com"
		{ "server" = "10.2.3.5" }
	}


	let empty = "\n"
	test Pdnsr_forward_zones.lns get empty = {}
	
	
	test  Pdnsr_forward_zones.lns put empty  after
		set "/zone[ .  = 'zone1.com' ]" "zone1.com";
		set "/zone[ . = 'zone1.com' ]/server[ . = '10.1.1.20' ]" "10.1.1.20";
		set "/zone[ . = 'zone1.com' ]/server[ . = '10.1.1.25' ]" "10.1.1.25"
	 = "zone1.com=10.1.1.20,10.1.1.25"




More information about the augeas-devel mailing list