[PATCH 1/8] booty: make getPhysicalDevices take and return Devices rather then device names

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

 



---
 bootloader.py |   17 +++++++++--------
 booty/x86.py  |   32 +++++++++++++++++---------------
 2 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/bootloader.py b/bootloader.py
index 30912e7..83ef5d3 100644
--- a/bootloader.py
+++ b/bootloader.py
@@ -125,9 +125,10 @@ def fixedMdraidGrubTarget(anaconda, grubTarget):
     try:
         if float(version) < 12:
             stage1Devs = anaconda.bootloader.getPhysicalDevices(grubTarget)
-            fixedGrubTarget = getDiskPart(stage1Devs[0], anaconda.storage)[0]
-            log.info("Mdraid grub upgrade: %s -> %s" % (grubTarget,
-                                                       fixedGrubTarget))
+            disk = getDiskPart(stage1Devs[0].name, anaconda.storage)[0]
+            fixedGrubTarget = anaconda.storage.devicetree.getDeviceByName(disk)
+            log.info("Mdraid grub upgrade: %s -> %s" % (grubTarget.name,
+                                                        fixedGrubTarget.name))
     except ValueError:
         log.warning("Can't decide mdraid grub upgrade fix, product: %s, version: %s" % (product, version))
 
@@ -147,13 +148,13 @@ def writeBootloader(anaconda):
         
         anaconda.bootloader.doUpgradeonly = 1
         if bootType == "GRUB":
-            if theDev.startswith('/dev/md'):
-                theDev = fixedMdraidGrubTarget(anaconda,
-                                               devicePathToName(theDev))
+            grubTarget = anaconda.storage.devicetree.getDeviceByPath(theDev)
+            if grubTarget.type == "mdarray":
+                grubTarget = fixedMdraidGrubTarget(anaconda, grubTarget)
             anaconda.bootloader.useGrubVal = 1
-            anaconda.bootloader.setDevice(devicePathToName(theDev))
+            anaconda.bootloader.setDevice(grubTarget.name)
         else:
-            anaconda.bootloader.doUpgradeOnly = 0    
+            anaconda.bootloader.doUpgradeOnly = 0
 
     w = anaconda.intf.waitWindow(_("Bootloader"), _("Installing bootloader."))
 
diff --git a/booty/x86.py b/booty/x86.py
index 3544736..9c176d0 100644
--- a/booty/x86.py
+++ b/booty/x86.py
@@ -41,12 +41,11 @@ class x86BootloaderInfo(efiBootloaderInfo):
     def setUseGrub(self, val):
         self.useGrubVal = val
 
-    def getPhysicalDevices(self, device):
+    def getPhysicalDevices(self, dev):
         # This finds a list of devices on which the given device name resides.
         # Accepted values for "device" are raid1 md devices (i.e. "md0"),
         # physical disks ("hda"), and real partitions on physical disks
         # ("hda1"). Anything else gets ignored.
-        dev = self.storage.devicetree.getDeviceByName(device)
         if dev.type == "mdarray":
             if dev.level != 1:
                 log.error("x86BootloaderInfo.getPhysicalDevices ignoring non "
@@ -59,7 +58,7 @@ class x86BootloaderInfo(efiBootloaderInfo):
         physicalDevices = []
         for dev in devs:
             if dev in self.storage.disks or dev.type == "partition":
-                physicalDevices.append(dev.name)
+                physicalDevices.append(dev)
             else:
                 log.error("x86BootloaderInfo.getPhysicalDevices ignoring %s" %
                           dev.name)
@@ -127,16 +126,18 @@ class x86BootloaderInfo(efiBootloaderInfo):
 
         args = "--stage2=/boot/grub/stage2 "
 
-        stage1Devs = self.getPhysicalDevices(grubTarget)
-        bootDevs = self.getPhysicalDevices(bootDev.name)
+        stage1Devs = self.getPhysicalDevices(
+                          self.storage.devicetree.getDeviceByName(grubTarget))
+        bootDevs = self.getPhysicalDevices(bootDev)
 
         installs = [(None,
-                     self.grubbyPartitionName(stage1Devs[0]),
-                     self.grubbyPartitionName(bootDevs[0]))]
+                     self.grubbyPartitionName(stage1Devs[0].name),
+                     self.grubbyPartitionName(bootDevs[0].name))]
 
         if bootDev.type == "mdarray":
 
