[PATCH] Allow some sizes in kickstart to take the form of a blivet size spec.
David Lehman
dlehman at redhat.com
Thu May 1 22:29:39 UTC 2014
On 05/01/2014 10:29 AM, Chris Lumens wrote:
> This covers --size= and --maxsize= for the logvol and part commands. It
> requires pykickstart support in that it should not blindly assume those
> arguments will be passed in as ints.
I like this idea a lot, but I'd either go all the way or not at all. The
only other things I can think of that you would have to change are
volgroup.pesize, logvol.chunksize and logvol.metadatasize.
David
> ---
> anaconda.spec.in | 2 +-
> pyanaconda/kickstart.py | 36 +++++++++++++++++++++++-------------
> 2 files changed, 24 insertions(+), 14 deletions(-)
>
> diff --git a/anaconda.spec.in b/anaconda.spec.in
> index 89f4df2..18c75c0 100755
> --- a/anaconda.spec.in
> +++ b/anaconda.spec.in
> @@ -21,7 +21,7 @@ Source0: %{name}-%{version}.tar.bz2
> # Also update in AM_GNU_GETTEXT_VERSION in configure.ac
> %define gettextver 0.18.3
> %define intltoolver 0.31.2-3
> -%define pykickstartver 1.99.52
> +%define pykickstartver 1.99.55
> %define yumver 3.4.3-91
> %define dnfver 0.4.18
> %define partedver 1.8.1
> diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py
> index 0881c5d..81dd2a8 100644
> --- a/pyanaconda/kickstart.py
> +++ b/pyanaconda/kickstart.py
> @@ -1,7 +1,7 @@
> #
> # kickstart.py: kickstart install support
> #
> -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
> +# Copyright (C) 1999-2014
> # Red Hat, Inc. All rights reserved.
> #
> # This program is free software; you can redistribute it and/or modify
> @@ -223,6 +223,24 @@ def getAvailableDiskSpace(storage):
>
> return disk_space
>
> +def makeSize(s, default="MiB"):
> + try:
> + _n = int(s)
> + except ValueError:
> + # It's not just an integer, so treat the input string as a size spec.
> + spec = s
> + else:
> + # It's just an integer, so treat the input string in terms of the
> + # default unit.
> + spec = "%d %s" % (s, default)
> +
> + try:
> + return Size(spec=spec)
> + except (ValueError, SizeParamsError):
> + raise
> + except TypeError:
> + return None
> +
> ###
> ### SUBCLASSES OF PYKICKSTART COMMAND HANDLERS
> ###
> @@ -713,11 +731,9 @@ class LogVolData(commands.logvol.F20_LogVolData):
> vgname = ksdata.onPart.get(self.vgname, self.vgname)
>
> try:
> - size = Size(spec="%d MiB" % self.size)
> + size = makeSize(self.size)
> except (ValueError, SizeParamsError):
> raise KickstartValueError(formatErrorMsg(self.lineno, msg="The size %s is not valid." % self.size))
> - except TypeError:
> - pass
>
> if self.mountpoint == "swap":
> ty = "swap"
> @@ -857,11 +873,9 @@ class LogVolData(commands.logvol.F20_LogVolData):
>
> if self.maxSizeMB:
> try:
> - maxsize = Size(spec="%d MiB" % self.maxSizeMB)
> + maxsize = makeSize(self.maxSizeMB)
> except (ValueError, SizeParamsError):
> raise KickstartValueError(formatErrorMsg(self.lineno, msg="The maximum size %s is not valid." % self.maxSizeMB))
> - except TypeError:
> - pass
> else:
> maxsize = None
>
> @@ -949,11 +963,9 @@ class PartitionData(commands.partition.F18_PartData):
> storage.doAutoPart = False
>
> try:
> - size = Size(spec="%d MiB" % self.size)
> + size = makeSize(self.size)
> except (ValueError, SizeParamsError):
> raise KickstartValueError(formatErrorMsg(self.lineno, msg="The size %s is not valid." % self.size))
> - except TypeError:
> - pass
>
> if self.onbiosdisk != "":
> for (disk, biosdisk) in storage.eddDict.iteritems():
> @@ -1105,11 +1117,9 @@ class PartitionData(commands.partition.F18_PartData):
> kwargs["size"] = size
> if self.maxSizeMB:
> try:
> - maxsize = Size(spec="%d MiB" % self.maxSizeMB)
> + maxsize = makeSize(self.maxSizeMB)
> except (ValueError, SizeParamsError):
> raise KickstartValueError(formatErrorMsg(self.lineno, msg="The maximum size %s is not valid." % self.maxSizeMB))
> - except TypeError:
> - pass
> else:
> maxsize = None
>
>
More information about the anaconda-patches
mailing list