[master/rhel7-branch] Re-apply disk selection on error in TUi storage. (#1056316)
Vratislav Podzimek
vpodzime at redhat.com
Thu Feb 20 10:12:47 UTC 2014
On Wed, 2014-02-19 at 15:36 -0500, Samantha N. Bueno wrote:
> On Wed, Feb 19, 2014 at 02:21:16PM -0500, Chris Lumens wrote:
> > > diff --git a/pyanaconda/ui/lib/disks.py b/pyanaconda/ui/lib/disks.py
> > > index 486208b..ddfc6ea 100644
> > > --- a/pyanaconda/ui/lib/disks.py
> > > +++ b/pyanaconda/ui/lib/disks.py
> > > @@ -82,3 +82,12 @@ def size_str(mb):
> > > spec = "%f mb" % mb
> > >
> > > return str(Size(spec=spec)).upper()
> > > +
> > > +def applyDiskSelection(use_names):
> > > + onlyuse = use_names[:]
> > > + for disk in (d for d in self.storage.disks if d.name in onlyuse):
> > > + onlyuse.extend(d.name for d in disk.ancestors
> > > + if d.name not in onlyuse)
> > > +
> > > + self.data.ignoredisk.onlyuse = onlyuse
> > > + self.data.clearpart.drives = use_names[:]
> >
> > You're going to need to pass storage and data into this function -
> > there's no self to get them through.
>
> God, that was dumb. That's what I get for just blindly copy-pasting. New
> patch below.
>
> ----
>
> pyanaconda/ui/gui/spokes/storage.py | 19 +++++--------------
> pyanaconda/ui/lib/disks.py | 9 +++++++++
> pyanaconda/ui/tui/spokes/storage.py | 4 +++-
> 3 files changed, 17 insertions(+), 15 deletions(-)
>
> diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py
> index bdd48ef..6f719db 100644
> --- a/pyanaconda/ui/gui/spokes/storage.py
> +++ b/pyanaconda/ui/gui/spokes/storage.py
> @@ -43,7 +43,7 @@
> from gi.repository import Gdk, GLib, Gtk, AnacondaWidgets
>
> from pyanaconda.ui.communication import hubQ
> -from pyanaconda.ui.lib.disks import getDisks, isLocalDisk, size_str
> +from pyanaconda.ui.lib.disks import getDisks, isLocalDisk, size_str, applyDiskSelection
> from pyanaconda.ui.gui import GUIObject
> from pyanaconda.ui.gui.spokes import NormalSpoke
> from pyanaconda.ui.gui.spokes.lib.cart import SelectedDisksDialog
> @@ -304,17 +304,8 @@ class StorageSpoke(NormalSpoke, StorageChecker):
> self._encrypted = self.builder.get_object("encryptionCheckbox")
> self._reclaim = self.builder.get_object("reclaimCheckbox")
>
> - def _applyDiskSelection(self, use_names):
> - onlyuse = use_names[:]
> - for disk in (d for d in self.storage.disks if d.name in onlyuse):
> - onlyuse.extend(d.name for d in disk.ancestors
> - if d.name not in onlyuse)
> -
> - self.data.ignoredisk.onlyuse = onlyuse
> - self.data.clearpart.drives = use_names[:]
> -
> def apply(self):
> - self._applyDiskSelection(self.selected_disks)
> + applyDiskSelection(self.storage, self.data, self.selected_disks)
> self.data.autopart.autopart = self.autopart
> self.data.autopart.type = self.autoPartType
> self.data.autopart.encrypted = self.encrypted
> @@ -371,7 +362,7 @@ class StorageSpoke(NormalSpoke, StorageChecker):
> self.storage.reset()
> self.disks = getDisks(self.storage.devicetree)
> # now set ksdata back to the user's specified config
> - self._applyDiskSelection(self.selected_disks)
> + applyDiskSelection(self.storage, self.data, self.selected_disks)
> except BootLoaderError as e:
> log.error("BootLoader setup failed: %s", e)
> StorageChecker.errors = str(e).split("\n")
> @@ -632,7 +623,7 @@ class StorageSpoke(NormalSpoke, StorageChecker):
>
> # if there's only one disk, select it by default
> if len(self.disks) == 1 and not self.selected_disks:
> - self._applyDiskSelection([self.disks[0].name])
> + applyDiskSelection(self.storage, self.data, [self.disks[0].name])
>
> self._ready = True
> hubQ.send_ready(self.__class__.__name__, False)
> @@ -899,7 +890,7 @@ class StorageSpoke(NormalSpoke, StorageChecker):
>
> # However, we do want to apply current selections so the disk cart off
> # the filter spoke will display the correct information.
> - self._applyDiskSelection(self.selected_disks)
> + applyDiskSelection(self.storage, self.data, self.selected_disks)
>
> self.skipTo = "FilterSpoke"
> NormalSpoke.on_back_clicked(self, button)
> diff --git a/pyanaconda/ui/lib/disks.py b/pyanaconda/ui/lib/disks.py
> index 486208b..bfc586b 100644
> --- a/pyanaconda/ui/lib/disks.py
> +++ b/pyanaconda/ui/lib/disks.py
> @@ -82,3 +82,12 @@ def size_str(mb):
> spec = "%f mb" % mb
>
> return str(Size(spec=spec)).upper()
> +
> +def applyDiskSelection(storage, data, use_names):
> + onlyuse = use_names[:]
> + for disk in (d for d in storage.disks if d.name in onlyuse):
> + onlyuse.extend(d.name for d in disk.ancestors
> + if d.name not in onlyuse)
> +
> + data.ignoredisk.onlyuse = onlyuse
> + data.clearpart.drives = use_names[:]
> diff --git a/pyanaconda/ui/tui/spokes/storage.py b/pyanaconda/ui/tui/spokes/storage.py
> index b4d40f1..088684b 100644
> --- a/pyanaconda/ui/tui/spokes/storage.py
> +++ b/pyanaconda/ui/tui/spokes/storage.py
> @@ -22,7 +22,7 @@
> # which has the same license and authored by David Lehman
> # <dlehman at redhat.com>
> #
>
> -from pyanaconda.ui.lib.disks import getDisks, size_str
> +from pyanaconda.ui.lib.disks import getDisks, size_str, applyDiskSelection
> from pyanaconda.ui.tui.spokes import NormalTUISpoke
> from pyanaconda.ui.tui.simpleline import TextWidget, CheckboxWidget
>
> @@ -297,6 +297,8 @@ class StorageSpoke(NormalTUISpoke):
> self.storage.config.update(self.data)
> self.storage.autoPartType = self.data.clearpart.type
> self.storage.reset()
> + # now set ksdata back to the user's specified config
> + applyDiskSelection(self.storage, self.data, self.selected_disks)
> self._ready = True
> except BootLoaderError as e:
> log.error("BootLoader setup failed: %s", e)
This looks good.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list