[PATCH 1/3] Work with free region sizes instead of parted.Geometry objects

Vratislav Podzimek vpodzime at redhat.com
Wed Sep 17 07:14:16 UTC 2014


Related: rhbz#978266
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 blivet/partitioning.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/blivet/partitioning.py b/blivet/partitioning.py
index 6dff28f..dd60bf4 100644
--- a/blivet/partitioning.py
+++ b/blivet/partitioning.py
@@ -125,17 +125,17 @@ def _schedulePartitions(storage, disks):
     """
     # basis for requests with requiredSpace is the sum of the sizes of the
     # two largest free regions
-    all_free = getFreeRegions(disks)
-    all_free.sort(key=lambda f: f.length, reverse=True)
+    all_free = (Size(reg.getLength(unit="B")) for reg in getFreeRegions(disks))
+    all_free = sorted(all_free, reverse=True)
     if not all_free:
         # this should never happen since we've already filtered the disks
         # to those with at least 500MiB free
         log.error("no free space on disks %s", [d.name for d in disks])
         return
 
-    free = Size(all_free[0].getLength(unit="B"))
+    free = all_free[0]
     if len(all_free) > 1:
-        free += Size(all_free[1].getLength(unit="B"))
+        free += all_free[1]
 
     # The boot disk must be set at this point. See if any platform-specific
     # stage1 device we might allocate already exists on the boot disk.
@@ -191,7 +191,7 @@ def _schedulePartitions(storage, disks):
                 log.debug("%s", stage1_device)
                 continue
 
-        if request.size > Size(all_free[0].getLength("B")):
+        if request.size > all_free[0]:
             # no big enough free space for the requested partition
             raise NotEnoughFreeSpaceError(_("No big enough free space on disks for "
                                             "automatic partitioning"))
-- 
1.9.3



More information about the anaconda-patches mailing list