diff options
-rw-r--r-- | autopart.py | 33 | ||||
-rw-r--r-- | iw/partition_gui.py | 18 | ||||
-rw-r--r-- | partitioning.py | 33 |
3 files changed, 51 insertions, 33 deletions
diff --git a/autopart.py b/autopart.py index 4843c25ad..c13ae2a58 100644 --- a/autopart.py +++ b/autopart.py @@ -154,7 +154,7 @@ def fitSized(diskset, requests, primOnly = 0): for part in free[drive]: partSize = getPartSize(part) if partSize >= request.requestSize and partSize > largestPart[0]: - if not request.primary or (part.type & parted.PARTITION_PRIMARY): + if not request.primary or (not part.type & parted.PARTITION_LOGICAL): largestPart = (partSize, part) if not largestPart[1]: @@ -261,6 +261,8 @@ def growParts(diskset, requests): max = int(percent * freeSize[drive]) + request.size if max > request.maxSize: max = request.maxSize + if max > request.fstype.getMaxSize(): + max = request.fstype.getMaxSize() min = request.requestSize diff = max - min @@ -325,11 +327,6 @@ def processPartitioning(diskset, requests): if request.type == REQUEST_NEW: request.device = None - # set the unique identifier for raid devices - if request.type == REQUEST_RAID and not request.device: - request.device = str(requests.maxcontainer) - requests.maxcontainer = requests.maxcontainer + 1 - # XXX - handle delete requests for delete in requests.deletes: deletePart(diskset, delete) @@ -361,26 +358,34 @@ def processPartitioning(diskset, requests): # run through with primary only constraints first ret = fitConstrained(diskset, requests, 1) if ret == PARTITION_FAIL: - return ret + return (ret, "Could not allocate cylinder-based partitions as primary partitions") ret = fitSized(diskset, requests, 1) if ret == PARTITION_FAIL: - return ret + return (ret, "Could not allocate partitions as primary partitions") ret = fitConstrained(diskset, requests) if ret == PARTITION_FAIL: - return ret + return (ret, "Could not allocate cylinder-based partitions") ret = fitSized(diskset, requests) if ret == PARTITION_FAIL: - return ret + return (ret, "Could not allocate partitions") for request in requests.requests: - if request.type != REQUEST_RAID and not request.device: + # set the unique identifier for raid devices + if request.type == REQUEST_RAID and not request.device: + request.device = str(requests.maxcontainer) + requests.maxcontainer = requests.maxcontainer + 1 + + if request.type == REQUEST_RAID: + request.size = get_raid_device_size(request) + + if not request.device: # return PARTITION_FAIL raise PartitioningError, "Unsatisfied partition request\n%s" %(request) - return PARTITION_SUCCESS + return (PARTITION_SUCCESS, "success") ## print "disk layout after everything is done" ## print diskset.diskState() @@ -390,10 +395,10 @@ def doPartitioning(diskset, requests): for request in requests.requests: request.requestSize = request.size - ret = processPartitioning(diskset, requests) + (ret, msg) = processPartitioning(diskset, requests) if ret == PARTITION_FAIL: - raise PartitioningError, "Partitioning failed" + raise PartitioningError, "Partitioning failed: %s" %(msg) ret = growParts(diskset, requests) diff --git a/iw/partition_gui.py b/iw/partition_gui.py index 7d386fe83..178bc7323 100644 --- a/iw/partition_gui.py +++ b/iw/partition_gui.py @@ -34,6 +34,10 @@ TREE_SPACING = 2 MODE_ADD = 1 MODE_EDIT = 2 +# XXX this is made up and used by the size spinner; should just be set with +# a callback +MAX_PART_SIZE = 1024*1024*1024 + class DiskStripeSlice: def eventHandler(self, widget, event): if event.type == GDK.BUTTON_PRESS: @@ -282,6 +286,20 @@ def fstypechangeCB(widget, mountCombo): mountCombo.entry.set_text(_("<Not Applicable>")) mountCombo.set_sensitive(0) + # XXX hrmm... we need to get these passed into the callback somehow +## # XXX ugly, there has to be a better way +## adj = maxSizeSpinner.get_adjustment() +## adj.set_all(adj.value, size, fstype.getMaxSize(), +## adj.step_increment, adj.page_increment, +## adj.page_size) +## maxSizeSpinner.set_adjustment(adj) + +## adj = sizeSpinner.get_adjustment() +## adj.set_all(adj.value, size, fstype.getMaxSize(), +## adj.step_increment, adj.page_increment, +## adj.page_size) +## sizeSpinner.set_adjustment(adj) + def createAllowedDrivesClist(drives, reqdrives): driveclist = GtkCList() driveclist.set_selection_mode (SELECTION_MULTIPLE) diff --git a/partitioning.py b/partitioning.py index ae637b80e..2b4442dd8 100644 --- a/partitioning.py +++ b/partitioning.py @@ -34,11 +34,6 @@ REQUEST_PREEXIST = 1 REQUEST_NEW = 2 REQUEST_RAID = 4 -# max partition size in kB -# XXX these are just made up, need to get real values from parted! -MAX_PART_SIZE = 1024*1024*1024 -MAX_SWAP_PART_SIZE_KB = 2147483640/1024 - fsTypes = {} fs_type = parted.file_system_type_get_next () @@ -272,25 +267,21 @@ def doMountPointLinuxFSChecks(newrequest): return _("This mount point is invalid. This directory must " "be on the / filesystem.") - elif newrequest.fstype.getName() == "swap": - if newrequest.type == REQUEST_RAID: - swapsize = get_raid_device_size(newrequest) - else: - swapsize = newrequest.size - - print "swapsize ->",swapsize - - if swapsize / 1024 > MAX_SWAP_PART_SIZE_KB: - return _("This swap partition exceeds the maximum size of " - "%s MB.") % (MAX_SWAP_PART_SIZE_KB / 1024) - else: - return None else: if newrequest.mountpoint in mustbeonlinuxfs: return _("This mount point must be on a linux filesystem.") return None +def doPartitionSizeCheck(newrequest): + if not newrequest.fstype: + return None + + # XXX need to figure out the size for partitions specified by cyl range + if newrequest.size and newrequest.size > newrequest.fstype.getMaxSize(): + return _("This %s partition exceeds the maximum size of %s MB.") %(newrequest.fstype.getName(), newrequest.fstype.getMaxSize()) + else: + return None # returns error string if something not right about request @@ -300,6 +291,10 @@ def sanityCheckPartitionRequest(reqpartitions, newrequest): fstype = newrequest.fstype reqtype = newrequest.type + rc = doPartitionSizeCheck(newrequest) + if rc: + return rc + rc = sanityCheckMountPoint(mntpt, fstype, reqtype) if rc: return rc @@ -342,9 +337,9 @@ def sanityCheckRaidRequest(reqpartitions, newraid): return _("This RAID device can have a maximum of %s spares. " "To have more spares you will need to add members to " "the RAID device.") % (len(newraid.raidmembers) - minmembers ) - return None + class DeleteSpec: def __init__(self, drive, start, end): self.drive = drive |