[pykickstart] Do not set any magic default PE size in pykickstart

Vratislav Podzimek vpodzime at redhat.com
Mon Aug 4 13:21:56 UTC 2014


It should be left to the users of pykickstart to decide on the default PE size
so just use the value meaning "choose the default".

Related: rhbz#1098139

(port of 1bb22fd0a2e88e96442787c1c5a8cda1183545dc from master)

Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 pykickstart/commands/volgroup.py | 14 ++++++++++++++
 pykickstart/handlers/control.py  |  2 +-
 tests/commands/volgroup.py       | 24 ++++++++++++++++++++----
 3 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/pykickstart/commands/volgroup.py b/pykickstart/commands/volgroup.py
index eb9dbd9..dfd1291 100644
--- a/pykickstart/commands/volgroup.py
+++ b/pykickstart/commands/volgroup.py
@@ -80,6 +80,11 @@ class FC16_VolGroupData(FC3_VolGroupData):
 
         return retval
 
+class RHEL7_VolGroupData(FC16_VolGroupData):
+    def __init__(self, *args, **kwargs):
+        FC16_VolGroupData.__init__(self, *args, **kwargs)
+        self.pesize = kwargs.get("pesize", 0)
+
 class FC3_VolGroup(KickstartCommand):
     removedKeywords = KickstartCommand.removedKeywords
     removedAttrs = KickstartCommand.removedAttrs
@@ -186,3 +191,12 @@ class F20_VolGroup(FC16_VolGroup):
             errorMsg = _("The volgroup and autopart commands can't be used at the same time")
             raise KickstartParseError(formatErrorMsg(self.lineno, msg=errorMsg))
         return retval
+
+class RHEL7_VolGroup(F20_VolGroup):
+
+    def _getParser(self):
+        op = F20_VolGroup._getParser(self)
+        op.add_option("--pesize", dest="pesize", type="int", nargs=1,
+                      default=0)
+
+        return op
diff --git a/pykickstart/handlers/control.py b/pykickstart/handlers/control.py
index 04464d0..5d0b08a 100644
--- a/pykickstart/handlers/control.py
+++ b/pykickstart/handlers/control.py
@@ -1372,7 +1372,7 @@ commandMap = {
         "url": url.F18_Url,
         "user": user.F19_User,
         "vnc": vnc.RHEL7_Vnc,
-        "volgroup": volgroup.F20_VolGroup,
+        "volgroup": volgroup.RHEL7_VolGroup,
         "xconfig": xconfig.F14_XConfig,
         "zerombr": zerombr.F9_ZeroMbr,
         "zfcp": zfcp.F14_ZFCP,
diff --git a/tests/commands/volgroup.py b/tests/commands/volgroup.py
index 46462a4..74fbba6 100644
--- a/tests/commands/volgroup.py
+++ b/tests/commands/volgroup.py
@@ -10,12 +10,17 @@ class FC3_TestCase(CommandTest):
     command = "volgroup"
 
     def runTest(self):
+        if self.__class__ in (FC3_TestCase, F16_TestCase):
+            def_pesize_str = " --pesize=32768"
+        else:
+            def_pesize_str = ""
+
         # --noformat
         self.assert_parse("volgroup vg.01 --noformat",
-                          "volgroup vg.01 --noformat --pesize=32768 --useexisting\n")
+                          "volgroup vg.01 --noformat%s --useexisting\n" % def_pesize_str)
         # --useexisting
         self.assert_parse("volgroup vg.01 --useexisting",
-                          "volgroup vg.01 --pesize=32768 --useexisting\n")
+                          "volgroup vg.01%s --useexisting\n" % def_pesize_str)
 
         # --pesize
         self.assert_parse("volgroup vg.01 pv.01 --pesize=70000",
@@ -42,11 +47,16 @@ class F16_TestCase(FC3_TestCase):
     def runTest(self):
         FC3_TestCase.runTest(self)
 
+        if self.__class__ in (FC3_TestCase, F16_TestCase):
+            def_pesize_str = " --pesize=32768"
+        else:
+            def_pesize_str = ""
+
         # Pass - correct usage.
         self.assert_parse("volgroup vg.01 pv.01 --reserved-space=1000",
-                          "volgroup vg.01 --pesize=32768 --reserved-space=1000 pv.01\n")
+                          "volgroup vg.01%s --reserved-space=1000 pv.01\n" % def_pesize_str)
         self.assert_parse("volgroup vg.01 pv.01 --reserved-percent=50",
-                          "volgroup vg.01 --pesize=32768 --reserved-percent=50 pv.01\n")
+                          "volgroup vg.01%s --reserved-percent=50 pv.01\n" % def_pesize_str)
 
         # Fail - missing required argument.
         self.assert_parse_error("volgroup vg.01 pv.01 --reserved-space", KickstartParseError)
@@ -57,5 +67,11 @@ class F16_TestCase(FC3_TestCase):
         self.assert_parse_error("volgroup vg.01 pv.01 --reserved-percent=0", KickstartValueError)
         self.assert_parse_error("volgroup vg.01 pv.01 --reserved-percent=100", KickstartValueError)
 
+class RHEL7_TestCase(F16_TestCase):
+    def runTest(self):
+        # just run all the old tests with the new class (different PE size
+        # default)
+        F16_TestCase.runTest(self)
+
 if __name__ == "__main__":
     unittest.main()
-- 
1.9.3



More information about the anaconda-patches mailing list