[3/3 anaconda] Add --disklabel support to clearpart (#1078537)

Brian C. Lane bcl at redhat.com
Wed Jun 18 23:27:05 UTC 2014


This adds an optional --disklabel=<disklabel> switch to clearpart,
allowing the kickstart to specify a supported disklabel as the default.
If the specified disklabel is not supported on the current platform a
KickstartValueError will be raised.
---
 pyanaconda/kickstart.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py
index 2435ee5..cbb48f0 100644
--- a/pyanaconda/kickstart.py
+++ b/pyanaconda/kickstart.py
@@ -28,6 +28,7 @@ from blivet.partitioning import doPartitioning
 from blivet.partitioning import growLVM
 from blivet.size import Size
 from blivet import udev
+from blivet.platform import platform
 import blivet.iscsi
 import blivet.fcoe
 import blivet.zfcp
@@ -508,13 +509,18 @@ class Realm(commands.realm.F19_Realm):
         log.info("Joined realm %s", self.join_realm)
 
 
-class ClearPart(commands.clearpart.F17_ClearPart):
+class ClearPart(commands.clearpart.F21_ClearPart):
     def parse(self, args):
-        retval = commands.clearpart.F17_ClearPart.parse(self, args)
+        retval = commands.clearpart.F21_ClearPart.parse(self, args)
 
         if self.type is None:
             self.type = CLEARPART_TYPE_NONE
 
+        if self.disklabel and self.disklabel not in platform.diskLabelTypes:
+            raise KickstartValueError(formatErrorMsg(self.lineno,
+                    msg=_("Disklabel \"%s\" given in clearpart command is not "
+                          "supported on this platform.") % self.disklabel))
+
         # Do any glob expansion now, since we need to have the real list of
         # disks available before the execute methods run.
         drives = []
@@ -551,6 +557,11 @@ class ClearPart(commands.clearpart.F17_ClearPart):
         if self.initAll:
             storage.config.initializeDisks = self.initAll
 
+        if self.disklabel:
+            if not platform.setDefaultDiskLabelType(self.disklabel):
+                log.warn("%s is not a supported disklabel type on this platform. "
+                         "Using default disklabel %s instead.", self.disklabel, platform.defaultDiskLabelType)
+
         storage.clearPartitions()
 
 class Fcoe(commands.fcoe.F13_Fcoe):
-- 
1.9.3



More information about the anaconda-patches mailing list