Looks ok, Regards, Hans On 10/12/2009 05:26 PM, Peter Jones wrote:
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. --- storage/__init__.py | 17 +++++++++++++++++ storage/devicelibs/mpath.py | 37 +++++++++++++++++++++++++++++++++++++ storage/devices.py | 16 ++++++++++++++++ 3 files changed, 70 insertions(+), 0 deletions(-) create mode 100644 storage/devicelibs/mpath.py diff --git a/storage/__init__.py b/storage/__init__.py index 640014a..9a3752e 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 @@ -1951,6 +1952,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 @@ -2005,6 +2011,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 0000000..3de91af --- /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 261b9a1..5f9d068 100644 --- a/storage/devices.py +++ b/storage/devices.py @@ -2752,6 +2752,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.
_______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list