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

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

 



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

diff --git a/pykickstart/commands/autopart.py b/pykickstart/commands/autopart.py
index 3ea3a16..d4b6873 100644
--- a/pykickstart/commands/autopart.py
+++ b/pykickstart/commands/autopart.py
@@ -119,3 +119,32 @@ 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):
+        def lvm_cb (option, opt_str, value, parser):
+            parser.values.lvm = False
+
+        op = F12_AutoPart._getParser(self)
+        op.add_option("--nolvm", action="callback", callback=lvm_cb,
+                      dest="lvm", default=True, nargs=0)
+        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

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux