[PATCH] Allow specifying logvol, part, and volgroup sizes as strings.
Vratislav Podzimek
vpodzime at redhat.com
Mon May 5 11:10:10 UTC 2014
On Fri, 2014-05-02 at 11:37 -0400, Chris Lumens wrote:
> Basically, these commands can now take a string in F21, and it is expected
> this string will be a size spec like blivet would accept. It's up to the
> users of pykickstart to enforce this, though.
> ---
> pykickstart/commands/logvol.py | 23 ++++++++++++++++-------
> pykickstart/commands/partition.py | 15 +++++++++++----
> pykickstart/commands/volgroup.py | 10 ++++++++--
> pykickstart/handlers/f21.py | 8 ++++----
> tests/commands/logvol.py | 32 +++++++++++++++++++++++---------
> tests/commands/partition.py | 21 +++++++++++++++++----
> tests/commands/volgroup.py | 15 +++++++++++----
> 7 files changed, 90 insertions(+), 34 deletions(-)
>
> diff --git a/pykickstart/commands/logvol.py b/pykickstart/commands/logvol.py
> index f8d571a..fda0956 100644
> --- a/pykickstart/commands/logvol.py
> +++ b/pykickstart/commands/logvol.py
> @@ -1,7 +1,7 @@
> #
> # Chris Lumens <clumens at redhat.com>
> #
> -# Copyright 2005, 2006, 2007, 2008, 2012 Red Hat, Inc.
> +# Copyright 2005, 2006, 2007, 2008, 2012, 2014 Red Hat, Inc.
> #
> # This copyrighted material is made available to anyone wishing to use, modify,
> # copy, or redistribute it subject to the terms and conditions of the GNU
> @@ -59,16 +59,16 @@ class FC3_LogVolData(BaseData):
> retval += " --fstype=\"%s\"" % self.fstype
> if self.grow:
> retval += " --grow"
> - if self.maxSizeMB > 0:
> - retval += " --maxsize=%d" % self.maxSizeMB
> + if self.maxSizeMB:
> + retval += " --maxsize=%s" % self.maxSizeMB
> if not self.format:
> retval += " --noformat"
> if self.percent > 0:
> retval += " --percent=%d" % self.percent
> if self.recommended:
> retval += " --recommended"
> - if self.size > 0:
> - retval += " --size=%d" % self.size
> + if self.size:
> + retval += " --size=%s" % self.size
> if self.preexist:
> retval += " --useexisting"
>
> @@ -251,10 +251,10 @@ class F20_LogVolData(F18_LogVolData):
> retval += " --thinpool"
>
> if self.metadata_size:
> - retval += " --metadatasize=%d" % self.metadata_size
> + retval += " --metadatasize=%s" % self.metadata_size
>
> if self.chunk_size:
> - retval += " --chunksize=%d" % self.chunk_size
> + retval += " --chunksize=%s" % self.chunk_size
>
> if self.thin_volume:
> retval += " --thin --poolname=%s" % self.pool_name
> @@ -473,3 +473,12 @@ class F20_LogVol(F18_LogVol):
> raise KickstartParseError(formatErrorMsg(self.lineno, msg=errorMsg))
>
> return retval
> +
> +class F21_LogVol(F20_LogVol):
> + def _getParser(self):
> + op = F20_LogVol._getParser(self)
> + op.add_option("--maxsize", dest="maxSizeMB")
> + op.add_option("--size", dest="size")
> + op.add_option("--chunksize", dest="chunk_size")
> + op.add_option("--metadatasize", dest="metadata_size")
> + return op
> diff --git a/pykickstart/commands/partition.py b/pykickstart/commands/partition.py
> index 437347c..46f0b3c 100644
> --- a/pykickstart/commands/partition.py
> +++ b/pykickstart/commands/partition.py
> @@ -1,7 +1,7 @@
> #
> # Chris Lumens <clumens at redhat.com>
> #
> -# Copyright 2005, 2006, 2007, 2008, 2012 Red Hat, Inc.
> +# Copyright 2005, 2006, 2007, 2008, 2012, 2014 Red Hat, Inc.
> #
> # This copyrighted material is made available to anyone wishing to use, modify,
> # copy, or redistribute it subject to the terms and conditions of the GNU
> @@ -68,8 +68,8 @@ class FC3_PartData(BaseData):
> retval += " --fstype=\"%s\"" % self.fstype
> if self.grow:
> retval += " --grow"
> - if self.maxSizeMB > 0:
> - retval += " --maxsize=%d" % self.maxSizeMB
> + if self.maxSizeMB:
> + retval += " --maxsize=%s" % self.maxSizeMB
> if not self.format:
> retval += " --noformat"
> if self.onbiosdisk != "":
> @@ -80,7 +80,7 @@ class FC3_PartData(BaseData):
> retval += " --onpart=%s" % self.onPart
> if self.recommended:
> retval += " --recommended"
> - if self.size and self.size != 0:
> + if self.size:
> retval += " --size=%s" % self.size
> if hasattr(self, "start") and self.start != 0:
> retval += " --start=%s" % self.start
> @@ -471,3 +471,10 @@ class F20_Partition(F18_Partition):
> raise KickstartParseError(formatErrorMsg(self.lineno, msg=errorMsg))
>
> return retval
> +
> +class F21_Partition(F20_Partition):
> + def _getParser(self):
> + op = F20_Partition._getParser(self)
> + op.add_option("--maxsize", dest="maxSizeMB", action="store", nargs=1)
> + op.add_option("--size", dest="size", action="store", nargs=1)
> + return op
> diff --git a/pykickstart/commands/volgroup.py b/pykickstart/commands/volgroup.py
> index 9e52a9c..95c836c 100644
> --- a/pykickstart/commands/volgroup.py
> +++ b/pykickstart/commands/volgroup.py
> @@ -50,8 +50,8 @@ class FC3_VolGroupData(BaseData):
> retval = ""
> if not self.format:
> retval += " --noformat"
> - if self.pesize != 0:
> - retval += " --pesize=%d" % self.pesize
> + if self.pesize:
> + retval += " --pesize=%s" % self.pesize
> if self.preexist:
> retval += " --useexisting"
>
> @@ -190,3 +190,9 @@ class F20_VolGroup(FC16_VolGroup):
> raise KickstartParseError(formatErrorMsg(self.lineno, msg=errorMsg))
>
> return retval
> +
> +class F21_VolGroup(F20_VolGroup):
> + def _getParser(self):
> + op = F20_VolGroup._getParser(self)
> + op.add_option("--pesize", dest="pesize", default=32768)
Where did this number come from? ^^^^^
AFAICT, default PE size is 4 MiB and I cannot see this number anywhere
else in this patch.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list