ovirt-node 2.2.0 release
[ovirt-node.git] / augeas / resolv.aug
blob9403165c52f4dad52a8ae6f9b0b8aa1f5774840f
1 (*
2 Module: Resolv
3   Parses /etc/resolv.conf
5 Author: Raphael Pinson <raphink@gmail.com>
7 About: Reference
8   This lens tries to keep as close as possible to `man resolv.conf` where possible.
10 About: Licence
11   This file is licensed under the LGPLv2+, like the rest of Augeas.
13 About: Lens Usage
15 About: Configuration files
16   This lens applies to /etc/resolv.conf. See <filter>.
19 module Resolv =
20 autoload xfm
22 (************************************************************************
23  * Group:                 USEFUL PRIMITIVES
24  *************************************************************************)
26 (* View: comment *)
27 let comment = Util.comment_generic /[ \t]*[;#][ \t]*/ "# "
29 (* View: empty *)
30 let empty = Util.empty
33 (************************************************************************
34  * Group:                 MAIN OPTIONS
35  *************************************************************************)
37 (* View: netmask
38 A network mask for IP addresses *)
39 let netmask = [ label "netmask" . Util.del_str "/" . store Rx.ip ]
41 (* View: ipaddr 
42 An IP address or range with an optional mask *) 
43 let ipaddr = [label "ipaddr" . store Rx.ip . netmask?]
46 (* View: nameserver
47      A nameserver entry *)
48 let nameserver = Build.key_value_line 
49                     "nameserver" Sep.space (store Rx.ip)
51 (* View: domain *)
52 let domain = Build.key_value_line
53                     "domain" Sep.space (store Rx.word)
55 (* View: search *)
56 let search = Build.key_value_line
57                     "search" Sep.space
58                     (Build.opt_list 
59                            [label "domain" . store Rx.word]
60                             Sep.space)
62 (* View: sortlist *)
63 let sortlist = Build.key_value_line
64                     "sortlist" Sep.space
65                     (Build.opt_list
66                            ipaddr
67                            Sep.space) 
69 (************************************************************************
70  * Group:                 SPECIAL OPTIONS
71  *************************************************************************)
73 (* View: ip6_dotint
74      ip6-dotint option, which supports negation *)
75 let ip6_dotint = 
76   let negate = [ del "no-" "no-" . label "negate" ]
77     in [ negate? . key "ip6-dotint" ]
79 (* View: options 
80      Options values *)
81 let options =
82       let options_entry = Build.key_value ("ndots"|"timeout"|"attempts") 
83                                           (Util.del_str ":") (store Rx.integer)
84                         | Build.flag ("debug"|"rotate"|"no-check-names"
85                                      |"inet6"|"ip6-bytestring"|"edns0")
86                         | ip6_dotint
88             in Build.key_value_line
89                     "options" Sep.space
90                     (Build.opt_list
91                            options_entry
92                            Sep.space)
94 (* View: entry *)
95 let entry = nameserver
96           | domain
97           | search
98           | sortlist
99           | options
101 (* View: lns *)
102 let lns = ( empty | comment | entry )*
104 (* Variable: filter *)
105 let filter = (incl "/etc/resolv.conf")
106     . Util.stdexcl
108 let xfm = transform lns filter