[anaconda][master/rhel7-branch 2/2] Add GUI and TUI logic to handle unformatted DASDs. (#1001070)

Vratislav Podzimek vpodzime at redhat.com
Wed Feb 12 10:51:14 UTC 2014


On Tue, 2014-02-11 at 18:01 -0500, Samantha N. Bueno wrote:
> In both graphical and text, a check for unformatted DASDs is run
> iff you're running on s390x. Any DASDs requiring formatting with
> dasdfmt are then displayed to the user, who can choose to format
> them or not.
> 
> Following dasdfmt, storage initialization is run again in order
> to properly add the new DASDs to the devicetree and seen by the
> installer.
> 
> If a user opts not to have dasdfmt run, the DASDs stay unformatted
> and can not be used during installation.
> 
> Resolves:rhbz#1001070
> ---
>  pyanaconda/ui/gui/spokes/storage.py | 41 +++++++++++++++++++---
>  pyanaconda/ui/tui/spokes/storage.py | 70 +++++++++++++++++++++++++++++++++++--
>  2 files changed, 105 insertions(+), 6 deletions(-)
> 
> diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py
> index f14a681..ff45dd4 100644
> --- a/pyanaconda/ui/gui/spokes/storage.py
> +++ b/pyanaconda/ui/gui/spokes/storage.py
> @@ -50,15 +50,19 @@ from pyanaconda.ui.gui.spokes.lib.cart import SelectedDisksDialog
>  from pyanaconda.ui.gui.spokes.lib.passphrase import PassphraseDialog
>  from pyanaconda.ui.gui.spokes.lib.detailederror import DetailedErrorDialog
>  from pyanaconda.ui.gui.spokes.lib.resize import ResizeDialog
> +from pyanaconda.ui.gui.spokes.lib.dasdfmt import DasdFormatDialog
>  from pyanaconda.ui.gui.categories.system import SystemCategory
> -from pyanaconda.ui.gui.utils import enlightbox, gtk_call_once, gtk_action_wait
> +from pyanaconda.ui.gui.utils import enlightbox, gtk_call_once, gtk_action_wait, ignoreEscape
>  
>  from pyanaconda.kickstart import doKickstartStorage, getAvailableDiskSpace
> +from blivet import storageInitialize, arch
>  from blivet.size import Size
>  from blivet.devices import MultipathDevice
>  from blivet.errors import StorageError
> +from blivet.errors import StorageError
>  from blivet.platform import platform
>  from blivet.devicelibs import swap as swap_lib
> +from blivet.devicelibs.dasd import make_unformatted_dasd_list
>  from pyanaconda.threads import threadMgr, AnacondaThread
>  from pyanaconda.product import productName
>  from pyanaconda.flags import flags
> @@ -265,6 +269,10 @@ class StorageSpoke(NormalSpoke, StorageChecker):
>          # if set to False, it means the user needs to confirm the current
>          # storage configuration
>  
> +        # set this to None by default; it should only ever exist if we're on
> +        # s390x and have unformatted DASDs
> +        self.dasd_warning = None
> +
>          if flags.automatedInstall:
>              # now we have to check if some form of partitioning is specified
>              # in the current kickstart
> @@ -412,7 +420,7 @@ class StorageSpoke(NormalSpoke, StorageChecker):
>  
>              if self.errors:
>                  msg = _("Error checking storage configuration")
> -            elif self.warnings:
> +            elif self.warnings or self.dasd_warning:
>                  msg = _("Warning checking storage configuration")
>              elif self.data.autopart.autopart:
>                  msg = _("Automatic partitioning selected")
> @@ -543,11 +551,15 @@ class StorageSpoke(NormalSpoke, StorageChecker):
>              name = overview.get_property("name")
>              overview.set_chosen(name in self.selected_disks)
>  
> +        # if we're on s390x, check for unformatted DASDs
> +        if arch.isS390():
> +            self.dasd_warning = make_unformatted_dasd_list(self.storage.dasd, self.storage.devicetree.exclusiveDisks)
Please split this into two lines.

> +
>          self._update_summary()
>  
>          if self.errors:
>              self.set_warning(_("Error checking storage configuration.  Click for details."))
> -        elif self.warnings:
> +        elif self.warnings or self.dasd_warning:
>              self.set_warning(_("Warning checking storage configuration.  Click for details."))
>  
>      def initialize(self):
> @@ -658,6 +670,8 @@ class StorageSpoke(NormalSpoke, StorageChecker):
>  
>          if len(self.disks) == 0:
>              self.set_warning(_("No disks detected.  Please shut down the computer, connect at least one disk, and restart to complete installation."))
> +        elif self.dasd_warning:
> +            self.set_warning(_("Unformatted DASDs detected."))
>          elif count == 0:
>              self.set_warning(_("No disks selected; please select at least one disk to install to."))
>          else:
> @@ -893,7 +907,25 @@ class StorageSpoke(NormalSpoke, StorageChecker):
>          NormalSpoke.on_back_clicked(self, button)
>  
>      def on_info_bar_clicked(self, *args):
> -        if self.errors:
> +        if self.dasd_warning:
> +            dialog = DasdFormatDialog(self.data, self.storage, self.dasd_warning)
> +            ignoreEscape(dialog.window)
> +            rc = self.run_lightbox_dialog(dialog)
> +            if rc == 1:
> +                # User hit OK on the dialog, indicating they stayed on the
> +                # dialog until formatting completed and now needs to go back
> +                # to the main storage spoke.
> +                #self.skipTo = "StorageSpoke"
Leftover?

> +                dialog.window.destroy()
> +                self.dasd_warning = None
> +                self.refresh()
> +            elif rc != 2:
> +                # User either hit cancel on the dialog or closed it via escape, so
> +                # there was no formatting done.
> +                # NOTE: rc == 2 means the user clicked on the link that takes them
> +                # back to the hub.
> +                return
> +        elif self.errors:
>              label = _("The following errors were encountered when checking your storage "
>                        "configuration.  You can modify your storage layout or quit the "
>                        "installer.")
> @@ -921,6 +953,7 @@ class StorageSpoke(NormalSpoke, StorageChecker):
>                  rc = dialog.run()
>  
>              dialog.window.destroy()
> +            self.refresh()
>  
>      def on_disks_key_released(self, box, event):
>          # we want to react only on Ctrl-A being pressed
> diff --git a/pyanaconda/ui/tui/spokes/storage.py b/pyanaconda/ui/tui/spokes/storage.py
> index 05cf122..32a80d8 100644
> --- a/pyanaconda/ui/tui/spokes/storage.py
> +++ b/pyanaconda/ui/tui/spokes/storage.py
> @@ -25,11 +25,14 @@
>  from pyanaconda.ui.lib.disks import getDisks, size_str
>  from pyanaconda.ui.tui.spokes import NormalTUISpoke
>  from pyanaconda.ui.tui.simpleline import TextWidget, CheckboxWidget
> +from pyanaconda.ui.tui.tuiobject import YesNoDialog
>  
>  from pykickstart.constants import AUTOPART_TYPE_LVM, AUTOPART_TYPE_BTRFS, AUTOPART_TYPE_PLAIN
> +from blivet import storageInitialize, arch
>  from blivet.size import Size
> -from blivet.errors import StorageError
> +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 pyanaconda.flags import flags
>  from pyanaconda.kickstart import doKickstartStorage
>  from pyanaconda.threads import threadMgr, AnacondaThread
> @@ -72,6 +75,12 @@ class StorageSpoke(NormalTUISpoke):
>          self.disks = []
>          self.errors = []
>          self.warnings = []
> +        # this should always be None unless we are (a) on s390x and (b) have
> +        # unformatted DASDs
> +        if arch.isS390():
> +            self.dasd_warning = make_unformatted_dasd_list(self.storage.dasd, self.storage.devicetree.exclusiveDisks)
A very long line again.

> +        else:
> +            self.dasd_warning = None
>  
>          if not flags.automatedInstall:
>              # default to using autopart for interactive installs
> @@ -111,7 +120,7 @@ class StorageSpoke(NormalTUISpoke):
>  
>              if self.errors:
>                  msg = _("Error checking storage configuration")
> -            elif self.warnings:
> +            elif self.warnings or self.dasd_warning:
>                  msg = _("Warning checking storage configuration")
>              # Maybe show what type of clearpart and which disks selected?
>              elif self.data.autopart.autopart:
> @@ -162,6 +171,9 @@ class StorageSpoke(NormalTUISpoke):
>              summary = summary + "\n" + "\n".join(self.errors)
>          elif self.warnings:
>              summary = summary + "\n" + "\n".join(self.warnings)
> +        elif self.dasd_warning:
> +            #self.dasdfmt_prompt(self.dasd_warning)
leftover?

> +            summary = (_("Unformatted DASDs detected"))
>  
>          return summary
>  
> @@ -182,6 +194,7 @@ class StorageSpoke(NormalTUISpoke):
>          message = self._update_summary()
>  
>          # loop through the disks and present them.
> +        self.disks = getDisks(self.storage.devicetree)
>          for disk in self.disks:
>              disk_info = self._format_disk_info(disk)
>              c = CheckboxWidget(title="%i) %s" % (self.disks.index(disk) + 1, disk_info),
> @@ -190,8 +203,60 @@ class StorageSpoke(NormalTUISpoke):
>  
>          self._window += [TextWidget(message), ""]
>  
> +        if self.dasd_warning:
> +            self.dasdfmt_prompt(self.dasd_warning)
> +            # refresh screen to pick up any changes
> +            self.refresh()
> +
>          return True
>  
> +    def dasdfmt_prompt(self, dasd_warning):
> +        """ Custom prompt to separate the dasdfmt stuff from the rest of the
> +            logic in refresh.
> +        """
> +        self.dasd_warning = dasd_warning
> +        if not self.dasd_warning:
> +            return True
> +
> +        # prepare our msg strings; almost all of this is copied verbatim from
> +        # the corresponding GUI text
> +        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")
> +
> +        warntext = _("Warning: All storage changes made using the installer will be lost when you choose to format.\n\nProceed to run dasdfmt?\n")
> +
> +        displaytext = (summary + "\n".join((map(lambda dasd: dasd.path, self.dasd_warning))) + "\n" + warntext)
displaytext = (summary + "\n".join(dasd.path for dasd in
self.dasd_warning) + "\n" + warntext)
# stupid Evolution!

should do the same and would be better readable.

-- 
Vratislav Podzimek

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



More information about the anaconda-patches mailing list