summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Katz <katzj@redhat.com>2007-11-28 17:21:41 -0500
committerJeremy Katz <katzj@redhat.com>2007-11-29 16:12:01 -0500
commitbd5b1fa617aa81e6dd475b3513158b9a1f917a5e (patch)
tree0e3f7a8c6fa3896580c33c8afb4c0e5477d81988
parenteaa319461a2b8bc8a717e4ef75e776148d13faf5 (diff)
downloadanaconda-bd5b1fa617aa81e6dd475b3513158b9a1f917a5e.tar.gz
anaconda-bd5b1fa617aa81e6dd475b3513158b9a1f917a5e.tar.xz
anaconda-bd5b1fa617aa81e6dd475b3513158b9a1f917a5e.zip
Add method for finding the available size that a partition can expand into
-rw-r--r--partedUtils.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/partedUtils.py b/partedUtils.py
index ea40a3b46..4adc0b9c7 100644
--- a/partedUtils.py
+++ b/partedUtils.py
@@ -97,6 +97,24 @@ def getDeviceSizeMB(dev):
return (float(dev.heads * dev.cylinders * dev.sectors) / (1024 * 1024)
* dev.sector_size)
+def getMaxAvailPartSizeMB(part):
+ """Return the maximum size this partition can grow to by looking
+ at contiguous freespace partitions."""
+
+ disk = part.disk
+ maxlen = part.geom.length
+
+ # let's look at the next partition(s) and if they're freespace,
+ # they can add to our maximum size.
+ np = disk.next_partition(part)
+ while np:
+ if np.type & parted.PARTITION_FREESPACE:
+ maxlen += np.geom.length
+ else:
+ break
+ np = disk.next_partition(np)
+ return math.floor(maxlen * part.geom.dev.sector_size / 1024.0 / 1024.0)
+
def get_partition_by_name(disks, partname):
"""Return the parted part object associated with partname.