[PATCH] Allow "ignoredisk" to explicitly specify interactive usage (#596804)

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

 



We want the user to be able to manually navigate advanced storage when
using a ks.cfg without partitioning sections.
---
 pykickstart/commands/ignoredisk.py |   47 +++++++++++++++++++++++++++++++++--
 pykickstart/handlers/control.py    |    2 +-
 tests/commands/ignoredisk.py       |   17 +++++++++++++
 3 files changed, 62 insertions(+), 4 deletions(-)

diff --git a/pykickstart/commands/ignoredisk.py b/pykickstart/commands/ignoredisk.py
index 607d696..83e1048 100644
--- a/pykickstart/commands/ignoredisk.py
+++ b/pykickstart/commands/ignoredisk.py
@@ -77,11 +77,12 @@ class F8_IgnoreDisk(FC3_IgnoreDisk):
 
         return retval
 
-    def parse(self, args):
+    def parse(self, args, errorCheck=True):
         retval = FC3_IgnoreDisk.parse(self, args)
 
-        if (len(self.ignoredisk) == 0 and len(self.onlyuse) == 0) or (len(self.ignoredisk) > 0 and (len(self.onlyuse) > 0)):
-            raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --drives or --only-use must be specified for ignoredisk command."))
+        if errorCheck:
+            if (len(self.ignoredisk) == 0 and len(self.onlyuse) == 0) or (len(self.ignoredisk) > 0 and (len(self.onlyuse) > 0)):
+                raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --drives or --only-use must be specified for ignoredisk command."))
 
         return retval
 
@@ -96,3 +97,43 @@ class F8_IgnoreDisk(FC3_IgnoreDisk):
         op.add_option("--only-use", dest="onlyuse", action="callback",
                       callback=drive_cb, nargs=1, type="string")
         return op
+
+class RHEL6_IgnoreDisk(F8_IgnoreDisk):
+    removedKeywords = F8_IgnoreDisk.removedKeywords
+    removedAttrs = F8_IgnoreDisk.removedAttrs
+
+    def __init__(self, writePriority=0, *args, **kwargs):
+        F8_IgnoreDisk.__init__(self, writePriority, *args, **kwargs)
+
+        self.interactive = kwargs.get("interactive", False)
+        if self.interactive:
+            self.ignoredisk = []
+
+    def __str__(self):
+        retval = F8_IgnoreDisk.__str__(self)
+
+        if self.interactive:
+            retval = "ignoredisk --interactive\n"
+
+        return retval
+
+    def parse(self, args):
+        retval = F8_IgnoreDisk.parse(self, args, errorCheck=False)
+
+        howmany = 0
+        if len(self.ignoredisk) > 0:
+            howmany += 1
+        if len(self.onlyuse) > 0:
+            howmany += 1
+        if self.interactive:
+            howmany += 1
+        if howmany != 1:
+            raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --drives , --only-use , or --interactive must be specified for ignoredisk command."))
+
+        return retval
+
+    def _getParser(self):
+        op = F8_IgnoreDisk._getParser(self)
+        op.add_option("--interactive", dest="interactive", action="store_true",
+                      default=False)
+        return op
diff --git a/pykickstart/handlers/control.py b/pykickstart/handlers/control.py
index 51651b8..2bcb566 100644
--- a/pykickstart/handlers/control.py
+++ b/pykickstart/handlers/control.py
@@ -830,7 +830,7 @@ commandMap = {
         "group": group.F12_Group,
         "halt": reboot.FC6_Reboot,
         "harddrive": method.F13_Method,
-        "ignoredisk": ignoredisk.F8_IgnoreDisk,
+        "ignoredisk": ignoredisk.RHEL6_IgnoreDisk,
         "install": upgrade.F11_Upgrade,
         "interactive": interactive.FC3_Interactive,
         "iscsi": iscsi.F10_Iscsi,
diff --git a/tests/commands/ignoredisk.py b/tests/commands/ignoredisk.py
index 23c5840..f535689 100644
--- a/tests/commands/ignoredisk.py
+++ b/tests/commands/ignoredisk.py
@@ -59,5 +59,22 @@ class F8_TestCase(FC3_TestCase):
         self.assert_parse_error("ignoredisk --drives=sda --only-use=sdb", KickstartValueError)
         self.assert_parse_error("ignoredisk --only-use=sda --drives=sdb", KickstartValueError)
 
+class RHEL6_TestCase(F8_TestCase):
+    def runTest(self):
+        # Run parents class tests
+        F8_TestCase.runTest(self)
+
+        # pass
+        self.assert_parse("ignoredisk --interactive", "ignoredisk --interactive\n")
+
+        # fail
+        # both options provided
+        self.assert_parse_error("ignoredisk --drives=sda --interactive", KickstartValueError)
+        self.assert_parse_error("ignoredisk --interactive --drives=sda", KickstartValueError)
+        self.assert_parse_error("ignoredisk --only-use=sda --interactive", KickstartValueError)
+        self.assert_parse_error("ignoredisk --interactive --only-use=sda", KickstartValueError)
+        self.assert_parse_error("ignoredisk --interactive --drives=sda --only-use=sdb", KickstartValueError)
+        self.assert_parse_error("ignoredisk --only-use=sda --drives=sdb --interactive", KickstartValueError)
+
 if __name__ == "__main__":
     unittest.main()
-- 
1.7.0.1

_______________________________________________
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