[rhel6-branch] add unsupported_hardware command (#824963)

Brian C. Lane bcl at redhat.com
Fri Sep 28 17:36:44 UTC 2012


From: "Brian C. Lane" <bcl at redhat.com>

Used by RHEL6 to skip tainted hardware warning dialog during kickstart
installs.
---
 pykickstart/commands/__init__.py             |  4 +-
 pykickstart/commands/unsupported_hardware.py | 55 ++++++++++++++++++++++++++++
 pykickstart/handlers/control.py              |  1 +
 tests/commands/unsupported_hardware.py       | 19 ++++++++++
 4 files changed, 77 insertions(+), 2 deletions(-)
 create mode 100644 pykickstart/commands/unsupported_hardware.py
 create mode 100644 tests/commands/unsupported_hardware.py

diff --git a/pykickstart/commands/__init__.py b/pykickstart/commands/__init__.py
index da48ff5..9c38242 100644
--- a/pykickstart/commands/__init__.py
+++ b/pykickstart/commands/__init__.py
@@ -22,5 +22,5 @@ import deviceprobe, displaymode, dmraid, driverdisk, fcoe, firewall, firstboot
 import group, ignoredisk, interactive, iscsi, iscsiname, key, keyboard, lang
 import langsupport, lilocheck, logging, logvol, mediacheck, method, monitor
 import mouse, multipath, network, partition, raid, reboot, repo, rescue, rootpw
-import selinux, services, skipx, sshpw, timezone, updates, upgrade, user, vnc
-import volgroup, xconfig, zerombr, zfcp
+import selinux, services, skipx, sshpw, timezone, updates, upgrade, user
+import unsupported_hardware, vnc, volgroup, xconfig, zerombr, zfcp
diff --git a/pykickstart/commands/unsupported_hardware.py b/pykickstart/commands/unsupported_hardware.py
new file mode 100644
index 0000000..5776ce6
--- /dev/null
+++ b/pykickstart/commands/unsupported_hardware.py
@@ -0,0 +1,55 @@
+#
+# Brian C. Lane <bcl at redhat.com>
+#
+# Copyright 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
+# General Public License v.2.  This program is distributed in the hope that it
+# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
+# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 51
+# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat
+# trademarks that are incorporated in the source code or documentation are not
+# subject to the GNU General Public License and may only be used or replicated
+# with the express permission of Red Hat, Inc.
+#
+from pykickstart.base import *
+from pykickstart.errors import *
+from pykickstart.options import *
+
+import gettext
+_ = lambda x: gettext.ldgettext("pykickstart", x)
+
+class RHEL6_UnsupportedHardware(KickstartCommand):
+    removedKeywords = KickstartCommand.removedKeywords
+    removedAttrs = KickstartCommand.removedAttrs
+
+    def __init__(self, writePriority=0, *args, **kwargs):
+        KickstartCommand.__init__(self, writePriority, *args, **kwargs)
+        self.op = self._getParser()
+        self.unsupported_hardware = kwargs.get("unsupported_hardware", False)
+
+    def __str__(self):
+        retval = KickstartCommand.__str__(self)
+
+        if self.unsupported_hardware:
+            retval += "unsupported_hardware\n"
+
+        return retval
+
+    def _getParser(self):
+        op = KSOptionParser()
+        return op
+
+    def parse(self, args):
+        (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
+
+        if len(extra) > 0:
+            raise KickstartParseError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % self.currentCmd)
+
+        self.unsupported_hardware = True
+        return self
diff --git a/pykickstart/handlers/control.py b/pykickstart/handlers/control.py
index 56d892a..cf24586 100644
--- a/pykickstart/handlers/control.py
+++ b/pykickstart/handlers/control.py
@@ -860,6 +860,7 @@ commandMap = {
         "sshpw": sshpw.F13_SshPw,
         "text": displaymode.FC3_DisplayMode,
         "timezone": timezone.FC6_Timezone,
+        "unsupported_hardware": unsupported_hardware.RHEL6_UnsupportedHardware,
         "updates": updates.F7_Updates,
         "upgrade": upgrade.F11_Upgrade,
         "url": method.RHEL6_Method,
diff --git a/tests/commands/unsupported_hardware.py b/tests/commands/unsupported_hardware.py
new file mode 100644
index 0000000..1348679
--- /dev/null
+++ b/tests/commands/unsupported_hardware.py
@@ -0,0 +1,19 @@
+import unittest, shlex
+import warnings
+from tests.baseclass import *
+
+from pykickstart.errors import *
+from pykickstart.commands.unsupported_hardware import *
+
+class RHEL6_TestCase(CommandTest):
+    command = "unsupported_hardware"
+
+    def runTest(self):
+        # pass
+        self.assert_parse("unsupported_hardware")
+
+        # fail
+        self.assert_parse_error("unsupported_hardware --cheese")
+
+if __name__ == "__main__":
+    unittest.main()
-- 
1.7.11.4



More information about the anaconda-patches mailing list