diff options
author | David Cantrell <dcantrell@redhat.com> | 2007-06-18 18:13:45 +0000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2007-06-18 18:13:45 +0000 |
commit | b701d9f3eb93acd6ec63a588856dcff3bcf0a49b (patch) | |
tree | 178ce884b63c09d1bd5f1078911ce9d3e76deafc | |
parent | 971323df2ab8d15115c00014fc243c0ffc9884e6 (diff) | |
download | anaconda-b701d9f3eb93acd6ec63a588856dcff3bcf0a49b.tar.gz anaconda-b701d9f3eb93acd6ec63a588856dcff3bcf0a49b.tar.xz anaconda-b701d9f3eb93acd6ec63a588856dcff3bcf0a49b.zip |
* backend.py (AnacondaBackend.doPostInstall): Make sure the multipath
bindings file exists on the target system, add multipath WWIDs to the
blacklist_exception block in multipath.conf (#243527), add mpath
filters to lvm.conf on the target system (#243531).
* fsset.py (FileSystemSet.fstab): Always print the device node name
for mpath devices in /etc/fstab rather than a LABEL line (#243532).
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | backend.py | 108 | ||||
-rw-r--r-- | fsset.py | 11 |
3 files changed, 114 insertions, 13 deletions
@@ -9,6 +9,14 @@ alert the user and return. libata won't allow more than 15 partitions at the moment (#238858). + * backend.py (AnacondaBackend.doPostInstall): Make sure the multipath + bindings file exists on the target system, add multipath WWIDs to the + blacklist_exception block in multipath.conf (#243527), add mpath + filters to lvm.conf on the target system (#243531). + + * fsset.py (FileSystemSet.fstab): Always print the device node name + for mpath devices in /etc/fstab rather than a LABEL line (#243532). + 2007-06-14 Chris Lumens <clumens@redhat.com> * anaconda.spec: Bump version. diff --git a/backend.py b/backend.py index abcfb4b0c..fe435d6aa 100644 --- a/backend.py +++ b/backend.py @@ -23,6 +23,7 @@ from syslogd import syslog from rhpl.translate import _ from flags import flags +from fsset import devify log = logging.getLogger("anaconda") @@ -50,15 +51,104 @@ class AnacondaBackend: sys.stdout.flush() if flags.setupFilesystems: syslog.stop() - try: - if not flags.mpath: - path = self.instPath + "/etc/sysconfig/mkinitrd/multipath" - f = open(path, "w") - f.write("MULTIPATH=no\n") - f.close() - os.chmod(path, 0755) - except: - pass + + # disable multipath boot features if system isn't using multipath + if not flags.mpath: + mpfile = self.instPath + "/etc/sysconfig/mkinitrd/multipath" + leading = os.path.dirname(mpfile) + + if not os.path.isdir(leading): + os.makedirs(leading, mode=0755) + + f = open(mpfile, "w") + f.write("MULTIPATH=no\n") + f.close() + os.chmod(mpfile, 0755) + + # make sure /var/lib/multipath/bindings exists on final system + bindings = '/var/lib/multipath/bindings' + wwids = [] + if flags.mpath and os.path.isfile(bindings): + leading = self.instPath + os.path.dirname(bindings) + + if not os.path.isdir(leading): + os.makedirs(leading, mode=0755) + + shutil.copy2(bindings, leading + '/bindings') + + # read in WWIDs per mpath device + f = open(bindings, 'r') + lines = map(lambda s: s[:-1], f.readlines()) + f.close() + + for l in lines: + if l.strip().startswith('mpath'): + try: + i = l.index(' ') + wwid = l[i:].strip() + wwids.append(wwid) + except: + pass + + # since all devices are blacklisted by default, add a + # blacklist_exception block for the devices we want treated as + # multipath devices --dcantrell (BZ #243527) + mpconf = self.instPath + "/etc/multipath.conf" + if flags.mpath: + f = open(mpconf, "r") + # remove newline from the end of each line + mplines = map(lambda s: s[:-1], f.readlines()) + f.close() + + f = open(mpconf, "w") + + blacklist = False + depth = 0 + for line in mplines: + if line.strip().startswith('#'): + f.write("%s\n" % (line,)) + else: + if blacklist: + depth += line.count('{') + depth -= line.count('}') + f.write("#%s\n" % (line,)) + + if depth == 0: + blacklist = False + + # write out the catch-all blacklist section to + # blacklist all device types + f.write('\nblacklist {\n') + f.write(' devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"\n') + f.write(' devnode "^hd[a-z]"\n') + f.write(' wwid "*"\n') + f.write('}\n') + + # write out the blacklist exceptions with + # multipath WWIDs + if wwids != []: + f.write('\n# Make sure our multipath devices are enabled.\n') + f.write('\nblacklist_exception {\n') + + for wwid in wwids: + f.write(" wwid \"%s\"\n" % (wwid,)) + + f.write('}\n\n') + else: + if line.strip().startswith('blacklist'): + depth += line.count('{') + depth -= line.count('}') + blacklist = True + f.write("#%s\n" % (line,)) + else: + f.write("%s\n" % (line,)) + + # add mpath filters to /etc/lvm/lvm.conf (#243531) + conf = self.instPath + '/etc/lvm/lvm.conf' + if flags.mpath and os.path.isfile(conf): + f = open(conf, 'w+') + f.write('filter = [ "a|/dev/mpath|", "r|.*|" ]\n') + f.close() def doInstall(self, anaconda): pass @@ -1234,13 +1234,16 @@ class FileSystemSet: for entry in self.entries: new.add (entry) return new - + def fstab (self): - format = "%-23s %-23s %-7s %-15s %d %d\n" + format = "%-23s %-23s %-7s %-15s %d %d\n" fstab = "" for entry in self.entries: if entry.mountpoint: - if entry.getLabel(): + # use LABEL if the device has a label except for multipath + # devices. always use devname on mpath devices + if entry.getLabel() and \ + entry.device.getDevice().find('mpath') == -1: device = "LABEL=%s" % (entry.getLabel(),) else: device = devify(entry.device.getDevice()) @@ -1282,7 +1285,7 @@ class FileSystemSet: def mdadmConf(self): raident = 0 - + cf = """ # mdadm.conf written out by anaconda DEVICE partitions |