summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--autopart.py9
-rw-r--r--iw/partition_gui.py6
-rw-r--r--partRequests.py2
-rw-r--r--partedUtils.py7
-rw-r--r--partitions.py6
5 files changed, 12 insertions, 18 deletions
diff --git a/autopart.py b/autopart.py
index d98af90f7..3f7a35c38 100644
--- a/autopart.py
+++ b/autopart.py
@@ -119,8 +119,7 @@ def bootAlphaCheckRequirements(part):
if free.type & parted.PARTITION_FREESPACE:
break
free = disk.next_partition(free)
- if (not free or free.geom.start != 1L or
- partedUtils.getPartSizeMB(free) < 1):
+ if (not free or free.geom.start != 1L or free.getSize(unit="MB") < 1):
return BOOTALPHA_NO_RESERVED_SPACE
return PARTITION_SUCCESS
@@ -137,7 +136,7 @@ def printNewRequestsCyl(diskset, newRequest):
## partedUtils.end_sector_to_cyl(part.geom.dev, part.geom.end)))
def printFreespaceitem(part):
- return partedUtils.get_partition_name(part), part.geom.start, part.geom.end, partedUtils.getPartSizeMB(part)
+ return partedUtils.get_partition_name(part), part.geom.start, part.geom.end, part.getSize(unit="MB")
def printFreespace(free):
print("Free Space Summary:")
@@ -180,7 +179,7 @@ class partlist:
def __str__(self):
retval = ""
for p in self.parts:
- retval = retval + "\t%s %s %s\n" % (partedUtils.get_partition_name(p), partedUtils.get_partition_file_system_type(p), partedUtils.getPartSizeMB(p))
+ retval = retval + "\t%s %s %s\n" % (partedUtils.get_partition_name(p), partedUtils.get_partition_file_system_type(p), p.getSize(unit="MB"))
return retval
@@ -379,7 +378,7 @@ def fitSized(diskset, requests, primOnly = 0, newParts = None):
continue
lvmLog.debug( "Trying partition %s" % (printFreespaceitem(part),))
- partSize = partedUtils.getPartSizeMB(part)
+ partSize = part.getSize(unit="MB")
# figure out what the request size will be given the
# geometry (#130885)
requestSectors = long((request.requestSize * 1024L * 1024L) / part.disk.dev.sector_size) - 1
diff --git a/iw/partition_gui.py b/iw/partition_gui.py
index 5bf359e1e..4b4375150 100644
--- a/iw/partition_gui.py
+++ b/iw/partition_gui.py
@@ -146,7 +146,7 @@ class DiskStripeSlice:
rc = "Free\n"
else:
rc = "%s\n" % (get_partition_name(self.partition),)
- rc = rc + "%Ld MB" % (getPartSizeMB(self.partition),)
+ rc = rc + "%Ld MB" % (self.partition.getSize(unit="MB"),)
return rc
def getDeviceName(self):
@@ -835,7 +835,7 @@ class PartitionWindow(InstallWindow):
part = disk.next_partition(part)
continue
# ignore the tiny < 1 MB partitions (#119479)
- if getPartSizeMB(part) <= 1.0:
+ if part.getSize(unit="MB") <= 1.0:
if not part.is_active() or not part.get_flag(parted.PARTITION_BOOT):
part = disk.next_partition(part)
continue
@@ -945,7 +945,7 @@ class PartitionWindow(InstallWindow):
part.geom.start))
self.tree[iter]['End'] = str(end_sector_to_cyl(disk.dev,
part.geom.end))
- size = getPartSizeMB(part)
+ size = part.getSize(unit="MB")
if size < 1.0:
sizestr = "< 1"
else:
diff --git a/partRequests.py b/partRequests.py
index 891afdf1f..fc108f218 100644
--- a/partRequests.py
+++ b/partRequests.py
@@ -521,7 +521,7 @@ class PartitionSpec(RequestSpec):
if not part:
# XXX kickstart might still call this before allocating the partitions
raise RuntimeError, "Checking the size of a partition which hasn't been allocated yet"
- return partedUtils.getPartSizeMB(part)
+ return part.getSize(unit="MB")
def doSizeSanityCheck(self):
"""Sanity check that the size of the partition is sane."""
diff --git a/partedUtils.py b/partedUtils.py
index 04f579486..a1633ecc6 100644
--- a/partedUtils.py
+++ b/partedUtils.py
@@ -70,11 +70,6 @@ def getPartSize(partition):
"""Return the size of partition in sectors."""
return partition.geom.length
-def getPartSizeMB(partition):
- """Return the size of partition in megabytes."""
- return (partition.geom.length * partition.geom.dev.sector_size
- / 1024.0 / 1024.0)
-
def getMaxAvailPartSizeMB(part):
"""Return the maximum size this partition can grow to by looking
at contiguous freespace partitions."""
@@ -149,7 +144,7 @@ def get_partition_file_system_type(part):
elif part.fs_type == None:
return None
elif (part.get_flag(parted.PARTITION_BOOT) == 1 and
- getPartSizeMB(part) <= 1 and part.fs_type.name == "hfs"):
+ part.getSize(unit="MB") <= 1 and part.fs_type.name == "hfs"):
ptype = fsset.fileSystemTypeGet("Apple Bootstrap")
elif part.fs_type.name == "linux-swap":
ptype = fsset.fileSystemTypeGet("swap")
diff --git a/partitions.py b/partitions.py
index 04c69fcfe..61fb04d0d 100644
--- a/partitions.py
+++ b/partitions.py
@@ -422,7 +422,7 @@ class Partitions:
start = part.geom.start
end = part.geom.end
- size = partedUtils.getPartSizeMB(part)
+ size = part.getSize(unit="MB")
drive = partedUtils.get_partition_drive(part)
spec = partRequests.PreexistingPartitionSpec(ptype,
@@ -806,7 +806,7 @@ class Partitions:
break
if used:
break
- size = partedUtils.getPartSizeMB(part)
+ size = part.getSize(unit="MB")
if not used:
rc.append((partname, size, 0))
@@ -932,7 +932,7 @@ class Partitions:
if size is None:
# if we get here, there's no PV data in the partition,
# so clamp the partition's size to 64M
- size = partedUtils.getPartSizeMB(part)
+ size = part.getSize(unit="MB")
size = lvm.clampPVSize(size, 65536)
if used == 0: