[pykickstart] Add autopart --fstype support (#1112697)
Vratislav Podzimek
vpodzime at redhat.com
Mon Jun 30 06:47:03 UTC 2014
On Fri, 2014-06-27 at 17:58 -0700, Brian C. Lane wrote:
> This will allow the user to specify the filesystem type to use instead
> of the default when auto-partitioning.
> ---
> pykickstart/commands/autopart.py | 41 ++++++++++++++++++++++++++++++++++++++++
> pykickstart/handlers/f21.py | 2 +-
> tests/commands/autopart.py | 19 +++++++++++++++++++
> 3 files changed, 61 insertions(+), 1 deletion(-)
>
> diff --git a/pykickstart/commands/autopart.py b/pykickstart/commands/autopart.py
> index e19a89f..19fb266 100644
> --- a/pykickstart/commands/autopart.py
> +++ b/pykickstart/commands/autopart.py
> @@ -336,3 +336,44 @@ class F20_AutoPart(F18_AutoPart):
> conflicting_command
> raise KickstartParseError(formatErrorMsg(self.lineno, msg=errorMsg))
> return retval
> +
> +class F21_AutoPart(F20_AutoPart):
> + removedKeywords = F20_AutoPart.removedKeywords
> + removedAttrs = F20_AutoPart.removedAttrs
> +
> + def __init__(self, writePriority=100, *args, **kwargs):
> + F20_AutoPart.__init__(self, writePriority=writePriority, *args, **kwargs)
> + self.fstype = kwargs.get("fstype", "")
> +
> + def __str__(self):
> + retval = F20_AutoPart.__str__(self)
> + if not self.autopart:
> + return retval
> +
> + if self.fstype:
> + # remove any trailing newline
> + retval = retval.strip()
> + retval += " --fstype=%s" % self.fstype
> + retval += "\n"
> +
> + return retval
> +
> + def _getParser(self):
> + op = F20_AutoPart._getParser(self)
> + op.add_option("--fstype")
> + return op
> +
> + def parse(self, args):
> + # call the overriden command to do it's job first
> + retval = F20_AutoPart.parse(self, args)
> +
> + # btrfs is not a valid filesystem type
> + if self.fstype == "btrfs":
> + raise KickstartParseError(formatErrorMsg(self.lineno,
> + msg=_("autopart --fstype=btrfs is not valid fstype, use --type=btrfs instead")))
> +
> + if self._typeAsStr() == "btrfs" and self.fstype:
> + raise KickstartParseError(formatErrorMsg(self.lineno,
> + msg=_("autopart --fstype cannot be used with --type=btrfs")))
> +
> + return retval
> diff --git a/pykickstart/handlers/f21.py b/pykickstart/handlers/f21.py
> index 23220ca..cac66bc 100644
> --- a/pykickstart/handlers/f21.py
> +++ b/pykickstart/handlers/f21.py
> @@ -29,7 +29,7 @@ class F21Handler(BaseHandler):
> commandMap = {
> "auth": commands.authconfig.FC3_Authconfig,
> "authconfig": commands.authconfig.FC3_Authconfig,
> - "autopart": commands.autopart.F20_AutoPart,
> + "autopart": commands.autopart.F21_AutoPart,
> "autostep": commands.autostep.FC3_AutoStep,
> "bootloader": commands.bootloader.F21_Bootloader,
> "btrfs": commands.btrfs.F17_BTRFS,
> diff --git a/tests/commands/autopart.py b/tests/commands/autopart.py
> index 962b02a..311f253 100644
> --- a/tests/commands/autopart.py
> +++ b/tests/commands/autopart.py
> @@ -147,8 +147,27 @@ class F18_TestCase(F17_TestCase):
>
> class F20_TestCase(F18_TestCase):
> def runTest(self):
> + F18_TestCase.runTest(self)
> +
> self.assert_parse("autopart --type=thinp",
> "autopart --type=thinp\n")
>
> +class F21_TestCase(F20_TestCase):
> + def runTest(self):
> + F20_TestCase.runTest(self)
> +
> + # pass
> + self.assert_parse("autopart --fstype=ext4",
> + 'autopart --fstype=ext4\n')
> + self.assert_parse("autopart --encrypted --fstype=ext4",
> + 'autopart --encrypted --fstype=ext4\n')
> + self.assert_parse("autopart --type=lvm --fstype=xfs",
> + "autopart --type=lvm --fstype=xfs\n")
> +
> + # fail
> + self.assert_parse_error("autopart --fstype")
> + self.assert_parse_error("autopart --fstype=btrfs")
> + self.assert_parse_error("autopart --type=btrfs --fstype=xfs")
> +
> if __name__ == "__main__":
> unittest.main()
These both look good to me, ACK.
--
Vratislav Podzimek
Anaconda Rider | RHCE | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list