[PATCH - storage]: Fix booty for dmraid

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

 



Booty was expecting the xxxxxxx part of /dev/xxxxxx paths instead of
new storage device names, this patch fixes this, making booty work on
dmraid with the new storage code.
---
 bootloader.py                    |    4 +-
 booty/alpha.py                   |    4 +-
 booty/bootloaderInfo.py          |    2 +-
 booty/checkbootloader.py         |   18 ++++++------
 booty/ppc.py                     |    2 +-
 booty/sparc.py                   |    2 +-
 booty/util.py                    |    9 +++---
 booty/x86.py                     |   51 ++++++++++++++++++++-----------------
 iw/upgrade_bootloader_gui.py     |    4 +-
 textw/upgrade_bootloader_text.py |    4 +-
 10 files changed, 53 insertions(+), 47 deletions(-)

diff --git a/bootloader.py b/bootloader.py
index 313ecdf..f920952 100644
--- a/bootloader.py
+++ b/bootloader.py
@@ -121,12 +121,12 @@ def writeBootloader(anaconda):
     # now make the upgrade stuff work for kickstart too. ick.
     if anaconda.isKickstart and anaconda.id.bootloader.doUpgradeOnly:
         import checkbootloader
-        (bootType, theDev) = checkbootloader.getBootloaderTypeAndBoot(anaconda.rootPath)
+        (bootType, theDev) = checkbootloader.getBootloaderTypeAndBoot(anaconda.rootPath, storage=anaconda.id.storage)

         anaconda.id.bootloader.doUpgradeonly = 1
         if bootType == "GRUB":
             anaconda.id.bootloader.useGrubVal = 1
-            anaconda.id.bootloader.setDevice(theDev)
+            anaconda.id.bootloader.setDevice(theDev.split("/")[-1])
         else:
             anaconda.id.bootloader.doUpgradeOnly = 0

diff --git a/booty/alpha.py b/booty/alpha.py
index abd3a63..ca71556 100644
--- a/booty/alpha.py
+++ b/booty/alpha.py
@@ -7,13 +7,13 @@ from util import getDiskPart

 class alphaBootloaderInfo(bootloaderInfo):
     def wholeDevice (self, path):
-        (device, foo) = getDiskPart(path)
+        (device, foo) = getDiskPart(path, self.storage)
         return device

     def partitionNum (self, path):
         # getDiskPart returns part numbers 0-based; we need it one based
         # *sigh*
