From c0c04cc76cd933a5159403281c16f639b3717321 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Wed, 18 Jun 2014 16:14:18 -0700 Subject: [PATCH] Add --disklabel support to clearpart (#1078537) This adds an optional --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. --- anaconda.spec.in | 4 ++-- pyanaconda/kickstart.py | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/anaconda.spec.in b/anaconda.spec.in index 1bb458fd69a..68d8566358e 100644 --- a/anaconda.spec.in +++ b/anaconda.spec.in @@ -21,7 +21,7 @@ Source0: %{name}-%{version}.tar.bz2 # Also update in AM_GNU_GETTEXT_VERSION in configure.ac %define gettextver 0.18.3 %define intltoolver 0.31.2-3 -%define pykickstartver 1.99.55 +%define pykickstartver 1.99.56 %define yumver 3.4.3-91 %define dnfver 0.4.18 %define partedver 1.8.1 @@ -91,7 +91,7 @@ The anaconda package is a metapackage for the Anaconda installer. %package core Summary: Core of the Anaconda installer Requires: dnf >= %{dnfver} -Requires: python-blivet >= 0.56 +Requires: python-blivet >= 0.57 Requires: python-meh >= %{mehver} Requires: libreport-anaconda >= 2.0.21-1 Requires: libselinux-python diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py index 2435ee5d01a..cbb48f0ea4c 100644 --- a/pyanaconda/kickstart.py +++ b/pyanaconda/kickstart.py @@ -28,6 +28,7 @@ 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 @@ def execute(self, *args): 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 @@ def execute(self, storage, ksdata, instClass): 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):