Similar to the code that went into rhel06, this adds a new function to devicelibs.dasd in order to detect LDL DASDs. There is also some code in the gui/tui storage spokes to create a list of any LDL DASDs and prompt the user to run dasdfmt against them.
The cleaerpart --cdl option basically says, if there are any LDL DASDs on my system detected during my ks install, run dasdfmt on them.
I will say that I have not had a chance to really test the clearpart --cdl option, so bear that in mind, but I think that it should be ok.
Thanks to Peter Jones pjones@redhat.com for this addition.
Resolves: rhbz#1233438 --- blivet/devicelibs/dasd.py | 112 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 2 deletions(-)
diff --git a/blivet/devicelibs/dasd.py b/blivet/devicelibs/dasd.py index 73284e8..8d2cbd2 100644 --- a/blivet/devicelibs/dasd.py +++ b/blivet/devicelibs/dasd.py @@ -1,7 +1,7 @@ # # dasd.py - DASD functions # -# Copyright (C) 2013 Red Hat, Inc. All rights reserved. +# Copyright (C) 2015 Red Hat, Inc. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,9 +16,12 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/. # -# Red Hat Author(s): Samantha N. Bueno +# Red Hat Author(s): Samantha N. Bueno sbueno@redhat.com +# Peter Jones pjones@redhat.com #
+import fcntl +import ctypes import os from blivet.errors import DasdFormatError from blivet.devices import deviceNameToDiskByPath @@ -32,6 +35,111 @@ import gettext _ = lambda x: gettext.ldgettext("blivet", x) P_ = lambda x, y, z: gettext.ldngettext("blivet", x, y, z)
+# ioctl crap that the fcntl module should really do for us... +_IOC_NRBITS = 8 +_IOC_TYPEBITS = 8 +_IOC_SIZEBITS = 14 +_IOC_DIRBITS = 2 + +_IOC_NRMASK = ((1 << _IOC_NRBITS)-1) +_IOC_TYPEMASK = ((1 << _IOC_TYPEBITS)-1) +_IOC_SIZEMASK = ((1 << _IOC_SIZEBITS)-1) +_IOC_DIRMASK = ((1 << _IOC_DIRBITS)-1) + +_IOC_NRSHIFT = 0 +_IOC_TYPESHIFT = (_IOC_NRSHIFT+_IOC_NRBITS) +_IOC_SIZESHIFT = (_IOC_TYPESHIFT+_IOC_TYPEBITS) +_IOC_DIRSHIFT = (_IOC_SIZESHIFT+_IOC_SIZEBITS) + +_IOC_NONE = 0 +_IOC_WRITE = 1 +_IOC_READ = 2 + +def _IOC(dir, typ, nr, size): + return (((dir) << _IOC_DIRSHIFT) | \ + ((typ) << _IOC_TYPESHIFT) | \ + ((nr) << _IOC_NRSHIFT) | \ + ((size) << _IOC_SIZESHIFT)) + +def _IO(typ, nr): + return _IOC(_IOC_NONE, typ, nr, 0) +def _IOR(typ, nr, size): + return _IOC(_IOC_READ, typ, nr, size) +def _IOW(typ, nr, size): + return _IOC(_IOC_WRITE, typ, nr, size) +def _IOWR(typ, nr, size): + return _IOC(_IOC_WRITE|_IOC_READ, typ, nr, size) + +BLKSSZGET = int(_IO(0x12, 104)) +BIODASDINFO2 = int(_IOR(ord('D'), 3, 416)) + +# and now just do our thing +class blksize(ctypes.Structure): + _fields_ = [ + ('blksize', ctypes.c_uint), + ] + +class dasd_info(ctypes.Structure): + _fields_ = [ + ('devno', ctypes.c_uint), + ('real_devno', ctypes.c_uint), + ('schid', ctypes.c_uint), + ('cu_type_model', ctypes.c_uint), + ('dev_type_model', ctypes.c_uint), + ('open_count', ctypes.c_uint), + ('req_queue_len', ctypes.c_uint), + ('chanq_len', ctypes.c_uint), + ('type', ctypes.c_char * 4), + ('status', ctypes.c_uint), + ('label_block', ctypes.c_uint), + ('FBA_layout', ctypes.c_uint), + ('characteristics_size', ctypes.c_uint), + ('confdata_size', ctypes.c_uint), + ('characteristics', ctypes.c_char * 64), + ('configuration_data', ctypes.c_char * 256), + ('format', ctypes.c_uint), + ('features', ctypes.c_uint), + ('reserved0', ctypes.c_uint), + ('reserved1', ctypes.c_uint), + ('reserved2', ctypes.c_uint), + ('reserved3', ctypes.c_uint), + ('reserved4', ctypes.c_uint), + ('reserved5', ctypes.c_uint), + ('reserved6', ctypes.c_uint), + ('reserved7', ctypes.c_uint), + ('reserved8', ctypes.c_uint), + ] + +DASD_FORMAT_CDL = 2 + +def is_ldl_dasd(device): + """Determine whether or not a DASD is LDL formatted.""" + device = "/dev/%s" % (device,) + + f = open(device, "r") + + # poorly check if this is even a block device... + arg = blksize() + rc = fcntl.ioctl(f.fileno(), BLKSSZGET, arg, True) + if rc < 0: + return False + + # alright, it's a block device, so get some info about DASD... + arg = dasd_info() + rc = fcntl.ioctl(f.fileno(), BIODASDINFO2, arg) + if rc < 0: + return False + + # check we're not on an FBA DASD, since dasdfmt can't run on them + if arg.type[0:2] == 'FBA': + return False + + # check DASD volume label; "VOL1" is CDL formatted DASD, won't + # require formatting + if arg.format == DASD_FORMAT_CDL: + return False + return True + def get_dasd_ports(): """ Return comma delimited string of valid DASD ports. """ ports = []
On Fri, 2015-06-19 at 10:59 -0400, Samantha N. Bueno wrote:
Thanks to Peter Jones pjones@redhat.com for this addition.
Resolves: rhbz#1233438
blivet/devicelibs/dasd.py | 112 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 2 deletions(-)
diff --git a/blivet/devicelibs/dasd.py b/blivet/devicelibs/dasd.py index 73284e8..8d2cbd2 100644 --- a/blivet/devicelibs/dasd.py +++ b/blivet/devicelibs/dasd.py @@ -1,7 +1,7 @@ # # dasd.py - DASD functions # -# Copyright (C) 2013 Red Hat, Inc. All rights reserved. +# Copyright (C) 2015 Red Hat, Inc. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,9 +16,12 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/. # -# Red Hat Author(s): Samantha N. Bueno +# Red Hat Author(s): Samantha N. Bueno sbueno@redhat.com +# Peter Jones pjones@redhat.com #
+import fcntl +import ctypes import os from blivet.errors import DasdFormatError from blivet.devices import deviceNameToDiskByPath @@ -32,6 +35,111 @@ import gettext _ = lambda x: gettext.ldgettext("blivet", x) P_ = lambda x, y, z: gettext.ldngettext("blivet", x, y, z)
+# ioctl crap that the fcntl module should really do for us... +_IOC_NRBITS = 8 +_IOC_TYPEBITS = 8 +_IOC_SIZEBITS = 14 +_IOC_DIRBITS = 2
+_IOC_NRMASK = ((1 << _IOC_NRBITS)-1) +_IOC_TYPEMASK = ((1 << _IOC_TYPEBITS)-1) +_IOC_SIZEMASK = ((1 << _IOC_SIZEBITS)-1) +_IOC_DIRMASK = ((1 << _IOC_DIRBITS)-1)
+_IOC_NRSHIFT = 0 +_IOC_TYPESHIFT = (_IOC_NRSHIFT+_IOC_NRBITS) +_IOC_SIZESHIFT = (_IOC_TYPESHIFT+_IOC_TYPEBITS) +_IOC_DIRSHIFT = (_IOC_SIZESHIFT+_IOC_SIZEBITS)
+_IOC_NONE = 0 +_IOC_WRITE = 1 +_IOC_READ = 2
+def _IOC(dir, typ, nr, size):
- return (((dir) << _IOC_DIRSHIFT) | \
((typ) << _IOC_TYPESHIFT) | \((nr) << _IOC_NRSHIFT) | \((size) << _IOC_SIZESHIFT))+def _IO(typ, nr):
- return _IOC(_IOC_NONE, typ, nr, 0)
+def _IOR(typ, nr, size):
- return _IOC(_IOC_READ, typ, nr, size)
+def _IOW(typ, nr, size):
- return _IOC(_IOC_WRITE, typ, nr, size)
+def _IOWR(typ, nr, size):
- return _IOC(_IOC_WRITE|_IOC_READ, typ, nr, size)
+BLKSSZGET = int(_IO(0x12, 104)) +BIODASDINFO2 = int(_IOR(ord('D'), 3, 416))
+# and now just do our thing +class blksize(ctypes.Structure):
- _fields_ = [
('blksize', ctypes.c_uint),- ]
+class dasd_info(ctypes.Structure):
- _fields_ = [
('devno', ctypes.c_uint),('real_devno', ctypes.c_uint),('schid', ctypes.c_uint),('cu_type_model', ctypes.c_uint),('dev_type_model', ctypes.c_uint),('open_count', ctypes.c_uint),('req_queue_len', ctypes.c_uint),('chanq_len', ctypes.c_uint),('type', ctypes.c_char * 4),('status', ctypes.c_uint),('label_block', ctypes.c_uint),('FBA_layout', ctypes.c_uint),('characteristics_size', ctypes.c_uint),('confdata_size', ctypes.c_uint),('characteristics', ctypes.c_char * 64),('configuration_data', ctypes.c_char * 256),('format', ctypes.c_uint),('features', ctypes.c_uint),('reserved0', ctypes.c_uint),('reserved1', ctypes.c_uint),('reserved2', ctypes.c_uint),('reserved3', ctypes.c_uint),('reserved4', ctypes.c_uint),('reserved5', ctypes.c_uint),('reserved6', ctypes.c_uint),('reserved7', ctypes.c_uint),('reserved8', ctypes.c_uint),- ]
+DASD_FORMAT_CDL = 2
+def is_ldl_dasd(device):
- """Determine whether or not a DASD is LDL formatted."""
- device = "/dev/%s" % (device,)
- f = open(device, "r")
- # poorly check if this is even a block device...
- arg = blksize()
- rc = fcntl.ioctl(f.fileno(), BLKSSZGET, arg, True)
- if rc < 0:
return False- # alright, it's a block device, so get some info about DASD...
- arg = dasd_info()
- rc = fcntl.ioctl(f.fileno(), BIODASDINFO2, arg)
- if rc < 0:
return False- # check we're not on an FBA DASD, since dasdfmt can't run on them
- if arg.type[0:2] == 'FBA':
return False- # check DASD volume label; "VOL1" is CDL formatted DASD, won't
- # require formatting
- if arg.format == DASD_FORMAT_CDL:
return False- return True
def get_dasd_ports(): """ Return comma delimited string of valid DASD ports. """ ports = []
Wow, I must say this is one of the ugliest pieces of "Python" code I've ever seen. But for sure better than adding C code to blivet.
Specifying this option in a ks file will ensure that any LDL DASDs will be (re)formatted to CDL format.
Resolves: rhbz#1232849 --- pykickstart/commands/clearpart.py | 5 +++++ tests/commands/clearpart.py | 6 ++++++ 2 files changed, 11 insertions(+)
diff --git a/pykickstart/commands/clearpart.py b/pykickstart/commands/clearpart.py index 0164215..a63b258 100644 --- a/pykickstart/commands/clearpart.py +++ b/pykickstart/commands/clearpart.py @@ -113,16 +113,21 @@ class F21_ClearPart(F17_ClearPart): def __init__(self, *args, **kwargs): super(F21_ClearPart, self).__init__(*args, **kwargs) self.disklabel = kwargs.get("disklabel", "") + self.cdl = kwargs.get("cdl", False)
def __str__(self): s = super(F21_ClearPart, self).__str__() if s and self.disklabel: s = s.rstrip() s += " --disklabel=%s\n" % self.disklabel + if s and self.cdl: + s = s.rstrip() + s += " --cdl\n" return s
def _getParser(self): op = F17_ClearPart._getParser(self)
op.add_option("--disklabel", dest="disklabel", default="") + op.add_option("--cdl", dest="cdl", action="store_true", default=False) return op diff --git a/tests/commands/clearpart.py b/tests/commands/clearpart.py index e044085..0b493c8 100644 --- a/tests/commands/clearpart.py +++ b/tests/commands/clearpart.py @@ -43,5 +43,11 @@ class F21_TestCase(F17_TestCase): "clearpart --all --initlabel --disklabel=gpt\n") self.assert_parse_error("clearpart --all --disklabel")
+ self.assert_parse("clearpart --all --cdl", "clearpart --all --cdl \n") + self.assert_parse("clearpart --all --cdl --drives=dasda,dasdb,dasdc", "clearpart --all --cdl --drives=dasda,dasdb,dasdc \n") + + # cdl should not take a value + self.assert_parse_error("clearpart --cdl=foo") + if __name__ == "__main__": unittest.main()
This checks for the clearpart --cdl ks option and takes appropriate action if it's specified (automatically format any detected LDL DASDs).
This also adds a general check (during interactive installations) for LDL DASDs and shows the user the dasdfmt dialog box.
And to anyone wondering why we show the dasdfmt dialog twice (once for unformatted, once for LDL), it is to give users the option of formatting unformatted DASDs but not LDL (or vice versa).
Resolves: rhbz#1170656 Resolves: rhbz#1170653 --- pyanaconda/ui/gui/spokes/storage.py | 71 ++++++++++++++++++++++++++++--------- pyanaconda/ui/tui/spokes/storage.py | 38 ++++++++++---------- 2 files changed, 74 insertions(+), 35 deletions(-)
diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py index fc65a0f..468daa0 100644 --- a/pyanaconda/ui/gui/spokes/storage.py +++ b/pyanaconda/ui/gui/spokes/storage.py @@ -61,7 +61,7 @@ from blivet.devices import MultipathDevice from blivet.errors import StorageError, DasdFormatError from blivet.platform import platform from blivet.devicelibs import swap as swap_lib -from blivet.devicelibs.dasd import make_unformatted_dasd_list, format_dasd +from blivet.devicelibs.dasd import make_unformatted_dasd_list, format_dasd, is_ldl_dasd from pyanaconda.threads import threadMgr, AnacondaThread from pyanaconda.product import productName from pyanaconda.flags import flags @@ -251,10 +251,10 @@ class StorageSpoke(NormalSpoke, StorageChecker): self.autoPartType = None self.clearPartType = CLEARPART_TYPE_NONE
- if self.data.zerombr.zerombr and arch.isS390(): - # run dasdfmt on any unformatted DASDs automatically + if arch.isS390() and (self.data.zerombr.zerombr or self.data.clearpart.cdl): + # run dasdfmt on any unformatted or LDL DASDs automatically threadMgr.add(AnacondaThread(name=constants.THREAD_DASDFMT, - target=self.run_dasdfmt)) + target=self.run_dasdfmt, args=(self.data.zerombr.zerombr, self.data.clearpart.cdl)))
self._previous_autopart = False
@@ -617,7 +617,7 @@ class StorageSpoke(NormalSpoke, StorageChecker): if not selected and name in self.selected_disks: self.selected_disks.remove(name)
- def run_dasdfmt(self): + def run_dasdfmt(self, askuser, cdl): """ Though the same function exists in pyanaconda.ui.gui.spokes.lib.dasdfmt, this instance doesn't include any of the UI pieces and should only @@ -627,19 +627,36 @@ class StorageSpoke(NormalSpoke, StorageChecker): # actions on storage devices threadMgr.wait(constants.THREAD_STORAGE)
- to_format = make_unformatted_dasd_list(d.name for d in getDisks(self.storage.devicetree)) - if not to_format: - # nothing to do here; bail - return + if askuser: + unformatted = make_unformatted_dasd_list(d.name for d in getDisks(self.storage.devicetree)) + if not unformatted: + # nothing to do here; bail + return
- hubQ.send_message(self.__class__.__name__, _("Formatting DASDs")) - for disk in to_format: - try: - format_dasd(disk) - except DasdFormatError as err: - # Log errors if formatting fails, but don't halt the installer - log.error(str(err)) - continue + hubQ.send_message(self.__class__.__name__, _("Formatting DASDs")) + for disk in unformatted: + try: + format_dasd(disk) + except DasdFormatError as err: + # Log errors if formatting fails, but don't halt the installer + log.error(str(err)) + continue + + if cdl: + ldldasds = [d.name for d in getDisks(self.storage.devicetree) if is_ldl_dasd(d.name)] + log.debug(ldldasds) + if not ldldasds: + # nothing to do here; bail + return + + hubQ.send_message(self.__class__.__name__, _("Formatting DASDs")) + for disk in ldldasds: + try: + format_dasd(disk) + except DasdFormatError as err: + # Log errors if formatting fails, but don't halt the installer + log.error(str(err)) + continue
# I really hate doing this, but the way is the way; probably the most # correct way to kajigger the storage spoke into becoming ready @@ -757,6 +774,26 @@ class StorageSpoke(NormalSpoke, StorageChecker): # back to the hub. return
+ # check for ldl dasds + ldldasds = [d for d in self.selected_disks if is_ldl_dasd(d)] + if len(ldldasds) > 0: + dialog = DasdFormatDialog(self.data, self.storage, ldldasds) + ignoreEscape(dialog.window) + rc = self.run_lightbox_dialog(dialog) + if rc == 1: + # User hit OK on the dialog + self.refresh() + elif rc == 2: + # User clicked uri to return to hub. + NormalSpoke.on_back_clicked(self, button) + return + elif rc != 2: + # User either hit cancel on the dialog or closed it via escape, + # there was no formatting done. + # NOTE: rc == 2 means the user clicked on the link that takes t + # back to the hub. + return + # Figure out if the existing disk labels will work on this platform # you need to have at least one of the platform's labels in order for # any of the free space to be useful. diff --git a/pyanaconda/ui/tui/spokes/storage.py b/pyanaconda/ui/tui/spokes/storage.py index 2df64ed..16b1467 100644 --- a/pyanaconda/ui/tui/spokes/storage.py +++ b/pyanaconda/ui/tui/spokes/storage.py @@ -33,7 +33,7 @@ from blivet import arch from blivet.size import Size from blivet.errors import StorageError, DasdFormatError from blivet.devices import DASDDevice, FcoeDiskDevice, iScsiDiskDevice, MultipathDevice, ZFCPDiskDevice -from blivet.devicelibs.dasd import format_dasd, make_unformatted_dasd_list +from blivet.devicelibs.dasd import format_dasd, make_unformatted_dasd_list, is_ldl_dasd from pyanaconda.flags import flags from pyanaconda.kickstart import doKickstartStorage, resetCustomStorageData from pyanaconda.threads import threadMgr, AnacondaThread @@ -84,12 +84,10 @@ class StorageSpoke(NormalTUISpoke): self.errors = [] self.warnings = []
- if self.data.zerombr.zerombr and arch.isS390(): - # if zerombr is specified in a ks file and there are unformatted - # dasds, automatically format them - to_format = make_unformatted_dasd_list(self.selected_disks) - if to_format: - self.run_dasdfmt(to_format) + # automatically dasdfmt any unformatted/ldl dasds if a user has + # specified zerombr/cdl in their ks file + if arch.isS390() and (self.data.zerombr.zerombr or self.data.clearpart.cdl): + self.run_dasdfmt(self.selected_disks, self.data.zerombr.zerombr, self.data.clearpart.cdl)
if not flags.automatedInstall: # default to using autopart for interactive installs @@ -270,13 +268,17 @@ class StorageSpoke(NormalTUISpoke): except (ValueError, IndexError): if key.lower() == "c": if self.selected_disks: - # check selected disks to see if we have any unformatted DASDs - # if we're on s390x, since they need to be formatted before we - # can use them. + # check selected disks to see if we have any unformatted or + # LDL DASDs if we're on s390x, since they need to be + # formatted before we can use them. if arch.isS390(): - to_format = make_unformatted_dasd_list(self.selected_disks) - if to_format: - self.run_dasdfmt(to_format) + dasds = make_unformatted_dasd_list(self.selected_disks) + if dasds: + self.run_dasdfmt(dasds) + return None + ldldasds = [d for d in self.selected_disks if is_ldl_dasd(d)] + if ldldasds: + self.run_dasdfmt(ldldasds) return None
newspoke = AutoPartSpoke(self.app, self.data, self.storage, @@ -289,7 +291,7 @@ class StorageSpoke(NormalTUISpoke): else: return key
- def run_dasdfmt(self, to_format): + def run_dasdfmt(self, to_format, zerombr, cdl): """ This generates the list of DASDs requiring dasdfmt and runs dasdfmt against them. @@ -299,8 +301,8 @@ class StorageSpoke(NormalTUISpoke): # zerombr in their ks file threadMgr.wait(THREAD_STORAGE)
- # ask user to verify they want to format if zerombr not in ks file - if not self.data.zerombr.zerombr: + # ask user to verify they want to format if zerombr or cdl not in ks file + if not (self.data.zerombr.zerombr or self.data.clearpart.cdl): # prepare our msg strings; copied directly from dasdfmt.glade summary = _("The following unformatted DASDs have been detected on your system. You can choose to format them now with dasdfmt or cancel to leave them unformatted. Unformatted DASDs can not be used during installation.\n\n")
@@ -309,8 +311,8 @@ class StorageSpoke(NormalTUISpoke): displaytext = summary + "\n".join("/dev/" + d for d in to_format) + "\n" + warntext
# now show actual prompt; note -- in cmdline mode, auto-answer for - # this is 'no', so unformatted DASDs will remain so unless zerombr - # is added to the ks file + # this is 'no', so unformatted and ldl DASDs will remain so unless + # zerombr or cdl are added to the ks file question_window = YesNoDialog(self._app, displaytext) self._app.switch_screen_modal(question_window) if not question_window.answer:
On Fri, 2015-06-19 at 10:59 -0400, Samantha N. Bueno wrote:
This checks for the clearpart --cdl ks option and takes appropriate action if it's specified (automatically format any detected LDL DASDs).
This also adds a general check (during interactive installations) for LDL DASDs and shows the user the dasdfmt dialog box.
And to anyone wondering why we show the dasdfmt dialog twice (once for unformatted, once for LDL), it is to give users the option of formatting unformatted DASDs but not LDL (or vice versa).
Resolves: rhbz#1170656 Resolves: rhbz#1170653
pyanaconda/ui/gui/spokes/storage.py | 71 ++++++++++++++++++++++++++++--------- pyanaconda/ui/tui/spokes/storage.py | 38 ++++++++++---------- 2 files changed, 74 insertions(+), 35 deletions(-)
diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py index fc65a0f..468daa0 100644 --- a/pyanaconda/ui/gui/spokes/storage.py +++ b/pyanaconda/ui/gui/spokes/storage.py @@ -61,7 +61,7 @@ from blivet.devices import MultipathDevice from blivet.errors import StorageError, DasdFormatError from blivet.platform import platform from blivet.devicelibs import swap as swap_lib -from blivet.devicelibs.dasd import make_unformatted_dasd_list, format_dasd +from blivet.devicelibs.dasd import make_unformatted_dasd_list, format_dasd, is_ldl_dasd from pyanaconda.threads import threadMgr, AnacondaThread from pyanaconda.product import productName from pyanaconda.flags import flags @@ -251,10 +251,10 @@ class StorageSpoke(NormalSpoke, StorageChecker): self.autoPartType = None self.clearPartType = CLEARPART_TYPE_NONE
if self.data.zerombr.zerombr and arch.isS390():# run dasdfmt on any unformatted DASDs automatically
if arch.isS390() and (self.data.zerombr.zerombr or self.data.clearpart.cdl):# run dasdfmt on any unformatted or LDL DASDs automatically threadMgr.add(AnacondaThread(name=constants.THREAD_DASDFMT,
target=self.run_dasdfmt))
target=self.run_dasdfmt, args=(self.data.zerombr.zerombr, self.data.clearpart.cdl))) self._previous_autopart = False@@ -617,7 +617,7 @@ class StorageSpoke(NormalSpoke, StorageChecker): if not selected and name in self.selected_disks: self.selected_disks.remove(name)
- def run_dasdfmt(self):
- def run_dasdfmt(self, askuser, cdl): """ Though the same function exists in pyanaconda.ui.gui.spokes.lib.dasdfmt, this instance doesn't include any of the UI pieces and should only
@@ -627,19 +627,36 @@ class StorageSpoke(NormalSpoke, StorageChecker): # actions on storage devices threadMgr.wait(constants.THREAD_STORAGE)
to_format = make_unformatted_dasd_list(d.name for d in getDisks(self.storage.devicetree))if not to_format:# nothing to do here; bailreturn
if askuser:unformatted = make_unformatted_dasd_list(d.name for d in getDisks(self.storage.devicetree))if not unformatted:# nothing to do here; bailreturn
hubQ.send_message(self.__class__.__name__, _("Formatting DASDs"))for disk in to_format:try:format_dasd(disk)except DasdFormatError as err:# Log errors if formatting fails, but don't halt the installerlog.error(str(err))continue
hubQ.send_message(self.__class__.__name__, _("Formatting DASDs"))for disk in unformatted:try:format_dasd(disk)except DasdFormatError as err:# Log errors if formatting fails, but don't halt the installerlog.error(str(err))continue
I'm not sure 'askuser' is the best possible name for the parameter. It sounds like something that should make us ask user for some more info or confirmation, but the code looks like it's more "acked by user" as it formats DASDs right away.
if cdl:ldldasds = [d.name for d in getDisks(self.storage.devicetree) if is_ldl_dasd(d.name)]log.debug(ldldasds)
This should be either removed (a debugging leftover?) or prepended with some description of the logged stuff -- something like "LDL DASDs: %s".
if not ldldasds:# nothing to do here; bailreturnhubQ.send_message(self.__class__.__name__, _("Formatting DASDs"))for disk in ldldasds:try:format_dasd(disk)except DasdFormatError as err:# Log errors if formatting fails, but don't halt the installerlog.error(str(err))continue # I really hate doing this, but the way is the way; probably the most # correct way to kajigger the storage spoke into becoming ready@@ -757,6 +774,26 @@ class StorageSpoke(NormalSpoke, StorageChecker): # back to the hub. return
# check for ldl dasdsldldasds = [d for d in self.selected_disks if is_ldl_dasd(d)]if len(ldldasds) > 0:dialog = DasdFormatDialog(self.data, self.storage, ldldasds)ignoreEscape(dialog.window)rc = self.run_lightbox_dialog(dialog)if rc == 1:# User hit OK on the dialogself.refresh()elif rc == 2:# User clicked uri to return to hub.NormalSpoke.on_back_clicked(self, button)returnelif rc != 2:# User either hit cancel on the dialog or closed it via escape,# there was no formatting done.# NOTE: rc == 2 means the user clicked on the link that takes t# back to the hub.return# Figure out if the existing disk labels will work on this platform # you need to have at least one of the platform's labels in order for # any of the free space to be useful.diff --git a/pyanaconda/ui/tui/spokes/storage.py b/pyanaconda/ui/tui/spokes/storage.py index 2df64ed..16b1467 100644 --- a/pyanaconda/ui/tui/spokes/storage.py +++ b/pyanaconda/ui/tui/spokes/storage.py @@ -33,7 +33,7 @@ from blivet import arch from blivet.size import Size from blivet.errors import StorageError, DasdFormatError from blivet.devices import DASDDevice, FcoeDiskDevice, iScsiDiskDevice, MultipathDevice, ZFCPDiskDevice -from blivet.devicelibs.dasd import format_dasd, make_unformatted_dasd_list +from blivet.devicelibs.dasd import format_dasd, make_unformatted_dasd_list, is_ldl_dasd from pyanaconda.flags import flags from pyanaconda.kickstart import doKickstartStorage, resetCustomStorageData from pyanaconda.threads import threadMgr, AnacondaThread @@ -84,12 +84,10 @@ class StorageSpoke(NormalTUISpoke): self.errors = [] self.warnings = []
if self.data.zerombr.zerombr and arch.isS390():# if zerombr is specified in a ks file and there are unformatted# dasds, automatically format themto_format = make_unformatted_dasd_list(self.selected_disks)if to_format:self.run_dasdfmt(to_format)
# automatically dasdfmt any unformatted/ldl dasds if a user has# specified zerombr/cdl in their ks fileif arch.isS390() and (self.data.zerombr.zerombr or self.data.clearpart.cdl):self.run_dasdfmt(self.selected_disks, self.data.zerombr.zerombr, self.data.clearpart.cdl) if not flags.automatedInstall: # default to using autopart for interactive installs@@ -270,13 +268,17 @@ class StorageSpoke(NormalTUISpoke): except (ValueError, IndexError): if key.lower() == "c": if self.selected_disks:
# check selected disks to see if we have any unformatted DASDs# if we're on s390x, since they need to be formatted before we# can use them.
# check selected disks to see if we have any unformatted or# LDL DASDs if we're on s390x, since they need to be# formatted before we can use them. if arch.isS390():
to_format = make_unformatted_dasd_list(self.selected_disks)if to_format:self.run_dasdfmt(to_format)
dasds = make_unformatted_dasd_list(self.selected_disks)if dasds:self.run_dasdfmt(dasds)return Noneldldasds = [d for d in self.selected_disks if is_ldl_dasd(d)]if ldldasds:self.run_dasdfmt(ldldasds) return None newspoke = AutoPartSpoke(self.app, self.data, self.storage,@@ -289,7 +291,7 @@ class StorageSpoke(NormalTUISpoke): else: return key
- def run_dasdfmt(self, to_format):
- def run_dasdfmt(self, to_format, zerombr, cdl):
The last two arguments seem to be extra here (not passed, not used).
""" This generates the list of DASDs requiring dasdfmt and runs dasdfmt against them.@@ -299,8 +301,8 @@ class StorageSpoke(NormalTUISpoke): # zerombr in their ks file threadMgr.wait(THREAD_STORAGE)
# ask user to verify they want to format if zerombr not in ks fileif not self.data.zerombr.zerombr:
# ask user to verify they want to format if zerombr or cdl not in ks fileif not (self.data.zerombr.zerombr or self.data.clearpart.cdl): # prepare our msg strings; copied directly from dasdfmt.glade summary = _("The following unformatted DASDs have been detected on your system. You can choose to format them now with dasdfmt or cancel to leave them unformatted. Unformatted DASDs can not be used during installation.\n\n")@@ -309,8 +311,8 @@ class StorageSpoke(NormalTUISpoke): displaytext = summary + "\n".join("/dev/" + d for d in to_format) + "\n" + warntext
# now show actual prompt; note -- in cmdline mode, auto-answer for
# this is 'no', so unformatted DASDs will remain so unless zerombr# is added to the ks file
# this is 'no', so unformatted and ldl DASDs will remain so unless# zerombr or cdl are added to the ks file question_window = YesNoDialog(self._app, displaytext) self._app.switch_screen_modal(question_window) if not question_window.answer:
Unless there actually are DAD devices.
Related: rhbz#1170653 --- pyanaconda/ui/gui/spokes/lib/dasdfmt.glade | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/pyanaconda/ui/gui/spokes/lib/dasdfmt.glade b/pyanaconda/ui/gui/spokes/lib/dasdfmt.glade index d5280c3..07a1805 100644 --- a/pyanaconda/ui/gui/spokes/lib/dasdfmt.glade +++ b/pyanaconda/ui/gui/spokes/lib/dasdfmt.glade @@ -20,7 +20,7 @@ <property name="layout_style">end</property> <child> <object class="GtkButton" id="udCancelButton"> - <property name="label" translatable="yes" context="GUI|DAD Format Dialog">_Cancel</property> + <property name="label" translatable="yes" context="GUI|DASD Format Dialog">_Cancel</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> @@ -34,7 +34,7 @@ </child> <child> <object class="GtkButton" id="udOKButton"> - <property name="label" translatable="yes" context="GUI|DAD Format Dialog">_OK</property> + <property name="label" translatable="yes" context="GUI|DASD Format Dialog">_OK</property> <property name="visible">True</property> <property name="sensitive">False</property> <property name="can_focus">True</property> @@ -157,7 +157,7 @@ <property name="show_tabs">False</property> <child> <object class="GtkButton" id="formatButton"> - <property name="label" translatable="yes" context="GUI|DAD Format Dialog">_Format with dasdfmt</property> + <property name="label" translatable="yes" context="GUI|DASD Format Dialog">_Format with dasdfmt</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property>
Include the mention of LDL DASDs now.
Related: rhbz#1170653 --- pyanaconda/ui/gui/spokes/lib/dasdfmt.glade | 2 +- pyanaconda/ui/tui/spokes/storage.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/pyanaconda/ui/gui/spokes/lib/dasdfmt.glade b/pyanaconda/ui/gui/spokes/lib/dasdfmt.glade index 07a1805..6049df5 100644 --- a/pyanaconda/ui/gui/spokes/lib/dasdfmt.glade +++ b/pyanaconda/ui/gui/spokes/lib/dasdfmt.glade @@ -67,7 +67,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="valign">start</property> - <property name="label" translatable="yes">The following unformatted DASDs have been detected on your system. You can choose to format them now with dasdfmt or cancel to leave them unformatted. Unformatted DASDs can not be used during installation.</property> + <property name="label" translatable="yes">The following unformatted or LDL DASDs have been detected on your system. You can choose to format them now with dasdfmt or cancel to leave them unformatted. Unformatted and LDL DASDs can not be used during installation.</property> <property name="wrap">True</property> <attributes> <attribute name="font-desc" value="Cantarell 12"/> diff --git a/pyanaconda/ui/tui/spokes/storage.py b/pyanaconda/ui/tui/spokes/storage.py index 16b1467..556a108 100644 --- a/pyanaconda/ui/tui/spokes/storage.py +++ b/pyanaconda/ui/tui/spokes/storage.py @@ -304,7 +304,10 @@ class StorageSpoke(NormalTUISpoke): # ask user to verify they want to format if zerombr or cdl not in ks file if not (self.data.zerombr.zerombr or self.data.clearpart.cdl): # prepare our msg strings; copied directly from dasdfmt.glade - summary = _("The following unformatted DASDs have been detected on your system. You can choose to format them now with dasdfmt or cancel to leave them unformatted. Unformatted DASDs can not be used during installation.\n\n") + summary = _("The following unformatted or LDL DASDs have been " + "detected on your system. You can choose to format them " + "now with dasdfmt or cancel to leave them unformatted. " + "Unformatted and LDL DASDs can not be used during installation.\n\n")
warntext = _("Warning: All storage changes made using the installer will be lost when you choose to format.\n\nProceed to run dasdfmt?\n")
On Fri, 2015-06-19 at 10:59 -0400, Samantha N. Bueno wrote:
Similar to the code that went into rhel06, this adds a new function to devicelibs.dasd in order to detect LDL DASDs. There is also some code in the gui/tui storage spokes to create a list of any LDL DASDs and prompt the user to run dasdfmt against them.
The cleaerpart --cdl option basically says, if there are any LDL DASDs on my system detected during my ks install, run dasdfmt on them.
I will say that I have not had a chance to really test the clearpart --cdl option, so bear that in mind, but I think that it should be ok.
Looks good to me other than the minor comments to PATCH 1/3.
anaconda-patches@lists.fedorahosted.org