-        (foo, partitionNumber) = getDiskPart(path)
+        (foo, partitionNumber) = getDiskPart(path, self.storage)
         return partitionNumber + 1

     def writeAboot(self, instRoot, bl, kernelList,
diff --git a/booty/bootloaderInfo.py b/booty/bootloaderInfo.py
index f9f684b..2fdf16a 100644
--- a/booty/bootloaderInfo.py
+++ b/booty/bootloaderInfo.py
@@ -295,7 +295,7 @@ class bootloaderInfo:
     def setDevice(self, device):
         self.device = device

-        (dev, part) = getDiskPart(device)
+        (dev, part) = getDiskPart(device, self.storage)
         if part is None:
             self.defaultDevice = "mbr"
         else:
diff --git a/booty/checkbootloader.py b/booty/checkbootloader.py
index 7c62416..9508e14 100644
--- a/booty/checkbootloader.py
+++ b/booty/checkbootloader.py
@@ -27,7 +27,7 @@ liloConfigFile = "/etc/lilo.conf"
 yabootConfigFile = "/etc/yaboot.conf"
 siloConfigFile = "/etc/silo.conf"

-def getRaidDisks(raidDevice, raidLevel=None, stripPart=1):
+def getRaidDisks(raidDevice, storage, raidLevel=None, stripPart=1):
     rc = []
     if raidLevel is not None:
         try:
@@ -54,7 +54,7 @@ def getRaidDisks(raidDevice, raidLevel=None, stripPart=1):
                 if len(dev) == 0:
                     continue
                 if stripPart:
-                    disk = getDiskPart(dev)[0]
+                    disk = getDiskPart(dev, storage)[0]
                     rc.append(disk)
                 else:
                     rc.append(dev)
@@ -62,7 +62,7 @@ def getRaidDisks(raidDevice, raidLevel=None, stripPart=1):
     return rc


-def getBootBlock(bootDev, instRoot, seekBlocks=0):
+def getBootBlock(bootDev, instRoot, storage, seekBlocks=0):
     """Get the boot block from bootDev.  Return a 512 byte string."""
     block = " " * 512
     if bootDev is None:
@@ -70,7 +70,7 @@ def getBootBlock(bootDev, instRoot, seekBlocks=0):

     # get the devices in the raid device
     if bootDev[5:7] == "md":
-        bootDevs = getRaidDisks(bootDev[5:])
+        bootDevs = getRaidDisks(bootDev[5:], storage)
         bootDevs.sort()
     else:
         bootDevs = [ bootDev[5:] ]
@@ -108,7 +108,7 @@ def getBootDevList(line):
         rets.append(dev)
     return string.join(rets)

-def getBootloaderTypeAndBoot(instRoot = "/"):
+def getBootloaderTypeAndBoot(instRoot, storage):
     haveGrubConf = 1
     haveLiloConf = 1
     haveYabootConf = 1
@@ -150,7 +150,7 @@ def getBootloaderTypeAndBoot(instRoot = "/"):
             return ("GRUB", bootDev)

         if bootDev is not None:
-            block = getBootBlock(bootDev, instRoot)
+            block = getBootBlock(bootDev, instRoot, storage)
             # XXX I don't like this, but it's what the maintainer suggested :(
             if string.find(block, "GRUB") >= 0:
                 return ("GRUB", bootDev)
@@ -163,7 +163,7 @@ def getBootloaderTypeAndBoot(instRoot = "/"):
                 bootDev = getBootDevString(line)
                 break

-        block = getBootBlock(bootDev, instRoot)
+        block = getBootBlock(bootDev, instRoot, storage)
         # this at least is well-defined
         if block[6:10] == "LILO":
             return ("LILO", bootDev)
@@ -200,8 +200,8 @@ def getBootloaderTypeAndBoot(instRoot = "/"):

         if bootDev is not None:
             # XXX SILO sucks just like grub.
-            if getDiskPart(bootDev)[1] != 3:
-                block = getBootBlock(bootDev, instRoot, 1)
+            if getDiskPart(bootDev, storage)[1] != 3:
+                block = getBootBlock(bootDev, instRoot, storage, 1)
                 if block[24:28] == "SILO":
                     return ("SILO", bootDev)

diff --git a/booty/ppc.py b/booty/ppc.py
index a68c593..7ac9299 100644
--- a/booty/ppc.py
+++ b/booty/ppc.py
@@ -64,7 +64,7 @@ class ppcBootloaderInfo(bootloaderInfo):
         f.write("init-message=\"Welcome to %s!\\nHit <TAB> for boot options\"\n\n"
                 % productName)

-        (name, partNum) = getDiskPart(bootDev)
+        (name, partNum) = getDiskPart(bootDev, self.storage)
         partno = partNum + 1 # 1 based

         f.write("partition=%s\n" %(partno,))
diff --git a/booty/sparc.py b/booty/sparc.py
index 5ea45ee..4ea2cea 100644
--- a/booty/sparc.py
+++ b/booty/sparc.py
@@ -35,7 +35,7 @@ class sparcBootloaderInfo(bootloaderInfo):
         f.write("message=%s\n" % (mf,))
         f.write("timeout=%s\n" % (self.timeout or 50))

-        (name, partNum) = getDiskPart(bootDev)
+        (name, partNum) = getDiskPart(bootDev, self.storage)
         partno = partNum + 1
         f.write("partition=%s\n" % (partno,))

diff --git a/booty/util.py b/booty/util.py
index f9a1b3e..74ba561 100644
--- a/booty/util.py
+++ b/booty/util.py
@@ -1,10 +1,11 @@
 import string

-def getDiskPart(dev):
+def getDiskPart(dev, storage):
+    path = storage.devicetree.getDeviceByName(dev).path[5:]
     cut = len(dev)
-    if (dev.startswith('rd/') or dev.startswith('ida/') or
-            dev.startswith('cciss/') or dev.startswith('sx8/') or
-            dev.startswith('mapper/') or dev.startswith('mmcblk')):
+    if (path.startswith('rd/') or path.startswith('ida/') or
+            path.startswith('cciss/') or path.startswith('sx8/') or
+            path.startswith('mapper/') or path.startswith('mmcblk')):
         if dev[-2] == 'p':
             cut = -1
         elif dev[-3] == 'p':
diff --git a/booty/x86.py b/booty/x86.py
index de88458..05c9feb 100644
--- a/booty/x86.py
+++ b/booty/x86.py
@@ -46,15 +46,18 @@ class x86BootloaderInfo(efiBootloaderInfo):
         # Accepted values for "device" are raid1 md devices (i.e. "md0"),
         # physical disks ("hda"), and real partitions on physical disks
         # ("hda1").  Volume groups/logical volumes are not accepted.
-        if string.split(device, '/', 1)[0] in map (lambda x: x.name, self.storage.lvs + self.storage.vgs):
+        path = self.storage.devicetree.getDeviceByName(device).path[5:]
+
+        if device in map (lambda x: x.name, self.storage.lvs + self.storage.vgs):
             return []

-        if device.startswith("mapper/luks-"):
+        if path.startswith("mapper/luks-"):
             return []

-        if device.startswith('md'):
+        if path.startswith('md'):
             bootable = 0
-            parts = checkbootloader.getRaidDisks(device, 1, stripPart=0)
+            parts = checkbootloader.getRaidDisks(device, self.storage,
+                                                 raidLevel=1, stripPart=0)
             parts.sort()
             return parts

@@ -107,7 +110,7 @@ class x86BootloaderInfo(efiBootloaderInfo):
         cmds = []
         for bootDev in bootDevs:
             gtPart = self.getMatchingPart(bootDev, grubTarget)
-            gtDisk = self.grubbyPartitionName(getDiskPart(gtPart)[0])
+            gtDisk = self.grubbyPartitionName(getDiskPart(gtPart, self.storage)[0])
             bPart = self.grubbyPartitionName(bootDev)
             cmd = "root %s\n" % (bPart,)

@@ -135,18 +138,19 @@ class x86BootloaderInfo(efiBootloaderInfo):
             os.rename(cf, cf + '.rpmsave')

         grubTarget = bl.getDevice()
+        path = self.storage.devicetree.getDeviceByName(grubTarget).path[5:]
         target = "mbr"
-        if (grubTarget.startswith('rd/') or grubTarget.startswith('ida/') or
-                grubTarget.startswith('cciss/') or
-                grubTarget.startswith('sx8/') or
-                grubTarget.startswith('mapper/')):
+        if (path.startswith('rd/') or path.startswith('ida/') or
+                path.startswith('cciss/') or
+                path.startswith('sx8/') or
+                path.startswith('mapper/')):
             if grubTarget[-1].isdigit():
                 if grubTarget[-2] == 'p' or \
                         (grubTarget[-2].isdigit() and grubTarget[-3] == 'p'):
                     target = "partition"
-        elif grubTarget[-1].isdigit() and not grubTarget.startswith('md'):
+        elif grubTarget[-1].isdigit() and not path.startswith('md'):
             target = "partition"
-
+
         f = open(cf, "w+")

         f.write("# grub.conf generated by anaconda\n")
@@ -316,7 +320,7 @@ class x86BootloaderInfo(efiBootloaderInfo):
         devs = usedDevs.keys()
         usedDevs = {}
         for dev in devs:
-            drive = getDiskPart(dev)[0]
+            drive = getDiskPart(dev, self.storage)[0]
             if usedDevs.has_key(drive):
                 continue
             usedDevs[drive] = 1
@@ -325,9 +329,9 @@ class x86BootloaderInfo(efiBootloaderInfo):
         for drive in devs:
             # XXX hack city.  If they're not the sort of thing that'll
             # be in the device map, they shouldn't still be in the list.
+            path = self.storage.devicetree.getDeviceByName(drive).path
             if not drive.startswith('md'):
-                f.write("(%s)     /dev/%s\n" % (self.grubbyDiskName(drive),
-                                            drive))
+                f.write("(%s)     %s\n" % (self.grubbyDiskName(drive), path))
         f.close()

         sysconf = '/etc/sysconfig/grub'
@@ -356,10 +360,10 @@ class x86BootloaderInfo(efiBootloaderInfo):
         return ""

     def getMatchingPart(self, bootDev, target):
-        bootName, bootPartNum = getDiskPart(bootDev)
+        bootName, bootPartNum = getDiskPart(bootDev, self.storage)
         devices = self.getPhysicalDevices(target)
         for device in devices:
-            name, partNum = getDiskPart(device)
+            name, partNum = getDiskPart(device, self.storage)
             if name == bootName:
                 return device
         return devices[0]
@@ -368,7 +372,7 @@ class x86BootloaderInfo(efiBootloaderInfo):
         return "hd%d" % self.drivelist.index(name)

     def grubbyPartitionName(self, dev):
-        (name, partNum) = getDiskPart(dev)
+        (name, partNum) = getDiskPart(dev, self.storage)
         if partNum != None:
             return "(%s,%d)" % (self.grubbyDiskName(name), partNum)
         else:
@@ -448,23 +452,24 @@ class x86BootloaderInfo(efiBootloaderInfo):
         # so we have to do shenanigans to get updated grub installed...
         # steal some more code above
         try:
-            bootDev = self.storage.fsset.mountpoints["/boot"]
+            bootDev = self.storage.fsset.mountpoints["/boot"].name
             grubPath = "/grub"
             cfPath = "/"
         except KeyError:
-            bootDev = self.storage.fsset.rootDevice
+            bootDev = self.storage.fsset.rootDevice.name
             grubPath = "/boot/grub"
             cfPath = "/boot/"

         masterBootDev = bootDev
         if masterBootDev[0:2] == 'md':
-            rootDevs = checkbootloader.getRaidDisks(masterBootDev, raidLevel=1,
-                            stripPart = 0)
+            rootDevs = checkbootloader.getRaidDisks(masterBootDev,
+                            self.storage, raidLevel=1, stripPart=0)
         else:
             rootDevs = [masterBootDev]

         if theDev[5:7] == 'md':
-            stage1Devs = checkbootloader.getRaidDisks(theDev[5:], raidLevel=1)
+            stage1Devs = checkbootloader.getRaidDisks(theDev[5:], self.storage,
+                              raidLevel=1)
         else:
             stage1Devs = [theDev[5:]]

@@ -478,7 +483,7 @@ class x86BootloaderInfo(efiBootloaderInfo):
             grubbyRootPart = self.grubbyPartitionName(rootDevs[0])

             for rootDev in rootDevs:
-                testGrubbyRootDev = getDiskPart(rootDev)[0]
+                testGrubbyRootDev = getDiskPart(rootDev, self.storage)[0]
                 testGrubbyRootDev = self.grubbyPartitionName(testGrubbyRootDev)

                 if grubbyStage1Dev == testGrubbyRootDev:
diff --git a/iw/upgrade_bootloader_gui.py b/iw/upgrade_bootloader_gui.py
index 63ebb9d..57cfc63 100644
--- a/iw/upgrade_bootloader_gui.py
+++ b/iw/upgrade_bootloader_gui.py
@@ -61,7 +61,7 @@ class UpgradeBootloaderWindow (InstallWindow):
                 self.bl.useGrubVal = 1
             else:
                 self.bl.useGrubVal = 0
-            self.bl.setDevice(self.bootDev)
+            self.bl.setDevice(self.bootDev.split("/")[-1])

     def _newToLibata(self, rootPath):
         # NOTE: any changes here need to be done in upgrade_bootloader_text too
@@ -117,7 +117,7 @@ class UpgradeBootloaderWindow (InstallWindow):
         newToLibata = self._newToLibata(anaconda.rootPath)

         (self.type, self.bootDev) = \
-                    checkbootloader.getBootloaderTypeAndBoot(anaconda.rootPath)
+                    checkbootloader.getBootloaderTypeAndBoot(anaconda.rootPath, storage=anaconda.id.storage)

         self.update_radio = gtk.RadioButton(None, _("_Update boot loader configuration"))
         updatestr = _("This will update your current boot loader.")
diff --git a/textw/upgrade_bootloader_text.py b/textw/upgrade_bootloader_text.py
index 636d789..f863efb 100644
--- a/textw/upgrade_bootloader_text.py
+++ b/textw/upgrade_bootloader_text.py
@@ -86,7 +86,7 @@ class UpgradeBootloaderWindow:

         newToLibata = self._ideToLibata(anaconda.rootPath)
         (self.type, self.bootDev) = \
-                    checkbootloader.getBootloaderTypeAndBoot(anaconda.rootPath)
+                    checkbootloader.getBootloaderTypeAndBoot(anaconda.rootPath, storage=anaconda.id.storage)

         blradio = RadioGroup()

@@ -173,7 +173,7 @@ class UpgradeBootloaderWindow:
                     self.bl.useGrubVal = 1
                 else:
                     self.bl.useGrubVal = 0
-                self.bl.setDevice(self.bootDev)
+                self.bl.setDevice(self.bootDev.split("/")[-1])



--
1.6.1.3

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux