[augeas-devel] augeas: master - Multipath: new lens for /etc/multipath.conf
David Lutterkort
lutter at fedoraproject.org
Wed Sep 9 22:34:44 UTC 2009
Gitweb: http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=22f638decea4b7d771e61f81e0c5258a8dfa7979
Commit: 22f638decea4b7d771e61f81e0c5258a8dfa7979
Parent: d4a6b4fd9dc0749fe99059e4ecee43eeb80afdab
Author: David Lutterkort <lutter at redhat.com>
AuthorDate: Wed Sep 2 17:05:00 2009 -0700
Committer: David Lutterkort <lutter at redhat.com>
CommitterDate: Fri Sep 4 10:56:47 2009 -0700
Multipath: new lens for /etc/multipath.conf
---
lenses/multipath.aug | 95 ++++++++++++++++++++++++
lenses/tests/test_multipath.aug | 153 +++++++++++++++++++++++++++++++++++++++
tests/Makefile.am | 1 +
tests/root/etc/multipath.conf | 97 +++++++++++++++++++++++++
4 files changed, 346 insertions(+), 0 deletions(-)
diff --git a/lenses/multipath.aug b/lenses/multipath.aug
new file mode 100644
index 0000000..82a6c16
--- /dev/null
+++ b/lenses/multipath.aug
@@ -0,0 +1,95 @@
+(* Process /etc/multipath.conf *)
+(* The lens is based on the multipath.conf(5) man page *)
+module Multipath =
+
+autoload xfm
+
+let comment = Util.comment
+let empty = Util.empty
+let dels = Util.del_str
+let eol = Util.eol
+
+let ws = del /[ \t]+/ " "
+let indent = del /[ \t]*/ ""
+(* We require that braces are always followed by a newline *)
+let obr = del /\{([ \t]*)\n/ "{\n"
+let cbr = del /[ \t]*}[ \t]*\n/ "}\n"
+
+let ikey (k:regexp) = indent . key k
+
+let section (n:regexp) (b:lens) =
+ [ ikey n . ws . obr . (b|empty|comment)* . cbr ]
+
+let kv (k:regexp) (v:regexp) =
+ [ ikey k . ws . store v . eol ]
+
+(* FIXME: it would be much more concise to write *)
+(* [ key k . ws . (bare | quoted) ] *)
+(* but the typechecker trips over that *)
+let qstr (k:regexp) =
+ let delq = del /['"]/ "\"" in
+ let bare = del /["']?/ "" . store /[^"' \t\n]+/ . del /["']?/ "" in
+ let quoted = delq . store /.*[ \t].*/ . delq in
+ [ ikey k . ws . bare . eol ]
+ |[ ikey k . ws . quoted . eol ]
+
+let wwid = kv "wwid" (Rx.word|"*")
+
+(* Settings that can be changed in various places *)
+let common_setting =
+ kv "path_grouping_policy"
+ /failover|multibus|group_by_(serial|prio|node_name)/
+ |qstr /(getuid|prio)_callout/
+ |qstr /path_(selector|checker)|features/
+ |kv "failback" (Rx.integer | /immediate|manual/)
+ |kv "rr_weight" /priorities|uniform/
+ |kv "no_path_retry" (Rx.integer | /fail|queue/)
+ |kv "rr_min_io" Rx.integer
+
+(* A device subsection *)
+let device =
+ let setting =
+ qstr /vendor|product|product_blacklist|hardware_handler/
+ |common_setting in
+ section "device" setting
+
+(* The defaults section *)
+let defaults =
+ let setting =
+ common_setting
+ |kv "polling_interval" Rx.integer
+ |kv "udev_dir" Rx.fspath
+ |qstr "selector"
+ |kv "user_friendly_names" /yes|no/
+ (* These are not in the manpage but in the example multipath.conf *)
+ |kv "prio" Rx.word
+ |kv "max_fds" Rx.integer in
+ section "defaults" setting
+
+(* The blacklist and blacklist_exceptions sections *)
+let blacklist =
+ let setting =
+ wwid
+ |qstr "devnode"
+ |device in
+ section /blacklist(_exceptions)?/ setting
+
+(* A multipath subsection *)
+let multipath =
+ let setting =
+ wwid
+ |qstr "alias"
+ |common_setting in
+ section "multipath" setting
+
+(* The multipaths section *)
+let multipaths =
+ section "multipaths" multipath
+
+(* The devices section *)
+let devices =
+ section "devices" device
+
+let lns = (comment|empty|defaults|blacklist|devices|multipaths)*
+
+let xfm = transform lns (incl "/etc/multipath.conf")
diff --git a/lenses/tests/test_multipath.aug b/lenses/tests/test_multipath.aug
new file mode 100644
index 0000000..5260337
--- /dev/null
+++ b/lenses/tests/test_multipath.aug
@@ -0,0 +1,153 @@
+module Test_multipath =
+
+ let conf = "# Blacklist all devices by default.
+blacklist {
+ devnode \"*\"
+ wwid *
+}
+
+# By default, devices with vendor = \"IBM\" and product = \"S/390.*\" are
+# blacklisted. To enable mulitpathing on these devies, uncomment the
+# following lines.
+blacklist_exceptions {
+ device {
+ vendor \"IBM\"
+ product \"S/390.*\"
+ }
+}
+
+#
+# Here is an example of how to configure some standard options.
+#
+
+defaults {
+ udev_dir /dev
+ polling_interval 10
+ selector \"round-robin 0\"
+ path_grouping_policy multibus
+ getuid_callout \"/sbin/scsi_id --whitelisted /dev/%n\"
+ prio alua
+ path_checker readsector0
+ rr_min_io 100
+ max_fds 8192
+ rr_weight priorities
+ failback immediate
+ no_path_retry fail
+ user_friendly_names yes
+}
+
+# Sections without empty lines in between
+blacklist {
+ wwid 26353900f02796769
+ devnode \"^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*\"
+
+ # Comments and blank lines inside a section
+ devnode \"^hd[a-z]\"
+
+}
+multipaths {
+ multipath {
+ wwid 3600508b4000156d700012000000b0000
+ alias yellow
+ path_grouping_policy multibus
+ path_checker readsector0
+ path_selector \"round-robin 0\"
+ failback manual
+ rr_weight priorities
+ no_path_retry 5
+ }
+ multipath {
+ wwid 1DEC_____321816758474
+ alias red
+ }
+}
+devices {
+ device {
+ vendor \"COMPAQ \"
+ product \"HSV110 (C)COMPAQ\"
+ path_grouping_policy multibus
+ getuid_callout \"/sbin/scsi_id --whitelisted /dev/%n\"
+ path_checker readsector0
+ path_selector \"round-robin 0\"
+ hardware_handler \"0\"
+ failback 15
+ rr_weight priorities
+ no_path_retry queue
+ }
+ device {
+ vendor \"COMPAQ \"
+ product \"MSA1000 \"
+ path_grouping_policy multibus
+ }
+}\n"
+
+test Multipath.lns get conf =
+ { "#comment" = "Blacklist all devices by default." }
+ { "blacklist"
+ { "devnode" = "*" }
+ { "wwid" = "*" } }
+ { }
+ { "#comment" = "By default, devices with vendor = \"IBM\" and product = \"S/390.*\" are" }
+ { "#comment" = "blacklisted. To enable mulitpathing on these devies, uncomment the" }
+ { "#comment" = "following lines." }
+ { "blacklist_exceptions"
+ { "device"
+ { "vendor" = "IBM" }
+ { "product" = "S/390.*" } } }
+ { }
+ { }
+ { "#comment" = "Here is an example of how to configure some standard options." }
+ { }
+ { }
+ { "defaults"
+ { "udev_dir" = "/dev" }
+ { "polling_interval" = "10" }
+ { "selector" = "round-robin 0" }
+ { "path_grouping_policy" = "multibus" }
+ { "getuid_callout" = "/sbin/scsi_id --whitelisted /dev/%n" }
+ { "prio" = "alua" }
+ { "path_checker" = "readsector0" }
+ { "rr_min_io" = "100" }
+ { "max_fds" = "8192" }
+ { "rr_weight" = "priorities" }
+ { "failback" = "immediate" }
+ { "no_path_retry" = "fail" }
+ { "user_friendly_names" = "yes" } }
+ { }
+ { "#comment" = "Sections without empty lines in between" }
+ { "blacklist"
+ { "wwid" = "26353900f02796769" }
+ { "devnode" = "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*" }
+ { }
+ { "#comment" = "Comments and blank lines inside a section" }
+ { "devnode" = "^hd[a-z]" }
+ { } }
+ { "multipaths"
+ { "multipath"
+ { "wwid" = "3600508b4000156d700012000000b0000" }
+ { "alias" = "yellow" }
+ { "path_grouping_policy" = "multibus" }
+ { "path_checker" = "readsector0" }
+ { "path_selector" = "round-robin 0" }
+ { "failback" = "manual" }
+ { "rr_weight" = "priorities" }
+ { "no_path_retry" = "5" } }
+ { "multipath"
+ { "wwid" = "1DEC_____321816758474" }
+ { "alias" = "red" } } }
+ { "devices"
+ { "device"
+ { "vendor" = "COMPAQ " }
+ { "product" = "HSV110 (C)COMPAQ" }
+ { "path_grouping_policy" = "multibus" }
+ { "getuid_callout" = "/sbin/scsi_id --whitelisted /dev/%n" }
+ { "path_checker" = "readsector0" }
+ { "path_selector" = "round-robin 0" }
+ { "hardware_handler" = "0" }
+ { "failback" = "15" }
+ { "rr_weight" = "priorities" }
+ { "no_path_retry" = "queue" } }
+ { "device"
+ { "vendor" = "COMPAQ " }
+ { "product" = "MSA1000 " }
+ { "path_grouping_policy" = "multibus" } } }
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9671aa7..eab9db3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -38,6 +38,7 @@ lens_tests = \
lens-lokkit.sh \
lens-modprobe.sh \
lens-monit.sh \
+ lens-multipath.sh \
lens-ntp.sh \
lens-openvpn.sh \
lens-pam.sh \
diff --git a/tests/root/etc/multipath.conf b/tests/root/etc/multipath.conf
new file mode 100644
index 0000000..fa2017b
--- /dev/null
+++ b/tests/root/etc/multipath.conf
@@ -0,0 +1,97 @@
+# This is a basic configuration file with some examples, for device mapper
+# multipath.
+# For a complete list of the default configuration values, see
+# /usr/share/doc/device-mapper-multipath-0.4.8/multipath.conf.defaults
+# For a list of configuration options with descriptions, see
+# /usr/share/doc/device-mapper-multipath-0.4.8/multipath.conf.annotated
+
+
+# Blacklist all devices by default. Remove this to enable multipathing
+# on the default devices.
+blacklist {
+ devnode "*"
+}
+
+# By default, devices with vendor = "IBM" and product = "S/390.*" are
+# blacklisted. To enable mulitpathing on these devies, uncomment the
+# following lines.
+blacklist_exceptions {
+ device {
+ vendor "IBM"
+ product "S/390.*"
+ }
+}
+
+## Use user friendly names, instead of using WWIDs as names.
+defaults {
+ user_friendly_names yes
+}
+#
+# Here is an example of how to configure some standard options.
+#
+
+defaults {
+ udev_dir /dev
+ polling_interval 10
+ selector "round-robin 0"
+ path_grouping_policy multibus
+ getuid_callout "/sbin/scsi_id --whitelisted /dev/%n"
+ prio alua
+ path_checker readsector0
+ rr_min_io 100
+ max_fds 8192
+ rr_weight priorities
+ failback immediate
+ no_path_retry fail
+ user_friendly_names yes
+}
+#
+# The wwid line in the following blacklist section is shown as an example
+# of how to blacklist devices by wwid. The 2 devnode lines are the
+# compiled in default blacklist. If you want to blacklist entire types
+# of devices, such as all scsi devices, you should use a devnode line.
+# However, if you want to blacklist specific devices, you should use
+# a wwid line. Since there is no guarantee that a specific device will
+# not change names on reboot (from /dev/sda to /dev/sdb for example)
+# devnode lines are not recommended for blacklisting specific devices.
+#
+blacklist {
+ wwid 26353900f02796769
+ devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
+ devnode "^hd[a-z]"
+}
+multipaths {
+ multipath {
+ wwid 3600508b4000156d700012000000b0000
+ alias yellow
+ path_grouping_policy multibus
+ path_checker readsector0
+ path_selector "round-robin 0"
+ failback manual
+ rr_weight priorities
+ no_path_retry 5
+ }
+ multipath {
+ wwid 1DEC_____321816758474
+ alias red
+ }
+}
+devices {
+ device {
+ vendor "COMPAQ "
+ product "HSV110 (C)COMPAQ"
+ path_grouping_policy multibus
+ getuid_callout "/sbin/scsi_id --whitelisted /dev/%n"
+ path_checker readsector0
+ path_selector "round-robin 0"
+ hardware_handler "0"
+ failback 15
+ rr_weight priorities
+ no_path_retry queue
+ }
+ device {
+ vendor "COMPAQ "
+ product "MSA1000 "
+ path_grouping_policy multibus
+ }
+}
More information about the augeas-devel
mailing list