[PATCH 5/7] Update storage module for new platform and bootloader modules.

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

 



---
 pyanaconda/storage/__init__.py     |   33 +++++++++++++++++----------------
 pyanaconda/storage/partitioning.py |   30 ++++++++++++------------------
 2 files changed, 29 insertions(+), 34 deletions(-)

diff --git a/pyanaconda/storage/__init__.py b/pyanaconda/storage/__init__.py
index 11f2acf..f7947f3 100644
--- a/pyanaconda/storage/__init__.py
+++ b/pyanaconda/storage/__init__.py
@@ -35,6 +35,7 @@ from pyanaconda import iutil
 from pyanaconda.constants import *
 from pykickstart.constants import *
 from pyanaconda.flags import flags
+from pyanaconda import platform
 
 from errors import *
 from devices import *
@@ -187,19 +188,16 @@ def storageComplete(anaconda):
 
     # Warn the user if they are trying to boot a GPT disk on a non-EFI system
     # This may or may not work -- we have no way to tell, so just warn them
-    bootdisk = anaconda.bootloader.drivelist[0]
-    bootdisk = anaconda.storage.devicetree.getDeviceByName(bootdisk)
-
-    if not iutil.isEfi() and bootdisk and bootdisk.format \
-       and bootdisk.format.type == 'disklabel' \
-       and bootdisk.format.labelType == 'gpt':
-        warning = _("\n\n<b>WARNING:</b>\n"
-                    "You are using a GPT bootdisk on a non-EFI "
-                    "system. This may not work, depending on your BIOS's "
-                    "support for booting from GPT disks.")
-        log.warning("Using a GPT bootdisk on non-EFI system")
-    else:
-        warning = ""
+    warning = ""
+    if not isinstance(anaconda.platform, platform.EFI):
+        disks = (anaconda.bootloader.stage1_device.disks
+                 + anaconda.bootloader.stage2_device.disks)
+        if [d for d in disks if getattr(d.format, "labelType", None) == "gpt"]:
+            warning = _("\n\n<b>WARNING:</b>\n"
+                        "You are using a GPT bootdisk on a non-EFI "
+                        "system. This may not work, depending on your "
+                        "BIOS's support for booting from GPT disks.")
+            log.warning("Using a GPT bootdisk on non-EFI system")
 
     rc = anaconda.intf.messageWindow(_("Confirm"),
                                 _("The partitioning options you have selected "
@@ -375,7 +373,7 @@ class Storage(object):
 
         # now set the boot partition's flag
         try:
-            boot = self.platform.bootDevice()
+            boot = self.platform.bootDevice
             if boot.type == "mdarray":
                 bootDevs = boot.parents
             else:
@@ -460,6 +458,8 @@ class Storage(object):
            hasattr(self.anaconda, "upgradeRoot"):
             self.anaconda.rootParts = None
             self.anaconda.upgradeRoot = None
+        if self.platform:
+            self.platform.bootloader.clear_drive_list()
         self.dumpState("initial")
         if w:
             w.pop()
@@ -1055,7 +1055,7 @@ class Storage(object):
         root = self.fsset.rootDevice
         swaps = self.fsset.swapDevices
         try:
-            boot = self.platform.bootDevice()
+            boot = self.platform.bootDevice
         except (DeviceError, AttributeError):
             # AttributeError means we have no anaconda or platform. it's ok.
             boot = None
@@ -1144,7 +1144,8 @@ class Storage(object):
                               "or may not produce a working system."))
 
         if self.platform:
-            errors.extend(self.platform.checkBootRequest(boot))
+            errors.extend(self.platform.checkBootRequest())
+            errors.extend(self.platform.checkBootLoaderRequest())
 
         if not swaps:
             from pyanaconda.storage.size import Size
