summaryrefslogtreecommitdiffstats
path: root/partRequests.py
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2005-01-21 18:31:39 +0000
committerPeter Jones <pjones@redhat.com>2005-01-21 18:31:39 +0000
commitcc9d0f4e57b11a37fc5d33d0374509e43a97840c (patch)
treee224c5b5169ce0f8f064c57663dcd662efb507e6 /partRequests.py
parent15eca51f972e5f757f6f35b87b2cf3348d0c128c (diff)
downloadanaconda-cc9d0f4e57b11a37fc5d33d0374509e43a97840c.tar.gz
anaconda-cc9d0f4e57b11a37fc5d33d0374509e43a97840c.tar.xz
anaconda-cc9d0f4e57b11a37fc5d33d0374509e43a97840c.zip
* lvm.py (lvlist): return size in MB.
* lvm.py (pvlist): return size in MB. * lvm.py (vglist): return size in MB, and pesize in KB. * lvm.py (clampLVSizeRequest): use math.ceil and math.floor for "roundup", so we don't need to special case "size % pe == 0" * lvm.py (clampPVSize): replace the completely broken code that fails to implement a size heuristic for lvm1. We still need to guess at the available size, but not here. * partRequest.py: add PartitionSpec.getPVSize, which returns a size for a Physical Volume given a partition. If there's no PV in the real partition, it guesses the size based on the free space. Make VolumeGroupRequestSpec.getActualSize use PartitonSpec.getPVSize instead of PartitionSpec.getActualSize * partitions.py: make Partitions.setFromDisk use the PE size from the volume group, so we don't give the wrong pesize to clamp later and create an LV with an invalid size. Also make it handle lv size in MB. make Partitions.getAvailLVMPartitions use the PV's size, not the partition's size. It'll estimate the size from the partition's size if there's no LV created yet. * iw/lvm_dialog_gui.py: use getPVSize instead of getActualSize for LVM physical volume sizes.
Diffstat (limited to 'partRequests.py')
-rw-r--r--partRequests.py35
1 files changed, 34 insertions, 1 deletions
diff --git a/partRequests.py b/partRequests.py
index 3af554c21..e560e35eb 100644
--- a/partRequests.py
+++ b/partRequests.py
@@ -466,6 +466,39 @@ class PartitionSpec(RequestSpec):
raise RuntimeError, "Checking the size of a partition which hasn't been allocated yet"
return partedUtils.getPartSizeMB(part)
+ def getPVSize(self, partitions, diskset):
+ """Return the size of the physical volume in the request in megabytes."""
+
+ part = partedUtils.get_partition_by_name(diskset.disks, self.device)
+ 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"
+
+ for pvpart, pvvg, pvsize in lvm.pvlist():
+ if pvpart == "/dev/%s" % (self.device):
+ size = pvsize
+ return size;
+
+ # If we get here, the PV and/or VG hasn't been created yet, so we
+ # have to guess.
+
+ # you can't tell what the size of a PV until you've created a volume
+ # group, because the PV uses a PE to store metadata in, and it's
+ # got no PEs until there's a VG. So until you put something IN
+ # a PV, it has undefined size. Brilliant.
+ #
+ # From looking at what happens if we create it, we basically always
+ # use 1 PE. So right now, I'm assuming 64M PEs, since they're the
+ # biggest we create.
+ #
+ # The big downside here is that if the user chooses 4M, at this point
+ # he's losing 60M to 64M of space. I _think_ he'll actually get this
+ # back as soon as it's created though, since we don't give a max size
+ # to vgcreate, and we call getPVSize pretty often.
+ size = self.getActualSize(partitions, diskset)
+ size = long((math.floor(size / 64)-1) * 64)
+ return size
+
def doSizeSanityCheck(self):
"""Sanity check that the size of the partition is sane."""
if not self.fstype:
@@ -770,7 +803,7 @@ class VolumeGroupRequestSpec(RequestSpec):
totalspace = 0
for pvid in self.physicalVolumes:
pvreq = partitions.getRequestByID(pvid)
- size = pvreq.getActualSize(partitions, diskset)
+ size = pvreq.getPVSize(partitions, diskset)
size = lvm.clampPVSize(size, self.pesize)
totalspace = totalspace + size