--- pykickstart/commands/logvol.py | 31 ++++++++++++++++++++++++++++++- pykickstart/commands/partition.py | 33 ++++++++++++++++++++++++++++++++- pykickstart/handlers/control.py | 10 +++++----- tests/commands/logvol.py | 16 ++++++++++++++++ tests/commands/partition.py | 15 +++++++++++++++ 5 files changed, 98 insertions(+), 7 deletions(-) diff --git a/pykickstart/commands/logvol.py b/pykickstart/commands/logvol.py index c1b9cc3..1f3aea9 100644 --- a/pykickstart/commands/logvol.py +++ b/pykickstart/commands/logvol.py @@ -1,7 +1,7 @@ # # Chris Lumens <clumens@xxxxxxxxxx> # -# 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 @@ -178,6 +178,18 @@ class F15_LogVolData(F14_LogVolData): return retval +class F17_LogVolData(F15_LogVolData): + def __init__(self, *args, **kwargs): + F15_LogVolData.__init__(self, *args, **kwargs) + self.resize = kwargs.get("resize", False) + + def _getArgsAsStr(self): + retval = F15_LogVolData._getArgsAsStr(self) + if self.resize: + retval += " --resize" + + return retval + class FC3_LogVol(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords removedAttrs = KickstartCommand.removedAttrs @@ -302,3 +314,20 @@ class F15_LogVol(F14_LogVol): op = F14_LogVol._getParser(self) op.add_option("--label") return op + +class F17_LogVol(F15_LogVol): + def _getParser(self): + op = F15_LogVol._getParser(self) + op.add_option("--resize", action="store_true", default=False) + return op + + def parse(self, args): + retval = F15_LogVol.parse(self, args) + + if retval.resize and not retval.preexist: + raise KickstartParseError(formatErrorMsg(self.lineno, msg=_("--resize can only be used in conjunction with --useexisting"))) + + if retval.resize and not retval.size: + raise KickstartParseError(formatErrorMsg(self.lineno, msg=_("--resize requires --size to indicate new size"))) + + return retval diff --git a/pykickstart/commands/partition.py b/pykickstart/commands/partition.py index 34e5b7a..aad3202 100644 --- a/pykickstart/commands/partition.py +++ b/pykickstart/commands/partition.py @@ -1,7 +1,7 @@ # # Chris Lumens <clumens@xxxxxxxxxx> # -# 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 @@ -182,6 +182,20 @@ class F12_PartData(F11_PartData): F14_PartData = F12_PartData +class F17_PartData(F14_PartData): + def __init__(self, *args, **kwargs): + F14_PartData.__init__(self, *args, **kwargs) + + self.resize = kwargs.get("resize", False) + + def _getArgsAsStr(self): + retval = F14_PartData._getArgsAsStr(self) + + if self.resize: + retval += " --resize" + + return retval + class FC3_Partition(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords removedAttrs = KickstartCommand.removedAttrs @@ -346,3 +360,20 @@ class F14_Partition(F12_Partition): op.remove_option("--start") op.remove_option("--end") return op + +class F17_Partition(F14_Partition): + def _getParser(self): + op = F14_Partition._getParser(self) + op.add_option("--resize", action="store_true", default=False) + return op + + def parse(self, args): + retval = F14_Partition.parse(self, args) + + if retval.resize and not retval.onPart: + raise KickstartParseError(formatErrorMsg(self.lineno, msg=_("--resize can only be used in conjunction with --onpart"))) + + if retval.resize and not retval.size: + raise KickstartParseError(formatErrorMsg(self.lineno, msg=_("--resize requires --size to specify new size"))) + + return retval diff --git a/pykickstart/handlers/control.py b/pykickstart/handlers/control.py index db9acc5..165debf 100644 --- a/pykickstart/handlers/control.py +++ b/pykickstart/handlers/control.py @@ -852,14 +852,14 @@ commandMap = { "keyboard": keyboard.FC3_Keyboard, "lang": lang.FC3_Lang, "logging": logging.FC6_Logging, - "logvol": logvol.F15_LogVol, + "logvol": logvol.F17_LogVol, "mediacheck": mediacheck.FC4_MediaCheck, "monitor": monitor.F10_Monitor, "multipath": multipath.FC6_MultiPath, "network": network.F16_Network, "nfs": method.F14_Method, - "part": partition.F14_Partition, - "partition": partition.F14_Partition, + "part": partition.F17_Partition, + "partition": partition.F17_Partition, "poweroff": reboot.FC6_Reboot, "raid": raid.F15_Raid, "reboot": reboot.FC6_Reboot, @@ -1323,10 +1323,10 @@ dataMap = { "FcoeData": fcoe.F13_FcoeData, "GroupData": group.F12_GroupData, "IscsiData": iscsi.F10_IscsiData, - "LogVolData": logvol.F15_LogVolData, + "LogVolData": logvol.F17_LogVolData, "MultiPathData": multipath.FC6_MultiPathData, "NetworkData": network.F16_NetworkData, - "PartData": partition.F14_PartData, + "PartData": partition.F17_PartData, "RaidData": raid.F15_RaidData, "RepoData": repo.F15_RepoData, "SshPwData": sshpw.F13_SshPwData, diff --git a/tests/commands/logvol.py b/tests/commands/logvol.py index 9b14fd0..97ab01b 100644 --- a/tests/commands/logvol.py +++ b/tests/commands/logvol.py @@ -192,5 +192,21 @@ class F15_TestCase(F14_TestCase): self.assert_parse("logvol / --name=NAME --vgname=VGNAME --label=ROOT", "logvol / --label=\"ROOT\" --name=NAME --vgname=VGNAME\n") +class F17_TestCase(F15_TestCase): + def runTest(self): + F15_TestCase.runTest(self) + self.assert_parse("logvol /x --name=NAME --size 1000 --vgname=VGNAME " + "--useexisting --resize", + "logvol /x --size=1000 --useexisting --resize " + "--name=NAME --vgname=VGNAME\n") + self.assert_parse_error("logvol /x --name=NAME --vgname=VGNAME --resize") + + # no useexisting + self.assert_parse_error("logvol /x --name=NAME --vgname=VGNAME --resize --size=500") + + # no size + self.assert_parse_error("logvol /x --name=NAME --vgname=VGNAME --resize --useexisting") + + if __name__ == "__main__": unittest.main() diff --git a/tests/commands/partition.py b/tests/commands/partition.py index f68db1a..979f0ff 100644 --- a/tests/commands/partition.py +++ b/tests/commands/partition.py @@ -159,5 +159,20 @@ class F14_TestCase(F12_TestCase): self.assert_removed("partition", "--start") self.assert_removed("partition", "--end") +class F17_TestCase(F14_TestCase): + def runTest(self): + F14_TestCase.runTest(self) + self.assert_parse("part /foo --resize --size 500 --onpart=sda3", + "part /foo --onpart=sda3 --size=500 --resize\n") + + # no onpart or size + self.assert_parse_error("part /foo --resize") + + # no onpart + self.assert_parse_error("part /foo --size=999 --resize") + + # no size + self.assert_parse_error("part /foo --onpart=LABEL=var --resize") + if __name__ == "__main__": unittest.main() -- 1.7.7.6 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list