diff options
author | David Lehman <dlehman@redhat.com> | 2012-07-23 11:21:36 -0500 |
---|---|---|
committer | David Lehman <dlehman@redhat.com> | 2012-08-13 11:54:03 -0500 |
commit | 5494a2c4e62d743f435afe9039e6a420589a241e (patch) | |
tree | 33a28469cb1838373ecb72462606e7952c810b6e | |
parent | 56e2e6ee688127e3cd25b455e5a43382d9a9472e (diff) | |
download | anaconda-5494a2c4e62d743f435afe9039e6a420589a241e.tar.gz anaconda-5494a2c4e62d743f435afe9039e6a420589a241e.tar.xz anaconda-5494a2c4e62d743f435afe9039e6a420589a241e.zip |
Add a method to estimate disk space needs for a new logical volume.
Also moves default extent size and default pv metadata size to a
constant defined in devicelibs.lvm until we get a way to query
lvm for this stuff.
-rw-r--r-- | pyanaconda/storage/devicelibs/lvm.py | 15 | ||||
-rw-r--r-- | pyanaconda/storage/devices.py | 2 | ||||
-rw-r--r-- | pyanaconda/storage/formats/lvmpv.py | 2 |
3 files changed, 17 insertions, 2 deletions
diff --git a/pyanaconda/storage/devicelibs/lvm.py b/pyanaconda/storage/devicelibs/lvm.py index 136168b91..fedba99df 100644 --- a/pyanaconda/storage/devicelibs/lvm.py +++ b/pyanaconda/storage/devicelibs/lvm.py @@ -36,6 +36,10 @@ _ = lambda x: gettext.ldgettext("anaconda", x) MAX_LV_SLOTS = 256 +# some of lvm's defaults that we have no way to ask it for +LVM_PE_START = 1.0 # MB +LVM_PE_SIZE = 4.0 # MB + def has_lvm(): if iutil.find_program_in_path("lvm"): for line in open("/proc/devices").readlines(): @@ -143,6 +147,17 @@ def clampSize(size, pesize, roundup=None): return long(round(float(size)/float(pesize)) * pesize) +def get_pv_space(size, disks, pesize=LVM_PE_SIZE, + striped=False, mirrored=False): + """ Given specs for an LV, return total PV space required. """ + # XXX default extent size should be something we can ask of lvm + # TODO: handle striped and mirrored + # this is adding one extent for the lv's metadata + space = clampSize(size, pesize, roundup=True) + \ + (LVM_PE_START * disks) + \ + pesize + return space + def lvm(args): ret = iutil.execWithRedirect("lvm", args, stdout = "/dev/tty5", diff --git a/pyanaconda/storage/devices.py b/pyanaconda/storage/devices.py index 8fef3d168..c7b215aa1 100644 --- a/pyanaconda/storage/devices.py +++ b/pyanaconda/storage/devices.py @@ -2023,7 +2023,7 @@ class LVMVolumeGroupDevice(DMDevice): # TODO: validate peSize if given if not self.peSize: - self.peSize = 32.0 # MB + self.peSize = lvm.LVM_PE_SIZE # MB if not self.exists: self.pvCount = len(self.parents) diff --git a/pyanaconda/storage/formats/lvmpv.py b/pyanaconda/storage/formats/lvmpv.py index 994561e68..99aadb75e 100644 --- a/pyanaconda/storage/formats/lvmpv.py +++ b/pyanaconda/storage/formats/lvmpv.py @@ -65,7 +65,7 @@ class LVMPhysicalVolume(DeviceFormat): self.vgUuid = kwargs.get("vgUuid") # liblvm may be able to tell us this at some point, even # for not-yet-created devices - self.peStart = kwargs.get("peStart", 1.0) # in MB + self.peStart = kwargs.get("peStart", lvm.LVM_PE_START) # in MB self.inconsistentVG = False |