diff --git a/pyanaconda/storage/partitioning.py b/pyanaconda/storage/partitioning.py
index a699125..d83ed1b 100644
--- a/pyanaconda/storage/partitioning.py
+++ b/pyanaconda/storage/partitioning.py
@@ -94,7 +94,7 @@ def _schedulePartitions(storage, disks):
         if request.fstype is None:
             request.fstype = storage.defaultFSType
         elif request.fstype in ("prepboot", "efi") and \
-                storage.platform.bootDevice():
+                storage.platform.bootDevice:
             # there should never be a need for more than one of these
             # partitions, so skip them.
             continue
@@ -186,11 +186,11 @@ def doAutoPartition(anaconda):
     devs = []
 
     if anaconda.storage.doAutoPart:
-        clearPartitions(anaconda.storage)
+        clearPartitions(anaconda.storage, bootloader=anaconda.bootloader)
         # update the bootloader's drive list to add disks which have their
         # whole disk format replaced by a disklabel. Make sure to keep any
         # previous boot order selection from clearpart_gui or kickstart
-        anaconda.bootloader.updateDriveList(anaconda.bootloader.drivelist)
+        anaconda.bootloader.clear_drive_list()
 
     if anaconda.storage.doAutoPart:
         (disks, devs) = _createFreeSpacePartitions(anaconda.storage)
@@ -219,7 +219,7 @@ def doAutoPartition(anaconda):
 
     # run the autopart function to allocate and grow partitions
     try:
-        doPartitioning(anaconda.storage)
+        doPartitioning(anaconda.storage, bootloader=anaconda.bootloader)
 
         if anaconda.storage.doAutoPart:
             _scheduleLVs(anaconda.storage, devs)
@@ -332,8 +332,6 @@ def shouldClear(device, clearPartType, clearPartDisks=None):
     if device.immutable:
         return False
 
-    # TODO: do platform-specific checks on ia64, pSeries, iSeries, mac
-
     return True
 
 def clearPartitions(storage, bootloader=None):
@@ -345,7 +343,7 @@ def clearPartitions(storage, bootloader=None):
 
         Keyword arguments:
 
-            bootloader -- a bootloaderInfo instance
+            bootloader -- a BootLoader instance
 
         NOTES:
 
@@ -412,10 +410,10 @@ def clearPartitions(storage, bootloader=None):
     # make sure that the the boot device has the correct disklabel type if
     # we're going to completely clear it.
     for disk in storage.partitioned:
-        if not bootloader or not bootloader.drivelist:
+        if not bootloader or not bootloader.stage1_device:
             break
 
-        if disk.name != bootloader.drivelist[0]:
+        if disk in bootloader.stage1_device.disks:
             continue
 
         if storage.config.clearPartType != CLEARPART_TYPE_ALL or \
@@ -821,7 +819,7 @@ def doPartitioning(storage, bootloader=None):
 
         Keyword/Optional Arguments:
 
-            bootloader - bootloaderInfo instance
+            bootloader - BootLoader instance
 
     """
     if not hasattr(storage.platform, "diskLabelType"):
@@ -849,13 +847,11 @@ def doPartitioning(storage, bootloader=None):
             # start over with flexible-size requests
             part.req_size = part.req_base_size
 
-    # FIXME: isn't there a better place for this to happen?
     try:
-        bootDev = storage.platform.bootDevice()
+        bootDev = storage.platform.bootDevice
     except DeviceError:
-        bootDev = None
-
-    if bootDev:
+        pass
+    else:
         bootDev.req_bootable = True
 
     removeNewPartitions(disks, partitions)
@@ -966,9 +962,7 @@ def allocatePartitions(storage, disks, partitions, freespace, bootloader=None):
         req_disks.sort(key=lambda d: d.name, cmp=storage.compareDisks)
         boot_index = None
         for disk in req_disks:
-            if bootloader and \
-               disk.name in bootloader.drivelist and \
-               disk.name == bootloader.drivelist[0]:
+            if bootloader and disk == bootloader.stage1_device.disks[0]:
                 boot_index = req_disks.index(disk)
 
         if boot_index is not None and len(req_disks) > 1:
-- 
1.7.3.4

_______________________________________________
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