FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 11-25-2009, 09:59 PM
David Lehman
 
Default Display progress or wait window when creating devices.

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(sel f.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(sel f.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 = '' * 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@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 11-30-2009, 04:48 PM
David Lehman
 
Default Display progress or wait window when creating devices.

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 | 165 +++++++++++++++++++++++++++++++++------------------
1 files changed, 107 insertions(+), 58 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index ff7698f..7babfeb 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -1162,20 +1162,31 @@ class PartitionDevice(StorageDevice):
if self.exists:
raise DeviceError("device already exists", self.name)

- self.createParents()
- self.setupParents()
+ w = None
+ if intf:
+ w = intf.waitWindow(_("Creating"),
+ _("Creating device %s") % (self.path,))

- self.disk.format.addPartition(self.partedPartition )
- self.disk.format.commit()
+ try:
+ self.createParents()
+ self.setupParents()

- # 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()
+ self.disk.format.addPartition(self.partedPartition )
+ self.disk.format.commit()

- self.partedPartition = self.disk.format.partedDisk.getPartitionByPath(sel f.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(sel f.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,21 +1756,27 @@ class LVMVolumeGroupDevice(DMDevice):
if self.exists:
raise DeviceError("device already exists", self.name)

- pv_list = []
- #for pv in self.parents:
- # This is a little bit different from other devices in that
- # for VG we need the PVs to be formatted before we can create
- # the VG.
- # pv.create()
- # pv.format.create()
- # pv_list.append(pv.path)
- 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()
+ w = None
+ if intf:
+ w = intf.progressWindow(_("Creating"),
+ _("Creating device %s")
+ % (self.path,),
+ 100, pulse = True)
+ try:
+ self.createParents()
+ self.setupParents()
+
+ pv_list = [pv.path for pv in self.parents]
+ 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 +2144,27 @@ class LVMLogicalVolumeDevice(DMDevice):
if self.exists:
raise DeviceError("device already exists", self.name)

- self.createParents()
- self.setupParents()
+ w = None
+ if intf:
+ w = intf.progressWindow(_("Creating"),
+ _("Creating device %s")
+ % (self.path,),
+ 100, pulse = True)
+ try:
+ 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()
+ # 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 +2581,38 @@ class MDRaidArrayDevice(StorageDevice):
if self.exists:
raise DeviceError("device already exists", self.name)

- 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
+ w = None
+ if intf:
+ w = intf.progressWindow(_("Creating"),
+ _("Creating device %s")
+ % (self.path,),
+ 100, pulse = True)
+ try:
+ self.createParents()
+ self.setupParents()
+
+ disks = [disk.path for disk in self.devices]
+ spares = len(self.devices) - self.memberDevices
+ 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 +3014,28 @@ class FileDevice(StorageDevice):
if self.exists:
raise DeviceError("device already exists", self.name)

- # this only checks that parents exist
- self.createParents()
- self.setupParents()
+ w = None
+ if intf:
+ w = intf.waitWindow(_("Creating"),
+ _("Creating file %s") % (self.path,))

try:
- fd = os.open(self.path, os.O_RDWR)
- except OSError as e:
- raise DeviceError(e, self.name)
+ # this only checks that parents exist
+ self.createParents()
+ self.setupParents()

- try:
+ fd = os.open(self.path, os.O_RDWR)
buf = '' * 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@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 11-30-2009, 05:41 PM
Hans de Goede
 
Default Display progress or wait window when creating devices.

Ack.

On 11/30/2009 06:48 PM, David Lehman wrote:

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 | 165 +++++++++++++++++++++++++++++++++------------------
1 files changed, 107 insertions(+), 58 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index ff7698f..7babfeb 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -1162,20 +1162,31 @@ class PartitionDevice(StorageDevice):
if self.exists:
raise DeviceError("device already exists", self.name)

- self.createParents()
- self.setupParents()
+ w = None
+ if intf:
+ w = intf.waitWindow(_("Creating"),
+ _("Creating device %s") % (self.path,))

- self.disk.format.addPartition(self.partedPartition )
- self.disk.format.commit()
+ try:
+ self.createParents()
+ self.setupParents()

- # 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()
+ self.disk.format.addPartition(self.partedPartition )
+ self.disk.format.commit()

- self.partedPartition = self.disk.format.partedDisk.getPartitionByPath(sel f.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(sel f.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,21 +1756,27 @@ class LVMVolumeGroupDevice(DMDevice):
if self.exists:
raise DeviceError("device already exists", self.name)

- pv_list = []
- #for pv in self.parents:
- # This is a little bit different from other devices in that
- # for VG we need the PVs to be formatted before we can create
- # the VG.
- # pv.create()
- # pv.format.create()
- # pv_list.append(pv.path)
- 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()
+ w = None
+ if intf:
+ w = intf.progressWindow(_("Creating"),
+ _("Creating device %s")
+ % (self.path,),
+ 100, pulse = True)
+ try:
+ self.createParents()
+ self.setupParents()
+
+ pv_list = [pv.path for pv in self.parents]
+ 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 +2144,27 @@ class LVMLogicalVolumeDevice(DMDevice):
if self.exists:
raise DeviceError("device already exists", self.name)

- self.createParents()
- self.setupParents()
+ w = None
+ if intf:
+ w = intf.progressWindow(_("Creating"),
+ _("Creating device %s")
+ % (self.path,),
+ 100, pulse = True)
+ try:
+ 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()
+ # 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 +2581,38 @@ class MDRaidArrayDevice(StorageDevice):
if self.exists:
raise DeviceError("device already exists", self.name)

- 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
+ w = None
+ if intf:
+ w = intf.progressWindow(_("Creating"),
+ _("Creating device %s")
+ % (self.path,),
+ 100, pulse = True)
+ try:
+ self.createParents()
+ self.setupParents()
+
+ disks = [disk.path for disk in self.devices]
+ spares = len(self.devices) - self.memberDevices
+ 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 +3014,28 @@ class FileDevice(StorageDevice):
if self.exists:
raise DeviceError("device already exists", self.name)

- # this only checks that parents exist
- self.createParents()
- self.setupParents()
+ w = None
+ if intf:
+ w = intf.waitWindow(_("Creating"),
+ _("Creating file %s") % (self.path,))

try:
- fd = os.open(self.path, os.O_RDWR)
- except OSError as e:
- raise DeviceError(e, self.name)
+ # this only checks that parents exist
+ self.createParents()
+ self.setupParents()

- try:
+ fd = os.open(self.path, os.O_RDWR)
buf = '' * 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. """


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

Thread Tools




All times are GMT. The time now is 06:09 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org