[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[rhel6-branch] multipath: allow mapper/mpath<X> specfifications in kickstart.



Resolves: rhbz#696876
---
 kickstart.py |   27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/kickstart.py b/kickstart.py
index 56d67af..fe3f064 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -21,6 +21,7 @@
 from storage.deviceaction import *
 from storage.devices import LUKSDevice
 from storage.devicelibs.lvm import getPossiblePhysicalExtents
+from storage.devicelibs.mpath import MultipathConfigWriter, identifyMultipaths
 from storage.formats import getFormat
 from storage.partitioning import clearPartitions
 from storage.partitioning import shouldClear
@@ -59,6 +60,10 @@ log = logging.getLogger("anaconda")
 stdoutLog = logging.getLogger("anaconda.stdout")
 from anaconda_log import logger, logLevelMap, setHandlersLevel
 
+# deviceMatches is called early, before any multipaths can possibly be coalesced
+# so it needs to know about them in some additional way
+multipaths = None
+
 class AnacondaKSScript(Script):
     def run(self, chroot, serial, intf = None):
         if self.inChroot:
@@ -175,18 +180,37 @@ def getEscrowCertificate(anaconda, url):
 
     return anaconda.id.escrowCertificates[url]
 
+def detect_multipaths():
+    global multipaths
+    mcw = MultipathConfigWriter()
+    cfg = mcw.write()
+    with open("/etc/multipath.conf", "w+") as mpath_cfg:
+        mpath_cfg.write(cfg)
+    devices = udev_get_block_devices()
+    (singles, multipaths, partitions) = identifyMultipaths(devices)
+
 def deviceMatches(spec):
     if not spec.startswith("/dev/"):
         spec = os.path.normpath("/dev/" + spec)
 
+    # the regular case
     matches = udev_resolve_glob(spec)
     dev = udev_resolve_devspec(spec)
-
     # udev_resolve_devspec returns None if there's no match, but we don't
     # want that ending up in the list.
     if dev and dev not in matches:
         matches.append(dev)
 
+    if spec.startswith("/dev/mapper/"):
+        # handle the multipath case
+        dm_name = spec.replace("/dev/mapper/", "", 1)
+        for members in multipaths:
+            mpath_name = udev_device_get_multipath_name(members[0])
+            if mpath_name  == dm_name:
+                # append the mpath
+                matches.append(mpath_name)
+                matches.extend(map(udev_device_get_name, members))
+
     return matches
 
 # Remove any existing formatting on a device, but do not remove the partition
@@ -1301,6 +1325,7 @@ def parseKickstart(anaconda, file):
     storage.zfcp.ZFCP().startup()
     # Note we do NOT call dasd.startup() here, that does not online drives, but
     # only checks if they need formatting, which requires zerombr to be known
+    detect_multipaths()
 
     try:
         ksparser.readKickstart(file)
-- 
1.7.3.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]