[rhel7-branch[anaconda][PATCH 1/3] Enable anaconda to use the new cdl ks option, and detect ldl dasds. (#1170656, #1170653)

Vratislav Podzimek vpodzime at redhat.com
Mon Jun 22 07:17:02 UTC 2015


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; 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
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; 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):
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 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:

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list