Related: rhbz#843174 --- pykickstart/commands/autopart.py | 26 +++++++++++++++++++++++++- pykickstart/handlers/control.py | 2 +- tests/commands/autopart.py | 13 +++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/pykickstart/commands/autopart.py b/pykickstart/commands/autopart.py index cf28b5c..2885ad4 100644 --- a/pykickstart/commands/autopart.py +++ b/pykickstart/commands/autopart.py @@ -1,7 +1,7 @@ # # Chris Lumens clumens@redhat.com # -# Copyright 2005, 2006, 2007, 2008 Red Hat, Inc. +# Copyright 2005, 2006, 2007, 2008, 2012 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 @@ -117,3 +117,27 @@ class F12_AutoPart(F9_AutoPart): op.add_option("--escrowcert") op.add_option("--backuppassphrase", action="store_true", default=False) return op + +class RHEL6_AutoPart(F12_AutoPart): + removedKeywords = F12_AutoPart.removedKeywords + removedAttrs = F12_AutoPart.removedAttrs + + def __init__(self, writePriority=100, *args, **kwargs): + F12_AutoPart.__init__(self, writePriority=writePriority, *args, **kwargs) + self.cipher = kwargs.get("cipher", "") + + def __str__(self): + retval = F12_AutoPart.__str__(self) + + if self.encrypted and self.cipher: + # remove any trailing newline + retval = retval.strip() + retval += " --cipher="%s"" % self.cipher + retval += "\n" + + return retval + + def _getParser(self): + op = F12_AutoPart._getParser(self) + op.add_option("--cipher") + return op diff --git a/pykickstart/handlers/control.py b/pykickstart/handlers/control.py index cf24586..aa1ad39 100644 --- a/pykickstart/handlers/control.py +++ b/pykickstart/handlers/control.py @@ -813,7 +813,7 @@ commandMap = { RHEL6: { "auth": authconfig.FC3_Authconfig, "authconfig": authconfig.FC3_Authconfig, - "autopart": autopart.F12_AutoPart, + "autopart": autopart.RHEL6_AutoPart, "autostep": autostep.FC3_AutoStep, "bootloader": bootloader.RHEL6_Bootloader, "cdrom": method.RHEL6_Method, diff --git a/tests/commands/autopart.py b/tests/commands/autopart.py index 98b5e8a..6285fec 100644 --- a/tests/commands/autopart.py +++ b/tests/commands/autopart.py @@ -75,5 +75,18 @@ class F12_TestCase(F9_TestCase): self.assert_parse_error("autopart --backuppassphrase=False") self.assert_parse_error("autopart --backuppassphrase=True")
+class RHEL6_TestCase(F12_TestCase): + def runTest(self): + F12_TestCase.runTest(self) + + # pass + self.assert_parse("autopart --cipher=foo", "autopart\n") + self.assert_parse("autopart --encrypted --cipher=3-rot13", + "autopart --encrypted --cipher="3-rot13"\n") + + # fail + self.assert_parse_error("autopart --cipher") + self.assert_parse_error("autopart --encrypted --cipher") + if __name__ == "__main__": unittest.main()