Imported Upstream version 1.8.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    qstr "path_selector"
41   |kv "path_grouping_policy" /failover|multibus|group_by_(serial|prio|node_name)/
42   |kv "path_checker" /tur|emc_clariion|hp_sw|rdac|directio|rdb|readsector0/
43   |kv "prio" /const|emc|alua|ontap|rdac|hp_sw|hds|random|weightedpath/
44   |qstr "prio_args"
45   |kv "failback" (Rx.integer | /immediate|manual|followover/)
46   |kv "rr_weight" /priorities|uniform/
47   |kv "flush_on_last_del" /yes|no/
48   |kv "user_friendly_names" /yes|no/
49   |kv "no_path_retry" (Rx.integer | /fail|queue/)
50   |kv /rr_min_io(_q)?/ Rx.integer
51   |qstr "features"
52   |kv "reservation_key" Rx.word
53   |kv "deferred_remove" /yes|no/
54   |kv "delay_watch_checks" (Rx.integer | "no")
55   |kv "delay_wait_checks" (Rx.integer | "no")
56   |kv "skip_kpartx" /yes|no/
57   (* Deprecated settings for backwards compatibility *)
58   |qstr /(getuid|prio)_callout/
59   (* Settings not documented in `man multipath.conf` *)
60   |kv /rr_min_io_rq/ Rx.integer
61   |kv "udev_dir" Rx.fspath
62   |qstr "selector"
63   |kv "async_timeout" Rx.integer
64   |kv "pg_timeout" Rx.word
65   |kv "h_on_last_deleassign_maps" /yes|no/
66   |qstr "uid_attribute"
67   |kv "hwtable_regex_match" /yes|no|on|off/
68   |kv "reload_readwrite" /yes|no/
69
70 let default_setting =
71    common_setting
72   |kv "polling_interval" Rx.integer
73   |kv "max_polling_interval" Rx.integer
74   |kv "multipath_dir" Rx.fspath
75   |kv "find_multipaths" /yes|no/
76   |kv "verbosity" /[0-6]/
77   |kv "reassign_maps" /yes|no/
78   |kv "uid_attrribute" Rx.word
79   |kv "max_fds" (Rx.integer|"max")
80   |kv "checker_timeout" Rx.integer
81   |kv "fast_io_fail_tmo" (Rx.integer|"off")
82   |kv "dev_loss_tmo" (Rx.integer|"infinity")
83   |kv "queue_without_daemon" /yes|no/
84   |kv "bindings_file" Rx.fspath
85   |kv "wwids_file" Rx.fspath
86   |kv "log_checker_err" /once|always/
87   |kv "retain_attached_hw_handler" /yes|no/
88   |kv "detect_prio" /yes|no/
89   |kv "hw_str_match" /yes|no/
90   |kv "force_sync" /yes|no/
91   |kv "config_dir" Rx.fspath
92   |kv "missing_uev_wait_timeout" Rx.integer
93   |kv "ignore_new_boot_devs" /yes|no/
94   |kv "retrigger_tries" Rx.integer
95   |kv "retrigger_delay" Rx.integer
96   |kv "new_bindings_in_boot" /yes|no/
97
98 (* A device subsection *)
99 let device =
100   let setting =
101     qstr /vendor|product|product_blacklist|hardware_handler|alias_prefix/
102    |default_setting in
103   section "device" setting
104
105 (* The defaults section *)
106 let defaults =
107   section "defaults" default_setting
108
109 (* The blacklist and blacklist_exceptions sections *)
110 let blacklist =
111   let setting =
112     wwid
113    |qstr "devnode"
114    |device in
115   section /blacklist(_exceptions)?/ setting
116
117 (* A multipath subsection *)
118 let multipath =
119   let setting =
120     wwid
121    |qstr "alias"
122    |common_setting in
123   section "multipath" setting
124
125 (* The multipaths section *)
126 let multipaths =
127   section "multipaths" multipath
128
129 (* The devices section *)
130 let devices =
131   section "devices" device
132
133 let lns = (comment|empty|defaults|blacklist|devices|multipaths)*
134
135 let xfm = transform lns (incl "/etc/multipath.conf" .
136                          incl "/etc/multipath/conf.d/*.conf")