Imported Upstream version 1.7.0
[platform/upstream/augeas.git] / lenses / multipath.aug
1 (* Process /etc/multipath.conf                             *)
2 (* The lens is based on the multipath.conf(5) man page     *)
3 module Multipath =
4
5 autoload xfm
6
7 let comment = Util.comment
8 let empty = Util.empty
9 let dels = Util.del_str
10 let eol = Util.eol
11
12 let ws = del /[ \t]+/ " "
13 let indent = del /[ \t]*/ ""
14 (* We require that braces are always followed by a newline *)
15 let obr = del /\{([ \t]*)\n/ "{\n"
16 let cbr = del /[ \t]*}[ \t]*\n/ "}\n"
17
18 let ikey (k:regexp) = indent . key k
19
20 let section (n:regexp) (b:lens) =
21   [ ikey n . ws . obr . (b|empty|comment)* . cbr ]
22
23 let kv (k:regexp) (v:regexp) =
24   [ ikey k . ws . store v . eol ]
25
26 (* FIXME: it would be much more concise to write                       *)
27 (* [ key k . ws . (bare | quoted) ]                                    *)
28 (* but the typechecker trips over that                                 *)
29 let qstr (k:regexp) =
30   let delq = del /['"]/ "\"" in
31   let bare = del /["']?/ "" . store /[^"' \t\n]+/ . del /["']?/ "" in
32   let quoted = delq . store /.*[ \t].*/ . delq in
33   [ ikey k . ws . bare . eol ]
34  |[ ikey k . ws . quoted . eol ]
35
36 let wwid = kv "wwid" (Rx.word|"*")
37
38 (* Settings that can be changed in various places *)
39 let common_setting =
40   kv "path_grouping_policy"
41     /failover|multibus|group_by_(serial|prio|node_name)/
42  |qstr /(getuid|prio)_callout/
43  |qstr /path_(selector|checker)|features/
44  |kv "failback" (Rx.integer | /immediate|manual/)
45  |kv "rr_weight" /priorities|uniform/
46  |kv "no_path_retry" (Rx.integer | /fail|queue/)
47  |kv /rr_min_io(_rq)?/ Rx.integer
48  |kv "flush_on_last_del" /yes|no/
49  |kv "reservation_key" Rx.word
50  |kv "delay_watch_checks" (Rx.integer|"no")
51  |kv "delay_wait_checks" (Rx.integer|"no")
52
53 let default_setting =
54   kv "polling_interval" Rx.integer
55   |kv "udev_dir" Rx.fspath
56   |qstr "selector"
57   |kv "user_friendly_names" /yes|no/
58   |kv "dev_loss_tmo" Rx.integer
59   |kv "fast_io_fail_tmo" Rx.integer
60   |kv "verbosity" /[0-6]/
61   |kv "reassign_maps" /yes|no/
62   |kv "prio" Rx.word
63   |kv "max_fds" Rx.integer
64   |kv "find_multipaths" /yes|no/
65   |kv "checker_timeout" Rx.integer
66   |kv "hwtable_regex_match" /yes|no/
67   |kv "reload_readwrite" /yes|no/
68   |kv "replace_wwid_whitespace" /yes|no/
69   |kv "force_sync" /yes|no/
70   |kv "config_dir" Rx.fspath
71   (* SUSE extensions *)
72   |kv "async_timeout" Rx.integer
73   |kv "max_polling_interval" Rx.integer
74   |kv "pg_timeout" Rx.word
75   |kv "bindings_file" Rx.fspath
76   |kv "multipath_dir" Rx.fspath
77   |kv "alias_prefix" Rx.word
78   |kv "queue_without_daemon" /yes|no/
79   |kv "h_on_last_deleassign_maps" /yes|no/
80   |qstr "prio_args"
81   (* SUSE extensions SP3 *)
82   |qstr "uid_attribute"
83   |kv "wwids_file" Rx.fspath
84   |kv "log_checker_err" Rx.word
85   |kv "retain_attached_hw_handler" /yes|no/
86   |kv "detect_prio" /yes|no/
87
88 (* A device subsection *)
89 let device =
90   let setting =
91     qstr /vendor|product|product_blacklist|hardware_handler/
92    |common_setting
93    |default_setting in
94   section "device" setting
95
96 (* The defaults section *)
97 let defaults =
98   let setting =
99     common_setting
100    |default_setting
101   in section "defaults" setting
102
103 (* The blacklist and blacklist_exceptions sections *)
104 let blacklist =
105   let setting =
106     wwid
107    |qstr "devnode"
108    |device in
109   section /blacklist(_exceptions)?/ setting
110
111 (* A multipath subsection *)
112 let multipath =
113   let setting =
114     wwid
115    |qstr "alias"
116    |common_setting in
117   section "multipath" setting
118
119 (* The multipaths section *)
120 let multipaths =
121   section "multipaths" multipath
122
123 (* The devices section *)
124 let devices =
125   section "devices" device
126
127 let lns = (comment|empty|defaults|blacklist|devices|multipaths)*
128
129 let xfm = transform lns (incl "/etc/multipath.conf" .
130                          incl "/etc/multipath/conf.d/*.conf")