-            matches = self.matchingBootTargets(stage1Devs, bootDevs)
+            matches = self.matchingBootTargets([d.name for d in stage1Devs],
+                                               [d.name for d in bootDevs])
 
             # If the stage1 target disk contains member of boot raid array (mbr
             # case) or stage1 target partition is member of boot raid array
@@ -161,7 +162,7 @@ class x86BootloaderInfo(efiBootloaderInfo):
 
                 # if target is mbr, we want to install also to mbr of other
                 # members, so extend the matching list
-                matches = self.addMemberMbrs(matches, bootDevs)
+                matches = self.addMemberMbrs(matches, [d.name for d in bootDevs])
                 for stage1Target, mdMemberBootPart in matches[1:]:
                     # prepare special device mapping corresponding to member removal
                     mdMemberBootDisk = getDiskPart(mdMemberBootPart, self.storage)[0]
@@ -225,8 +226,9 @@ class x86BootloaderInfo(efiBootloaderInfo):
 
         # keep track of which devices are used for the device.map
         usedDevs = set()
-        usedDevs.update(self.getPhysicalDevices(grubTarget))
-        usedDevs.update(self.getPhysicalDevices(bootDev.name))
+        usedDevs.update([d.name for d in self.getPhysicalDevices(
+                          self.storage.devicetree.getDeviceByName(grubTarget))])
+        usedDevs.update([d.name for d in self.getPhysicalDevices(bootDev)])
         usedDevs.update([dev for (label, longlabel, dev) in chainList if longlabel])
 
         if not upgrade:
@@ -238,7 +240,7 @@ class x86BootloaderInfo(efiBootloaderInfo):
     def writeGrubConf(self, instRoot, bootDev, rootDev, defaultDev, kernelList,
                       chainList, grubTarget, grubPath, cfPath):
 
-        bootDevs = self.getPhysicalDevices(bootDev.name)
+        bootDevs = self.getPhysicalDevices(bootDev)
 
         # XXX old config file should be read here for upgrade
 
@@ -266,7 +268,7 @@ class x86BootloaderInfo(efiBootloaderInfo):
             f.write("#          all kernel and initrd paths are relative "
                     "to /, eg.\n")            
         
-        f.write('#          root %s\n' % self.grubbyPartitionName(bootDevs[0]))
+        f.write('#          root %s\n' % self.grubbyPartitionName(bootDevs[0].name))
         f.write("#          kernel %svmlinuz-version ro root=%s\n" % (cfPath, rootDev.path))
         f.write("#          initrd %sinitrd-[generic-]version.img\n" % (cfPath))
         f.write("#boot=/dev/%s\n" % (grubTarget))
@@ -309,7 +311,7 @@ class x86BootloaderInfo(efiBootloaderInfo):
             # we only want splashimage if they're not using a serial console
             if os.access("%s/boot/grub/splash.xpm.gz" %(instRoot,), os.R_OK):
                 f.write('splashimage=%s%sgrub/splash.xpm.gz\n'
-                        % (self.grubbyPartitionName(bootDevs[0]), cfPath))
+                        % (self.grubbyPartitionName(bootDevs[0].name), cfPath))
                 f.write("hiddenmenu\n")
 
             
@@ -323,7 +325,7 @@ class x86BootloaderInfo(efiBootloaderInfo):
             initrd = self.makeInitrd(kernelTag, instRoot)
 
             f.write('title %s (%s)\n' % (longlabel, version))
-            f.write('\troot %s\n' % self.grubbyPartitionName(bootDevs[0]))
+            f.write('\troot %s\n' % self.grubbyPartitionName(bootDevs[0].name))
 
             realroot = " root=%s" % rootDev.fstabSpec
 
-- 
1.7.0.1

_______________________________________________
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