[PATCH][pykickstart] Add support for lvm thin provisioning.
Vratislav Podzimek
vpodzime at redhat.com
Wed Jun 26 10:11:17 UTC 2013
On Tue, 2013-06-25 at 15:41 -0500, David Lehman wrote:
> This adds a new autopart type and options to the logvol command.
> ---
> pykickstart/commands/autopart.py | 18 ++++++++------
> pykickstart/commands/logvol.py | 54 ++++++++++++++++++++++++++++++++++++++++
> pykickstart/constants.py | 1 +
> pykickstart/handlers/control.py | 10 ++++----
> tests/commands/autopart.py | 2 ++
> tests/commands/logvol.py | 34 +++++++++++++++++++++++++
> 6 files changed, 107 insertions(+), 12 deletions(-)
>
> diff --git a/pykickstart/commands/autopart.py b/pykickstart/commands/autopart.py
> index c31e014..308ff25 100644
> --- a/pykickstart/commands/autopart.py
> +++ b/pykickstart/commands/autopart.py
> @@ -184,7 +184,8 @@ class F17_AutoPart(F16_AutoPart):
> self.typeMap = { "lvm": AUTOPART_TYPE_LVM,
> "btrfs": AUTOPART_TYPE_BTRFS,
> "plain": AUTOPART_TYPE_PLAIN,
> - "partition": AUTOPART_TYPE_PLAIN }
> + "partition": AUTOPART_TYPE_PLAIN,
> + "thinp": AUTOPART_TYPE_LVM_THINP }
>
> def __str__(self):
> retval = F16_AutoPart.__str__(self)
> @@ -195,12 +196,10 @@ class F17_AutoPart(F16_AutoPart):
> # remove any trailing newline
> retval = retval.strip()
> retval += " --type="
> - if self.type == AUTOPART_TYPE_LVM:
> - retval += "lvm"
> - elif self.type == AUTOPART_TYPE_BTRFS:
> - retval += "btrfs"
> - else:
> - retval += "plain"
> + for s, n in self.typeMap.items():
> + if self.type == n:
> + retval += s
> + break
> retval += "\n"
>
> return retval
> @@ -259,3 +258,8 @@ class F18_AutoPart(F17_AutoPart):
> op = F17_AutoPart._getParser(self)
> op.add_option("--cipher")
> return op
> +
> +class F19_AutoPart(F18_AutoPart):
> + def __init__(self, writePriority=100, *args, **kwargs):
> + F18_AutoPart.__init__(self, writePriority=writePriority, *args, **kwargs)
> + self.typeMap["thinp"] = AUTOPART_TYPE_LVM_THINP
> diff --git a/pykickstart/commands/logvol.py b/pykickstart/commands/logvol.py
> index 9a7b54c..28b8b50 100644
> --- a/pykickstart/commands/logvol.py
> +++ b/pykickstart/commands/logvol.py
> @@ -233,6 +233,34 @@ class F18_LogVolData(F17_LogVolData):
>
> return retval
>
> +class F19_LogVolData(F18_LogVolData):
I believe the new classes should be F20_* classes.
> + def __init__(self, *args, **kwargs):
> + F18_LogVolData.__init__(self, *args, **kwargs)
> + self.thin_pool = kwargs.get("thin_pool", False)
> + self.thin_volume = kwargs.get("thin_volume", False)
> + self.pool_name = kwargs.get("pool_name", "")
> +
> + # these are only for thin pools
> + self.chunk_size = kwargs.get("chunk_size", None) # kilobytes
> + self.metadata_size = kwargs.get("metadata_size", None) # megabytes
> +
> + def _getArgsAsStr(self):
> + retval = F18_LogVolData._getArgsAsStr(self)
> +
> + 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):
> removedKeywords = KickstartCommand.removedKeywords
> removedAttrs = KickstartCommand.removedAttrs
> @@ -394,3 +422,29 @@ class F18_LogVol(F17_LogVol):
> op.add_option("--cipher")
> return op
>
> +class F19_LogVol(F18_LogVol):
> + def _getParser(self):
> + op = F18_LogVol._getParser(self)
> + 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):
> + retval = F18_LogVol.parse(self, args)
> +
> + if retval.thin_volume and retval.thin_pool:
> + raise KickstartParseError(formatErrorMsg(self.lineno, msg=_("--thin and --thinpool cannot both be specified for the same logvol")))
> +
> + if retval.thin_volume and not retval.pool_name:
> + raise KickstartParseError(formatErrorMsg(self.lineno, msg=_("--thin requires --poolname to specify pool name")))
> +
> + if (retval.chunk_size or retval.metadata_size) and \
> + not retval.thin_pool:
> + raise KickstartParseError(formatErrorMsg(self.lineno, msg=_("--chunksize and --metadatasize are for thin pools only")))
Could you please split these long lines?
Other than that and Brian's comments this looks good to me.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list