summaryrefslogtreecommitdiffstats
path: root/autopart.py
diff options
context:
space:
mode:
authorJeremy Katz <katzj@redhat.com>2007-11-28 17:39:46 -0500
committerJeremy Katz <katzj@redhat.com>2007-11-29 16:12:01 -0500
commit349d9984e997529e88dcfb686580a6443f7e705a (patch)
treea2dfbbb7557973735a113cda364c5b15da6c820c /autopart.py
parentbd5b1fa617aa81e6dd475b3513158b9a1f917a5e (diff)
downloadanaconda-349d9984e997529e88dcfb686580a6443f7e705a.tar.gz
anaconda-349d9984e997529e88dcfb686580a6443f7e705a.tar.xz
anaconda-349d9984e997529e88dcfb686580a6443f7e705a.zip
Add infrastructure for partition resizing
We add support to preexisting partitions to be resized by adjusting their partition spec and then acting on the changes within the main partitioning engine. Keep track of what the maximum size for a preexisting partitition is so that we don't have to check in the UI Filesystems can claim to be resizable and implement the resize() method as well as the getMinimumSize() method
Diffstat (limited to 'autopart.py')
-rw-r--r--autopart.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/autopart.py b/autopart.py
index b5b517542..f67019aa3 100644
--- a/autopart.py
+++ b/autopart.py
@@ -870,6 +870,23 @@ def setPreexistParts(diskset, requests):
part = disk.next_partition()
while part:
if part.geom.start == request.start and part.geom.end == request.end:
+ # if the partition is being resized, we do that now
+ if request.targetSize is not None:
+ startSec = part.geom.start
+ endSec = part.geom.start + long(((request.targetSize * 1024L * 1024L) / disk.dev.sector_size)) - 1
+
+ try:
+ g = part.geom.duplicate()
+ g.set_end(endSec)
+ constraint = g.constraint_exact()
+ part.set_geometry(constraint, startSec, endSec)
+ except parted.error, msg:
+ log.error("error setting geometry for partition %s: %s" %(partedUtils.get_partition_name(part), msg))
+ raise PartitioningError, _("Error resizing partition %s.\n\n%s") %(partedUtils.get_partition_name(part), msg)
+
+ if startSec != part.geom.start:
+ raise PartitioningError, _("Start of partition %s was moved when resizing") %(partedUtils.get_partition_name(part),)
+
request.device = partedUtils.get_partition_name(part)
if request.fstype:
if request.fstype.getName() != request.origfstype.getName():
@@ -992,13 +1009,18 @@ def processPartitioning(diskset, requests, newParts):
for request in requests.requests:
if request.type == REQUEST_RAID:
request.size = request.getActualSize(requests, diskset)
- if request.type == REQUEST_VG:
+ elif request.type == REQUEST_VG:
request.size = request.getActualSize(requests, diskset)
- if request.type == REQUEST_LV:
+ elif request.type == REQUEST_LV:
if request.grow:
request.setSize(request.getStartSize())
else:
request.size = request.getActualSize(requests, diskset)
+ elif request.preexist:
+ # we need to keep track of the max size of preexisting partitions
+ # FIXME: we should also get the max size for LVs at some point
+ part = partedUtils.get_partition_by_name(diskset.disks, request.device)
+ request.maxResizeSize = partedUtils.getMaxAvailPartSizeMB(part)
## print "disk layout after everything is done"
## print diskset.diskState()