From 4745482c693af1f5f08f6ea35a80ecb57dac4aff Mon Sep 17 00:00:00 2001
From: "Samantha N. Bueno" <sbueno+anaconda@redhat.com>
Date: Wed, 29 Apr 2015 21:46:30 -0400
Subject: [PATCH] Make anaconda changes necessary for libblockdev s390 plugin.

---
 pyanaconda/ui/gui/spokes/advstorage/dasd.py |  9 +++++----
 pyanaconda/ui/gui/spokes/advstorage/zfcp.py | 11 ++++++-----
 pyanaconda/ui/gui/spokes/lib/dasdfmt.py     |  7 +++----
 pyanaconda/ui/gui/spokes/storage.py         | 12 ++++++------
 pyanaconda/ui/tui/spokes/storage.py         |  8 ++++----
 5 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/advstorage/dasd.py b/pyanaconda/ui/gui/spokes/advstorage/dasd.py
index 88e1a01..d6f811a 100644
--- a/pyanaconda/ui/gui/spokes/advstorage/dasd.py
+++ b/pyanaconda/ui/gui/spokes/advstorage/dasd.py
@@ -21,6 +21,7 @@
 
 from pyanaconda.ui.gui import GUIObject
 from pyanaconda.ui.gui.utils import gtk_action_nowait
+from gi.repository import BlockDev as bd
 
 from blivet.devicelibs.dasd import sanitize_dasd_dev_input, online_dasd
 
@@ -83,7 +84,7 @@ class DASDDialog(GUIObject):
         self._conditionNotebook.set_current_page(1)
 
         try:
-            device = sanitize_dasd_dev_input(self._deviceEntry.get_text())
+            device = bd.s390.sanitize_dev_input(self._deviceEntry.get_text())
         except ValueError as e:
             _config_error = str(e)
             self.builder.get_object("deviceErrorLabel").set_text(_config_error)
@@ -126,8 +127,8 @@ class DASDDialog(GUIObject):
         """
         # attempt to add the device
         try:
-            online_dasd(device)
+            bd.s390.dasd_online(device)
             self._update_devicetree = True
-        except ValueError as e:
-            self._discoveryError = str(e)
+        except GLib.GError as err:
+            self._discoveryError = str(err)
             return
diff --git a/pyanaconda/ui/gui/spokes/advstorage/zfcp.py b/pyanaconda/ui/gui/spokes/advstorage/zfcp.py
index 0674b1f..c755494 100644
--- a/pyanaconda/ui/gui/spokes/advstorage/zfcp.py
+++ b/pyanaconda/ui/gui/spokes/advstorage/zfcp.py
@@ -21,6 +21,7 @@
 
 from pyanaconda.ui.gui import GUIObject
 from pyanaconda.ui.gui.utils import gtk_action_nowait
+from gi.repository import BlockDev as bd
 
 from blivet.zfcp import ZFCPDevice
 
@@ -96,11 +97,11 @@ class ZFCPDialog(GUIObject):
         # below really, really is ugly and needs to be re-factored, but this
         # should give a good base idea as far as expected behavior should go
         try:
-            device = dev.sanitizeDeviceInput(self._deviceEntry.get_text())
-            wwpn = dev.sanitizeWWPNInput(self._wwpnEntry.get_text())
-            lun = dev.sanitizeFCPLInput(self._lunEntry.get_text())
-        except ValueError as e:
-            _config_error = str(e)
+            device = bd.s390.sanitize_dev_input(self._deviceEntry.get_text())
+            wwpn = bd.s390.zfcp_sanitize_wwpn_input(self._wwpnEntry.get_text())
+            lun = bd.s390.zfcp_sanitize_lun_input(self._lunEntry.get_text())
+        except GLib.GError as err:
+            _config_error = str(err)
             self.builder.get_object("deviceErrorLabel").set_text(_config_error)
             self._conditionNotebook.set_current_page(2)
 
diff --git a/pyanaconda/ui/gui/spokes/lib/dasdfmt.py b/pyanaconda/ui/gui/spokes/lib/dasdfmt.py
index 1b94705..938bbb8 100644
--- a/pyanaconda/ui/gui/spokes/lib/dasdfmt.py
+++ b/pyanaconda/ui/gui/spokes/lib/dasdfmt.py
@@ -27,8 +27,7 @@ from pyanaconda import constants
 from pyanaconda.i18n import _
 import threading
 
-from blivet.devicelibs.dasd import format_dasd
-from blivet.errors import DasdFormatError
+from gi.repository import BlockDev as blockdev
 
 import logging
 log = logging.getLogger("anaconda")
@@ -90,8 +89,8 @@ class DasdFormatDialog(GUIObject):
         for disk in self.to_format:
             try:
                 gtk_call_once(self._formatting_label.set_text, _("Formatting /dev/%s. This may take a moment.") % disk)
-                format_dasd(disk)
-            except DasdFormatError as err:
+                blockdev.s390_format_dasd(disk)
+            except GLib.GError as err:
                 # Log errors if formatting fails, but don't halt the installer
                 log.error(str(err))
                 continue
diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py
index 3cba326..7c5e9af 100644
--- a/pyanaconda/ui/gui/spokes/storage.py
+++ b/pyanaconda/ui/gui/spokes/storage.py
@@ -40,6 +40,7 @@
 """
 
 from gi.repository import Gdk, GLib, AnacondaWidgets
