[PATCH 02/21] Add a method to estimate disk space needs for a new logical volume.
David Lehman
dlehman at redhat.com
Thu Aug 9 19:28:21 UTC 2012
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.
---
pyanaconda/storage/devicelibs/lvm.py | 15 +++++++++++++++
pyanaconda/storage/devices.py | 2 +-
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 136168b..fedba99 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 c99c3c2..795ff49 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 994561e..99aadb7 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
--
1.7.7.6
More information about the anaconda-patches
mailing list