[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH 2/2] Add support for 'autopart --nolvm'



---
 pykickstart/commands/autopart.py |   26 ++++++++++++++++++++++++++
 pykickstart/handlers/control.py  |    2 +-
 tests/commands/autopart.py       |   15 +++++++++++++++
 3 files changed, 42 insertions(+), 1 deletions(-)

diff --git a/pykickstart/commands/autopart.py b/pykickstart/commands/autopart.py
index 3ea3a16..c104380 100644
--- a/pykickstart/commands/autopart.py
+++ b/pykickstart/commands/autopart.py
@@ -119,3 +119,29 @@ class F12_AutoPart(F9_AutoPart):
         op.add_option("--escrowcert")
         op.add_option("--backuppassphrase", action="store_true", default=False)
         return op
+
+class F16_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.lvm = kwargs.get("lvm", True)
+
+    def __str__(self):
+        retval = F12_AutoPart.__str__(self)
+
+        # If requested, disable LVM autopart
+        if not self.lvm:
+            # remove any trailing newline
+            retval = retval.strip()
+            retval += " --nolvm"
+            retval += "\n"
+
+        return retval
+
+    def _getParser(self):
+        op = F12_AutoPart._getParser(self)
+        op.add_option("--nolvm", action="store_false", dest="lvm",
+            default=True)
+        return op
diff --git a/pykickstart/handlers/control.py b/pykickstart/handlers/control.py
index d8c8f2b..27cbaad 100644
--- a/pykickstart/handlers/control.py
+++ b/pykickstart/handlers/control.py
@@ -767,7 +767,7 @@ commandMap = {
     F16: {
         "auth": authconfig.FC3_Authconfig,
         "authconfig": authconfig.FC3_Authconfig,
-        "autopart": autopart.F12_AutoPart,
+        "autopart": autopart.F16_AutoPart,
         "autostep": autostep.FC3_AutoStep,
         "bootloader": bootloader.F15_Bootloader,
         "cdrom": method.F14_Method,
diff --git a/tests/commands/autopart.py b/tests/commands/autopart.py
index 51c663e..5949fea 100644
--- a/tests/commands/autopart.py
+++ b/tests/commands/autopart.py
@@ -79,5 +79,20 @@ class F12_TestCase(F9_TestCase):
         self.assert_parse_error("autopart --backuppassphrase=False")
         self.assert_parse_error("autopart --backuppassphrase=True")
 
+class F16_TestCase(F12_TestCase):
+    def runTest(self):
+        # Run F12 test case
+        F12_TestCase.runTest(self)
+
+        # pass
+        self.assert_parse("autopart --nolvm",
+                          "autopart --nolvm\n")
+
+        # fail
+        self.assert_parse_error("autopart --nolvm=asdf")
+        self.assert_parse_error("autopart --nolvm True", KickstartValueError)
+        self.assert_parse_error("autopart --nolvm=1")
+        self.assert_parse_error("autopart --nolvm 0", KickstartValueError)
+
 if __name__ == "__main__":
     unittest.main()
-- 
1.7.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]