+from gi.repository import BlockDev as blockdev
 
 from pyanaconda.ui.communication import hubQ
 from pyanaconda.ui.lib.disks import getDisks, isLocalDisk, applyDiskSelection
@@ -59,9 +60,8 @@ from blivet import arch
 from blivet import autopart
 from blivet.size import Size
 from blivet.devices import MultipathDevice, ZFCPDiskDevice
-from blivet.errors import StorageError, DasdFormatError
+from blivet.errors import StorageError
 from blivet.platform import platform
-from blivet.devicelibs.dasd import make_unformatted_dasd_list, format_dasd
 from pyanaconda.threads import threadMgr, AnacondaThread
 from pyanaconda.product import productName
 from pyanaconda.flags import flags
@@ -664,7 +664,7 @@ 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))
+        to_format = self.storage.devicetree.make_unformatted_dasd_list(d.name for d in getDisks(self.storage.devicetree))
         if not to_format:
             # nothing to do here; bail
             return
@@ -672,8 +672,8 @@ class StorageSpoke(NormalSpoke, StorageChecker):
         hubQ.send_message(self.__class__.__name__, _("Formatting DASDs"))
         for disk in to_format:
             try:
-                format_dasd(disk)
-            except DasdFormatError as err:
+                blockdev.s390_format_dasd(disk)
+            except GLib.GError as err:
                 # Log errors if formatting fails, but don't halt the installer
                 log.error(str(err))
                 continue
@@ -774,7 +774,7 @@ class StorageSpoke(NormalSpoke, StorageChecker):
 
         if arch.isS390():
             # check for unformatted DASDs and launch dasdfmt if any discovered
-            dasds = make_unformatted_dasd_list(self.selected_disks)
+            dasds = self.storage.devicetree.make_unformatted_dasd_list(self.selected_disks)
             if len(dasds) > 0:
                 # We want to apply current selection before running dasdfmt to
                 # prevent this information from being lost afterward
diff --git a/pyanaconda/ui/tui/spokes/storage.py b/pyanaconda/ui/tui/spokes/storage.py
index 1c7b600..bf931b8 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 gi.repository import BlockDev as blockdev
 from pyanaconda.flags import flags
 from pyanaconda.kickstart import doKickstartStorage, resetCustomStorageData
 from pyanaconda.threads import threadMgr, AnacondaThread
@@ -89,7 +89,7 @@ class StorageSpoke(NormalTUISpoke):
             # dasds, automatically format them. pass in storage.devicetree here
             # instead of storage.disks since mediaPresent is checked on disks;
             # a dasd needing dasdfmt will fail this media check though
-            to_format = make_unformatted_dasd_list(d.name for d in getDisks(self.storage.devicetree))
+            to_format = storage.devicetree.make_unformatted_dasd_list(d.name for d in getDisks(self.storage.devicetree))
             if to_format:
                 self.run_dasdfmt(to_format)
 
@@ -276,7 +276,7 @@ class StorageSpoke(NormalTUISpoke):
                     # 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)
+                        to_format = self.storage.devicetree.make_unformatted_dasd_list(self.selected_disks)
                         if to_format:
                             self.run_dasdfmt(to_format)
                             return None
@@ -322,7 +322,7 @@ class StorageSpoke(NormalTUISpoke):
         for disk in to_format:
             try:
                 print(_("Formatting /dev/%s. This may take a moment.") % disk)
-                format_dasd(disk)
+                blockdev.s390_dasd_format(disk)
             except DasdFormatError as err:
                 # Log errors if formatting fails, but don't halt the installer
                 log.error(str(err))
-- 
1.9.3

