[PATCH 03/30] New function to tell us if there is free space for a new partition.

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

 



* storage/partitioning.py (hasFreeDiskSpace): New function.
---
 storage/partitioning.py |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/storage/partitioning.py b/storage/partitioning.py
index d14a481..4bbc9bc 100644
--- a/storage/partitioning.py
+++ b/storage/partitioning.py
@@ -1080,6 +1080,38 @@ def growPartitions(disks, partitions):
             continue
         part.req_size = part.req_base_size
 
+def hasFreeDiskSpace(storage, exclusiveDisks=None):
+    """Returns True if there is at least 100Mb of free usable space in any of
+       the disks.  False otherwise.
+
+       This function is the 'same" as doPartitioning.  The only difference is
+       that it first allocates partitions, searches for free space, and then
+       grows partitions. First we allocate partitions without growing them
+       because it  will give us a state where we can search for the regon that
+       is greater than 100Mb in every disk.
+
+    """
+    retval = False
+    doPartitioning(storage, exclusiveDisks=exclusiveDisks, grow=False)
+
+    # FIXME : shouldn't this be in storage.disks?
+    disks = storage.disks
+    if exclusiveDisks:
+        disks = [d for d in disks if d.name in exclusiveDisks]
+
+    for disk in disks:
+        regs = disk.format.partedDisk.getFreeSpaceRegions()
+        for region in regs:
+            if region.getSize(unit="MB") > 100:
+                retval = True
+                break
+        if retval:
+            break
+
+    doPartitioning(storage, exclusiveDisks=exclusiveDisks, alloc=False)
+    return retval
+
+
 def lvCompare(lv1, lv2):
     """ More specifically defined lvs come first.
 
-- 
1.6.4.2

_______________________________________________
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