[PATCH 3/3] Display progress or wait window when creating devices.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For devices created using an external utility we can display a
pulsing progressWindow. For devices created using a python module
we display a waitWindow.
---
 storage/devices.py |  128 +++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 92 insertions(+), 36 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index ff7698f..81708ce 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -1165,17 +1165,28 @@ class PartitionDevice(StorageDevice):
         self.createParents()
         self.setupParents()
 
-        self.disk.format.addPartition(self.partedPartition)
-        self.disk.format.commit()
+        w = None
+        if intf:
+            w = intf.waitWindow(_("Creating"),
+                                _("Creating device %s") % (self.path,))
 
-        # Ensure old metadata which lived in freespace so did not get
-        # explictly destroyed by a destroyformat action gets wiped
-        DeviceFormat(device=self.path, exists=True).destroy()
+        try:
+            self.disk.format.addPartition(self.partedPartition)
+            self.disk.format.commit()
 
-        self.partedPartition = self.disk.format.partedDisk.getPartitionByPath(self.path)
+            # Ensure old metadata which lived in freespace so did not get
+            # explictly destroyed by a destroyformat action gets wiped
+            DeviceFormat(device=self.path, exists=True).destroy()
+        except Exception:
+            raise
+        else:
+            self.partedPartition = self.disk.format.partedDisk.getPartitionByPath(self.path)
 
-        self.exists = True
-        self.setup()
+            self.exists = True
+            self.setup()
+        finally:
+            if w:
+                w.pop()
 
     def _computeResize(self, partition):
         log_method_call(self, self.name, status=self.status)
@@ -1745,6 +1756,12 @@ class LVMVolumeGroupDevice(DMDevice):
         if self.exists:
             raise DeviceError("device already exists", self.name)
 
+        w = None
+        if intf:
+            w = intf.progressWindow(_("Creating"),
+                                    _("Creating device %s")
+                                    % (self.path,),
+                                    100, pulse = True)
         pv_list = []
         #for pv in self.parents:
             # This is a little bit different from other devices in that
@@ -1756,10 +1773,17 @@ class LVMVolumeGroupDevice(DMDevice):
         pv_list = [pv.path for pv in self.parents]
         self.createParents()
         self.setupParents()
-        lvm.vgcreate(self.name, pv_list, self.peSize)
-        # FIXME set / update self.uuid here
-        self.exists = True
-        self.setup()
+        try:
+            lvm.vgcreate(self.name, pv_list, self.peSize, progress=w)
+        except Exception:
+            raise
+        else:
+            # FIXME set / update self.uuid here
+            self.exists = True
+            self.setup()
+        finally:
+            if w:
+                w.pop()
 
     def destroy(self):
         """ Destroy the device. """
@@ -2127,14 +2151,27 @@ class LVMLogicalVolumeDevice(DMDevice):
         if self.exists:
             raise DeviceError("device already exists", self.name)
 
+        w = None
+        if intf:
+            w = intf.progressWindow(_("Creating"),
+                                    _("Creating device %s")
+                                    % (self.path,),
+                                    100, pulse = True)
         self.createParents()
         self.setupParents()
 
-        # should we use --zero for safety's sake?
-        lvm.lvcreate(self.vg.name, self._name, self.size)
-        # FIXME set / update self.uuid here
-        self.exists = True
-        self.setup()
+        try:
+            # should we use --zero for safety's sake?
+            lvm.lvcreate(self.vg.name, self._name, self.size, progress=w)
+        except Exception:
+            raise
+        else:
+            # FIXME set / update self.uuid here
+            self.exists = True
+            self.setup()
+        finally:
+            if w:
+                w.pop()
 
     def destroy(self):
         """ Destroy the device. """
@@ -2551,23 +2588,38 @@ class MDRaidArrayDevice(StorageDevice):
         if self.exists:
             raise DeviceError("device already exists", self.name)
 
+        w = None
+        if intf:
+            w = intf.progressWindow(_("Creating"),
+                                    _("Creating device %s")
+                                    % (self.path,),
+                                    100, pulse = True)
         disks = [disk.path for disk in self.devices]
         self.createParents()
         self.setupParents()
         spares = len(self.devices) - self.memberDevices
-        mdraid.mdcreate(self.path,
-                        self.level,
-                        disks,
-                        spares)
-        self.exists = True
-        # the array is automatically activated upon creation, but...
-        self.setup()
-        udev_settle()
-        self.updateSysfsPath()
-        info = udev_get_block_device(self.sysfsPath)
-        self.uuid = udev_device_get_md_uuid(info)
-        for member in self.devices:
-            member.mdUuid = self.uuid
+
+        try:
+            mdraid.mdcreate(self.path,
+                            self.level,
+                            disks,
+                            spares,
+                            progress=w)
+        except Exception:
+            raise
+        else:
+            self.exists = True
+            # the array is automatically activated upon creation, but...
+            self.setup()
+            udev_settle()
+            self.updateSysfsPath()
+            info = udev_get_block_device(self.sysfsPath)
+            self.uuid = udev_device_get_md_uuid(info)
+            for member in self.devices:
+                member.mdUuid = self.uuid
+        finally:
+            if w:
+                w.pop()
 
     @property
     def formatArgs(self):
@@ -2969,24 +3021,28 @@ class FileDevice(StorageDevice):
         if self.exists:
             raise DeviceError("device already exists", self.name)
 
+        w = None
+        if intf:
+            w = intf.waitWindow(_("Creating"),
+                                _("Creating file %s") % (self.path,))
+
         # this only checks that parents exist
         self.createParents()
         self.setupParents()
 
         try:
             fd = os.open(self.path, os.O_RDWR)
-        except OSError as e:
-            raise DeviceError(e, self.name)
-
-        try:
             buf = '\0' * 1024 * 1024 * self.size
             os.write(fd, buf)
         except (OSError, TypeError) as e:
             log.error("error writing out %s: %s" % (self.path, e))
+            raise DeviceError(e, self.name)
+        else:
+            self.exists = True
         finally:
             os.close(fd)
-
-        self.exists = True
+            if w:
+                w.pop()
 
     def destroy(self):
         """ Destroy the device. """
-- 
1.6.0.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux