[master 1/1] Add basic support for LVM cache creation in kickstart

vpodzime installerbot-noreply at redhat.com
Fri Jul 31 11:35:44 UTC 2015


From: Vratislav Podzimek <vpodzime at redhat.com>

If user specifies we should create an LV as a cached LV, we need to transform
the parameters in to a CacheRequest instance and pass it to blivet to create a
new LV as cached.
---
 pyanaconda/kickstart.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py
index 31c5382..1043c9a 100644
--- a/pyanaconda/kickstart.py
+++ b/pyanaconda/kickstart.py
@@ -21,7 +21,7 @@
 from pyanaconda.errors import ScriptError, errorHandler
 from blivet.deviceaction import ActionCreateFormat, ActionDestroyFormat, ActionResizeDevice, ActionResizeFormat
 from blivet.devices import LUKSDevice
-from blivet.devices.lvm import LVMVolumeGroupDevice
+from blivet.devices.lvm import LVMVolumeGroupDevice, CacheRequest
 from blivet.devicelibs.lvm import LVM_PE_SIZE, KNOWN_THPOOL_PROFILES
 from blivet.devicelibs.crypto import MIN_CREATE_ENTROPY
 from blivet.formats import getFormat
@@ -1005,6 +1005,15 @@ def execute(self, storage, ksdata, instClass):
             else:
                 maxsize = None
 
+            if self.cache_size and self.cache_pvs:
+                pv_devices = (lookupAlias(devicetree, pv) for pv in self.cache_pvs)
+                pv_devices_names = [pv.name for pv in pv_devices]
+                cache_size = Size("%d MiB" % self.cache_size)
+                cache_mode = self.cache_mode or None
+                cache_request = CacheRequest(cache_size, pv_devices_names, cache_mode)
+            else:
+                cache_request = None
+
             try:
                 request = storage.newLV(fmt=fmt,
                                     name=self.name,
@@ -1015,6 +1024,7 @@ def execute(self, storage, ksdata, instClass):
                                     grow=self.grow,
                                     maxsize=maxsize,
                                     percent=self.percent,
+                                    cacheRequest=cache_request,
                                     **pool_args)
             except (StorageError, ValueError) as e:
                 raise KickstartValueError(formatErrorMsg(self.lineno, msg=str(e)))


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/e8665c2957bc997102795eb449aa7183eb100955


More information about the anaconda-patches mailing list