[pykickstart][PATCH 1/3] Add support for custom layouts using lvm thinp.
David Lehman
dlehman at redhat.com
Tue Jan 27 18:10:29 UTC 2015
This adds options to the logvol command. Support for thinp autopart is
not included.
(cherry picked from commit b455a512ccf4bbb84e1ab0ba66c44b59537aa1d3)
Related: rhbz#1083459
---
pykickstart/commands/logvol.py | 42 ++++++++++++++++++++++++++++++++++++++++++
tests/commands/logvol.py | 30 ++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+)
diff --git a/pykickstart/commands/logvol.py b/pykickstart/commands/logvol.py
index 6a7f62f..4f20ad3 100644
--- a/pykickstart/commands/logvol.py
+++ b/pykickstart/commands/logvol.py
@@ -170,6 +170,12 @@ class RHEL6_LogVolData(F12_LogVolData):
self.cipher = kwargs.get("cipher", "")
self.hibernation = kwargs.get("hibernation", False)
+ self.thin_pool = kwargs.get("thin_pool", False)
+ self.thin_volume = kwargs.get("thin_volume", False)
+ self.pool_name = kwargs.get("pool_name", "")
+ self.chunk_size = kwargs.get("chunk_size", None) # kilobytes
+ self.metadata_size = kwargs.get("metadata_size", None) # megabytes
+
def _getArgsAsStr(self):
retval = F12_LogVolData._getArgsAsStr(self)
@@ -178,6 +184,19 @@ class RHEL6_LogVolData(F12_LogVolData):
if self.hibernation:
retval += " --hibernation"
+ # these are only for thin pools
+ if self.thin_pool:
+ retval += " --thinpool"
+
+ if self.metadata_size:
+ retval += " --metadatasize=%d" % self.metadata_size
+
+ if self.chunk_size:
+ retval += " --chunksize=%d" % self.chunk_size
+
+ if self.thin_volume:
+ retval += " --thin --poolname=%s" % self.pool_name
+
return retval
class FC3_LogVol(KickstartCommand):
@@ -297,6 +316,13 @@ class RHEL6_LogVol(F12_LogVol):
op.add_option("--hibernation", dest="hibernation", action="store_true",
default=False)
+ op.add_option("--thinpool", action="store_true", dest="thin_pool",
+ default=False)
+ op.add_option("--thin", action="store_true", dest="thin_volume",
+ default=False)
+ op.add_option("--poolname", dest="pool_name")
+ op.add_option("--chunksize", type="int", dest="chunk_size")
+ op.add_option("--metadatasize", type="int", dest="metadata_size")
return op
def parse(self, args):
@@ -307,4 +333,20 @@ class RHEL6_LogVol(F12_LogVol):
if self.handler.autopart.currentCmd:
errorMsg = _("The logvol and autopart commands can't be used at the same time")
raise KickstartParseError, formatErrorMsg(self.lineno, msg=errorMsg)
+
+ if retval.thin_volume and retval.thin_pool:
+ errorMsg = _("--thin and --thinpool cannot both be specified for "
+ "the same logvol")
+ raise KickstartParseError, formatErrorMsg(self.lineno, msg=errorMsg)
+
+ if retval.thin_volume and not retval.pool_name:
+ errorMsg = _("--thin requires --poolname to specify pool name")
+ raise KickstartParseError, formatErrorMsg(self.lineno, msg=errorMsg)
+
+ if (retval.chunk_size or retval.metadata_size) and \
+ not retval.thin_pool:
+ errorMsg = _("--chunksize and --metadatasize are for thin pools only")
+ raise KickstartParseError, formatErrorMsg(self.lineno, msg=errorMsg)
+
return retval
+
diff --git a/tests/commands/logvol.py b/tests/commands/logvol.py
index 13f056d..5accb5a 100644
--- a/tests/commands/logvol.py
+++ b/tests/commands/logvol.py
@@ -252,5 +252,35 @@ class RHEL6_TestCase(F12_TestCase):
self.assert_parse("logvol swap --recommended --hibernation "
"--name=NAME --vgname=VGNAME")
+ # thinp
+ self.assert_parse("logvol none --name=pool1 --vgname=vg --thinpool",
+ "logvol none --thinpool --name=pool1 --vgname=vg\n")
+ self.assert_parse("logvol none --name=pool1 --vgname=vg --thinpool "
+ "--chunksize=512",
+ "logvol none --thinpool --chunksize=512 "
+ "--name=pool1 --vgname=vg\n")
+ self.assert_parse("logvol none --name=pool1 --vgname=vg --thinpool "
+ "--metadatasize=4 --chunksize=1024",
+ "logvol none --thinpool --metadatasize=4 "
+ "--chunksize=1024 --name=pool1 --vgname=vg\n")
+ self.assert_parse("logvol /home --name=home --vgname=vg "
+ "--thin --poolname=pool1",
+ "logvol /home --thin --poolname=pool1 "
+ "--name=home --vgname=vg\n")
+
+ # missing pool name
+ self.assert_parse_error("logvol /home --name=home --vgname=vg --thin")
+
+ # chunksize is an int
+ self.assert_parse_error("logvol none --name=pool1 --vgname=vg "
+ "--thinpool --chunksize=foo")
+
+ # both --thin and --thinpool
+ self.assert_parse_error("logvol /home --name=home --thin --thinpool --vgname=vg --size=10000")
+
+ # chunksize and/or metadata size and not thinpool
+ self.assert_parse_error("logvol none --name=pool1 --vgname=vg "
+ "--chunksize=512")
+
if __name__ == "__main__":
unittest.main()
--
1.9.3
More information about the anaconda-patches
mailing list