summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2009-10-12 11:24:30 -0400
committerPeter Jones <pjones@redhat.com>2009-10-12 14:40:03 -0400
commit7b43a50cb9e96f39cb88c43c4cd4fc3e4a9604ad (patch)
tree1af721b8da19210273002bb1355e4a2901fae665
parent46aae7360fc76e7cc60742f62655fdc1e62efd80 (diff)
downloadanaconda-7b43a50cb9e96f39cb88c43c4cd4fc3e4a9604ad.tar.gz
anaconda-7b43a50cb9e96f39cb88c43c4cd4fc3e4a9604ad.tar.xz
anaconda-7b43a50cb9e96f39cb88c43c4cd4fc3e4a9604ad.zip
Write multipathd.conf in anaconda so that dracut can find it.
This writes a multipathd.conf that whitelists the devices we're using in our multipath devices. It's a fairly basic configuration, and it doesn't handle ALUA yet.
-rw-r--r--storage/__init__.py17
-rw-r--r--storage/devicelibs/mpath.py37
-rw-r--r--storage/devices.py16
3 files changed, 70 insertions, 0 deletions
diff --git a/storage/__init__.py b/storage/__init__.py
index be60444e5..0a9dad0ec 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -46,6 +46,7 @@ from formats import get_default_filesystem_type
from devicelibs.lvm import safeLvmName
from devicelibs.dm import name_from_dm_node
from devicelibs.crypto import generateBackupPassphrase
+from devicelibs.mpath import MultipathConfigWriter
from udev import *
import iscsi
import fcoe
@@ -1943,6 +1944,11 @@ class FSSet(object):
if mdadm_conf:
open(mdadm_path, "w").write(mdadm_conf)
+ multipath_path = os.path.normpath("%s/etc/multipath.conf" % instPath)
+ multipath_conf = self.multipathConf()
+ if multipath_conf:
+ open(multipath_path, "w").write(multipath_conf)
+
def crypttab(self):
# if we are upgrading, do we want to update crypttab?
# gut reaction says no, but plymouth needs the names to be very
@@ -1997,6 +2003,17 @@ class FSSet(object):
return retval
+ def multipathConf(self):
+ """ Return the contents of multipath.conf. """
+ mpaths = self.devicetree.getDevicesByType("dm-multipath")
+ if not mpaths:
+ return None
+ mpaths.sort(key=lambda d: d.name)
+ config = MultipathConfigWriter()
+ for mpath in mpaths:
+ config.addMultipathDevice(mpath)
+ return config.write()
+
def fstab (self):
format = "%-23s %-23s %-7s %-15s %d %d\n"
fstab = """
diff --git a/storage/devicelibs/mpath.py b/storage/devicelibs/mpath.py
new file mode 100644
index 000000000..3de91af62
--- /dev/null
+++ b/storage/devicelibs/mpath.py
@@ -0,0 +1,37 @@
+
+class MultipathConfigWriter:
+ def __init__(self):
+ self.blacklist_exceptions = []
+ self.mpaths = []
+
+ def addMultipathDevice(self, mpath):
+ for parent in mpath.parents:
+ self.blacklist_exceptions.append(parent.name)
+ self.mpaths.append(mpath)
+
+ def write(self):
+ ret = ""
+ ret += """\
+# multipath.conf written by anaconda
+
+blacklist {
+ devnode "*"
+}
+
+blacklist_exceptions {
+"""
+ for device in self.blacklist_exceptions:
+ ret += "\tdevnode \"^%s$\"\n" % (device,)
+ ret += """\
+}
+
+multipaths {
+"""
+ for mpath in self.mpaths:
+ ret += "\tmultipath {\n"
+ for k,v in mpath.config.items():
+ ret += "\t\t%s %s\n" % (k, v)
+ ret += "\t}\n\n"
+ ret += "}\n"
+
+ return ret
diff --git a/storage/devices.py b/storage/devices.py
index 577b0e9b4..d708130d2 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -2750,6 +2750,22 @@ class MultipathDevice(DiskDevice):
DiskDevice.__init__(self, name, format=format, size=size,
parents=parents, sysfsPath=sysfsPath)
+ # PJTODO: these need better setup
+ self.config = {
+ 'wwid' : self.identity,
+ 'alias' : self.name,
+ 'path_grouping_policy' : 'failover',
+ 'path_selector' : '\"round-robin 0\"',
+ 'failback' : 'manual',
+ 'rr_weight' : 'priorities',
+ 'no_path_retry' : 'queue',
+ 'rr_min_io' : '100',
+ #'flush_on_last_del' : 'yes',
+ 'mode' : '0644',
+ 'uid' : '0',
+ 'gid' : '0',
+ }
+
def setupIdentity(self):
""" Adds identifying remarks to MultipathDevice object.