(based on commit 4946bcf5d330338a160c12e77f3252fce60994d4 from rhel6-branch)
Also update some RHEL6 stuff that didn't make it to master. --- pykickstart/commands/autopart.py | 50 ++++++++++++++++++++++++++++++++++++- pykickstart/commands/logvol.py | 37 ++++++++++++++++++++++++++++ pykickstart/commands/partition.py | 36 +++++++++++++++++++++++++++ pykickstart/commands/raid.py | 52 +++++++++++++++++++++++++++++++++++++++ pykickstart/handlers/control.py | 22 ++++++++--------- tests/commands/autopart.py | 27 ++++++++++++++++++++ tests/commands/logvol.py | 27 ++++++++++++++++++++ tests/commands/partition.py | 25 +++++++++++++++++++ tests/commands/raid.py | 26 ++++++++++++++++++++ 9 files changed, 290 insertions(+), 12 deletions(-)
diff --git a/pykickstart/commands/autopart.py b/pykickstart/commands/autopart.py index 910886f..a00efdb 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 @@ -120,6 +120,30 @@ class F12_AutoPart(F9_AutoPart): 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 + class F16_AutoPart(F12_AutoPart): removedKeywords = F12_AutoPart.removedKeywords removedAttrs = F12_AutoPart.removedAttrs @@ -199,3 +223,27 @@ class F17_AutoPart(F16_AutoPart): self.lvm = True
return self + +class F18_AutoPart(F17_AutoPart): + removedKeywords = F17_AutoPart.removedKeywords + removedAttrs = F17_AutoPart.removedAttrs + + def __init__(self, writePriority=100, *args, **kwargs): + F17_AutoPart.__init__(self, writePriority=writePriority, *args, **kwargs) + self.cipher = kwargs.get("cipher", "") + + def __str__(self): + retval = F17_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 = F17_AutoPart._getParser(self) + op.add_option("--cipher") + return op diff --git a/pykickstart/commands/logvol.py b/pykickstart/commands/logvol.py index 1e6579e..5fcb6e5 100644 --- a/pykickstart/commands/logvol.py +++ b/pykickstart/commands/logvol.py @@ -166,6 +166,26 @@ class F12_LogVolData(F9_LogVolData):
return retval
+class RHEL6_LogVolData(F12_LogVolData): + removedKeywords = F12_LogVolData.removedKeywords + removedAttrs = F12_LogVolData.removedAttrs + + def __init__(self, *args, **kwargs): + F12_LogVolData.__init__(self, *args, **kwargs) + + self.cipher = kwargs.get("cipher", "") + self.hibernation = kwargs.get("hibernation", False) + + def _getArgsAsStr(self): + retval = F12_LogVolData._getArgsAsStr(self) + + if self.encrypted and self.cipher: + retval += " --cipher="%s"" % self.cipher + if self.hibernation: + retval += " --hibernation" + + return retval + F14_LogVolData = F12_LogVolData
class F15_LogVolData(F14_LogVolData): @@ -200,6 +220,7 @@ class F18_LogVolData(F17_LogVolData): def __init__(self, *args, **kwargs): F17_LogVolData.__init__(self, *args, **kwargs) self.hibernation = kwargs.get("hibernation", False) + self.cipher = kwargs.get("cipher", "")
def _getArgsAsStr(self): retval = F17_LogVolData._getArgsAsStr(self) @@ -207,6 +228,9 @@ class F18_LogVolData(F17_LogVolData): if self.hibernation: retval += " --hibernation"
+ if self.encrypted and self.cipher: + retval += " --cipher="%s"" % self.cipher + return retval
class FC3_LogVol(KickstartCommand): @@ -316,6 +340,18 @@ class F12_LogVol(F9_LogVol): op.add_option("--backuppassphrase", action="store_true", default=False) return op
+class RHEL6_LogVol(F12_LogVol): + removedKeywords = F12_LogVol.removedKeywords + removedAttrs = F12_LogVol.removedAttrs + + def _getParser(self): + op = F12_LogVol._getParser(self) + op.add_option("--cipher") + op.add_option("--hibernation", dest="hibernation", action="store_true", + default=False) + + return op + class F14_LogVol(F12_LogVol): removedKeywords = F12_LogVol.removedKeywords removedAttrs = F12_LogVol.removedAttrs @@ -355,5 +391,6 @@ class F18_LogVol(F17_LogVol): def _getParser(self): op = F17_LogVol._getParser(self) op.add_option("--hibernation", action="store_true", default=False) + op.add_option("--cipher") return op
diff --git a/pykickstart/commands/partition.py b/pykickstart/commands/partition.py index e30f849..62aa8f4 100644 --- a/pykickstart/commands/partition.py +++ b/pykickstart/commands/partition.py @@ -186,6 +186,26 @@ class F12_PartData(F11_PartData):
return retval
+class RHEL6_PartData(F12_PartData): + removedKeywords = F12_PartData.removedKeywords + removedAttrs = F12_PartData.removedAttrs + + def __init__(self, *args, **kwargs): + F12_PartData.__init__(self, *args, **kwargs) + + self.cipher = kwargs.get("cipher", "") + self.hibernation = kwargs.get("hibernation", False) + + def _getArgsAsStr(self): + retval = F12_PartData._getArgsAsStr(self) + + if self.encrypted and self.cipher: + retval += " --cipher="%s"" % self.cipher + if self.hibernation: + retval += " --hibernation" + + return retval + F14_PartData = F12_PartData
class F17_PartData(F14_PartData): @@ -207,6 +227,7 @@ class F18_PartData(F17_PartData): F17_PartData.__init__(self, *args, **kwargs)
self.hibernation = kwargs.get("hibernation", False) + self.cipher = kwargs.get("cipher", "")
def _getArgsAsStr(self): retval = F17_PartData._getArgsAsStr(self) @@ -214,6 +235,9 @@ class F18_PartData(F17_PartData): if self.hibernation: retval += " --hibernation"
+ if self.encrypted and self.cipher: + retval += " --cipher="%s"" % self.cipher + return retval
class FC3_Partition(KickstartCommand): @@ -370,6 +394,17 @@ class F12_Partition(F11_Partition): op.add_option("--backuppassphrase", action="store_true", default=False) return op
+class RHEL6_Partition(F12_Partition): + removedKeywords = F12_Partition.removedKeywords + removedAttrs = F12_Partition.removedAttrs + + def _getParser(self): + op = F12_Partition._getParser(self) + op.add_option("--cipher") + op.add_option("--hibernation", dest="hibernation", action="store_true", + default=False) + return op + class F14_Partition(F12_Partition): removedKeywords = F12_Partition.removedKeywords removedAttrs = F12_Partition.removedAttrs @@ -402,5 +437,6 @@ class F18_Partition(F17_Partition): def _getParser(self): op = F17_Partition._getParser(self) op.add_option("--hibernation", dest="hibernation", action="store_true", default=False) + op.add_option("--cipher")
return op diff --git a/pykickstart/commands/raid.py b/pykickstart/commands/raid.py index 4ba353d..d99f992 100644 --- a/pykickstart/commands/raid.py +++ b/pykickstart/commands/raid.py @@ -175,6 +175,23 @@ class F12_RaidData(F9_RaidData):
F13_RaidData = F12_RaidData
+class RHEL6_RaidData(F13_RaidData): + removedKeywords = F13_RaidData.removedKeywords + removedAttrs = F13_RaidData.removedAttrs + + def __init__(self, *args, **kwargs): + F13_RaidData.__init__(self, *args, **kwargs) + + self.cipher = kwargs.get("cipher", "") + + def _getArgsAsStr(self): + retval = F13_RaidData._getArgsAsStr(self) + + if self.encrypted and self.cipher: + retval += " --cipher="%s"" % self.cipher + + return retval + F14_RaidData = F13_RaidData
class F15_RaidData(F14_RaidData): @@ -195,6 +212,23 @@ class F15_RaidData(F14_RaidData):
return retval
+class F18_RaidData(F15_RaidData): + removedKeywords = F15_RaidData.removedKeywords + removedAttrs = F15_RaidData.removedAttrs + + def __init__(self, *args, **kwargs): + F15_RaidData.__init__(self, *args, **kwargs) + + self.cipher = kwargs.get("cipher", "") + + def _getArgsAsStr(self): + retval = F15_RaidData._getArgsAsStr(self) + + if self.encrypted and self.cipher: + retval += " --cipher="%s"" % self.cipher + + return retval + class FC3_Raid(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords removedAttrs = KickstartCommand.removedAttrs @@ -360,6 +394,15 @@ class F13_Raid(F12_Raid):
self.levelMap.update({"RAID4": "RAID4", "4": "RAID4"})
+class RHEL6_Raid(F13_Raid): + removedKeywords = F13_Raid.removedKeywords + removedAttrs = F13_Raid.removedAttrs + + def _getParser(self): + op = F13_Raid._getParser(self) + op.add_option("--cipher") + return op + class F14_Raid(F13_Raid): removedKeywords = F13_Raid.removedKeywords removedAttrs = F13_Raid.removedAttrs @@ -377,3 +420,12 @@ class F15_Raid(F14_Raid): op = F14_Raid._getParser(self) op.add_option("--label") return op + +class F18_Raid(F15_Raid): + removedKeywords = F15_Raid.removedKeywords + removedAttrs = F15_Raid.removedAttrs + + def _getParser(self): + op = F15_Raid._getParser(self) + op.add_option("--cipher") + return op diff --git a/pykickstart/handlers/control.py b/pykickstart/handlers/control.py index 0e02355..fb1424d 100644 --- a/pykickstart/handlers/control.py +++ b/pykickstart/handlers/control.py @@ -888,7 +888,7 @@ commandMap = { F18: { "auth": authconfig.FC3_Authconfig, "authconfig": authconfig.FC3_Authconfig, - "autopart": autopart.F17_AutoPart, + "autopart": autopart.F18_AutoPart, "autostep": autostep.FC3_AutoStep, "bootloader": bootloader.F18_Bootloader, "btrfs": btrfs.F17_BTRFS, @@ -921,7 +921,7 @@ commandMap = { "part": partition.F18_Partition, "partition": partition.F18_Partition, "poweroff": reboot.F18_Reboot, - "raid": raid.F15_Raid, + "raid": raid.F18_Raid, "reboot": reboot.F18_Reboot, "repo": repo.F15_Repo, "rescue": rescue.F10_Rescue, @@ -1107,7 +1107,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, @@ -1132,16 +1132,16 @@ commandMap = { "keyboard": keyboard.FC3_Keyboard, "lang": lang.FC3_Lang, "logging": logging.FC6_Logging, - "logvol": logvol.F12_LogVol, + "logvol": logvol.RHEL6_LogVol, "mediacheck": mediacheck.FC4_MediaCheck, "monitor": monitor.F10_Monitor, "multipath": multipath.FC6_MultiPath, "network": network.RHEL6_Network, "nfs": method.RHEL6_Method, - "part": partition.F12_Partition, - "partition": partition.F12_Partition, + "part": partition.RHEL6_Partition, + "partition": partition.RHEL6_Partition, "poweroff": reboot.FC6_Reboot, - "raid": raid.F13_Raid, + "raid": raid.RHEL6_Raid, "reboot": reboot.FC6_Reboot, "repo": repo.RHEL6_Repo, "rescue": rescue.F10_Rescue, @@ -1467,7 +1467,7 @@ dataMap = { "MultiPathData": multipath.FC6_MultiPathData, "NetworkData": network.F16_NetworkData, "PartData": partition.F18_PartData, - "RaidData": raid.F15_RaidData, + "RaidData": raid.F18_RaidData, "RepoData": repo.F15_RepoData, "SshPwData": sshpw.F13_SshPwData, "UserData": user.F12_UserData, @@ -1513,11 +1513,11 @@ dataMap = { "FcoeData": fcoe.F13_FcoeData, "GroupData": group.F12_GroupData, "IscsiData": iscsi.RHEL6_IscsiData, - "LogVolData": logvol.F12_LogVolData, + "LogVolData": logvol.RHEL6_LogVolData, "MultiPathData": multipath.FC6_MultiPathData, "NetworkData": network.RHEL6_NetworkData, - "PartData": partition.F12_PartData, - "RaidData": raid.F13_RaidData, + "PartData": partition.RHEL6_PartData, + "RaidData": raid.RHEL6_RaidData, "RepoData": repo.RHEL6_RepoData, "SshPwData": sshpw.F13_SshPwData, "UserData": user.F12_UserData, diff --git a/tests/commands/autopart.py b/tests/commands/autopart.py index a2b288a..f05124a 100644 --- a/tests/commands/autopart.py +++ b/tests/commands/autopart.py @@ -79,6 +79,19 @@ 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") + class F16_TestCase(F12_TestCase): def runTest(self): # Run F12 test case @@ -118,5 +131,19 @@ class F17_TestCase(F16_TestCase): # fail self.assert_parse_error("autopart --type")
+class F18_TestCase(F17_TestCase): + def runTest(self): + F17_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() diff --git a/tests/commands/logvol.py b/tests/commands/logvol.py index e255faf..cd868fd 100644 --- a/tests/commands/logvol.py +++ b/tests/commands/logvol.py @@ -181,6 +181,24 @@ class F12_TestCase(F9_TestCase): self.assert_parse_error("logvol / --backuppassphrase=True --name=NAME " "--vgname=VGNAME")
+class RHEL6_TestCase(F12_TestCase): + def runTest(self): + F12_TestCase.runTest(self) + + self.assert_parse("logvol / --encrypted --cipher=3-rot13 --name=NAME --vgname=VGNAME", + "logvol / --encrypted --cipher="3-rot13" --name=NAME --vgname=VGNAME\n") + # Allowed here, but anaconda should complain. Note how we throw out + # cipher from the output if there's no --encrypted. + self.assert_parse("logvol / --cipher=3-rot13 --name=NAME --vgname=VGNAME", + "logvol / --name=NAME --vgname=VGNAME\n") + + self.assert_parse_error("logvol / --cipher --name=NAME --vgname=VGNAME") + + self.assert_parse("logvol swap --hibernation " + "--name=NAME --vgname=VGNAME") + self.assert_parse("logvol swap --recommended --hibernation " + "--name=NAME --vgname=VGNAME") + class F14_TestCase(F12_TestCase): def runTest(self): F12_TestCase.runTest(self) @@ -216,5 +234,14 @@ class F18_TestCase(F17_TestCase): self.assert_parse("logvol swap --name=NAME --vgname=VGNAME "\ "--recommended --hibernation")
+ self.assert_parse("logvol / --encrypted --cipher=3-rot13 --name=NAME --vgname=VGNAME", + "logvol / --encrypted --cipher="3-rot13" --name=NAME --vgname=VGNAME\n") + # Allowed here, but anaconda should complain. Note how we throw out + # cipher from the output if there's no --encrypted. + self.assert_parse("logvol / --cipher=3-rot13 --name=NAME --vgname=VGNAME", + "logvol / --name=NAME --vgname=VGNAME\n") + + self.assert_parse_error("logvol / --cipher --name=NAME --vgname=VGNAME") + if __name__ == "__main__": unittest.main() diff --git a/tests/commands/partition.py b/tests/commands/partition.py index 6df1510..6c81b9e 100644 --- a/tests/commands/partition.py +++ b/tests/commands/partition.py @@ -152,6 +152,22 @@ class F12_TestCase(F9_TestCase): self.assert_parse_error("part / --backuppassphrase=False") self.assert_parse_error("part / --backuppassphrase=True")
+class RHEL6_TestCase(F12_TestCase): + def runTest(self): + F12_TestCase.runTest(self) + + self.assert_parse("part / --encrypted --cipher=3-rot13", + "part / --encrypted --cipher="3-rot13"\n") + # Allowed here, but anaconda should complain. Note how we throw out + # cipher from the output if there's no --encrypted. + self.assert_parse("part / --cipher=3-rot13", + "part /\n") + + self.assert_parse_error("part / --cipher") + + self.assert_parse("part swap --hibernation") + self.assert_parse("part swap --recommended --hibernation") + class F14_TestCase(F12_TestCase): def runTest(self): F12_TestCase.runTest(self) @@ -181,5 +197,14 @@ class F18_TestCase(F17_TestCase): self.assert_parse("part swap --recommended") self.assert_parse("part swap --recommended --hibernation")
+ self.assert_parse("part / --encrypted --cipher=3-rot13", + "part / --encrypted --cipher="3-rot13"\n") + # Allowed here, but anaconda should complain. Note how we throw out + # cipher from the output if there's no --encrypted. + self.assert_parse("part / --cipher=3-rot13", + "part /\n") + + self.assert_parse_error("part / --cipher") + if __name__ == "__main__": unittest.main() diff --git a/tests/commands/raid.py b/tests/commands/raid.py index 7b6675a..bc63632 100644 --- a/tests/commands/raid.py +++ b/tests/commands/raid.py @@ -179,6 +179,19 @@ class F13_TestCase(F12_TestCase): F12_TestCase.__init__(self, *kargs, **kwargs) self.validLevels.append("RAID4")
+class RHEL6_TestCase(F13_TestCase): + def runTest(self): + F13_TestCase.runTest(self) + + self.assert_parse("raid / --device=md0 --level=1 --encrypted --cipher=3-rot13 raid.01 raid.02", + "raid / --device=0 --level=RAID1 --encrypted --cipher="3-rot13" raid.01 raid.02\n") + # Allowed here, but anaconda should complain. Note how we throw out + # cipher from the output if there's no --encrypted. + self.assert_parse("raid / --device=md0 --level=1 --cipher=3-rot13 raid.01 raid.02", + "raid / --device=0 --level=RAID1 raid.01 raid.02\n") + + self.assert_parse_error("raid / --cipher --device=md0 --level=1 raid.01 raid.02") + class F14_TestCase(F13_TestCase): def runTest(self): F13_TestCase.runTest(self) @@ -192,5 +205,18 @@ class F15_TestCase(F14_TestCase): self.assert_parse("raid / --device=md0 --label=ROOT --level=1 raid.01 raid.02", "raid / --device=0 --level=RAID1 --label=ROOT raid.01 raid.02\n")
+class F18_TestCase(F15_TestCase): + def runTest(self): + F15_TestCase.runTest(self) + + self.assert_parse("raid / --device=md0 --level=1 --encrypted --cipher=3-rot13 raid.01 raid.02", + "raid / --device=0 --level=RAID1 --encrypted --cipher="3-rot13" raid.01 raid.02\n") + # Allowed here, but anaconda should complain. Note how we throw out + # cipher from the output if there's no --encrypted. + self.assert_parse("raid / --device=md0 --level=1 --cipher=3-rot13 raid.01 raid.02", + "raid / --device=0 --level=RAID1 raid.01 raid.02\n") + + self.assert_parse_error("raid / --cipher --device=md0 --level=1 raid.01 raid.02") + if __name__ == "__main__": unittest.main()
anaconda-patches@lists.fedorahosted.org