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 03-09-2010, 11:18 PM
David Lehman
 
Default Fix up device dialogs' handling of preexisting formatting.

Fixes display of original fstype, original fslabel. Also fixes
handling for when users initially specify that a device be re-
formatted, then later change it back to use what's already there.
---
iw/lvm_dialog_gui.py | 105 +++++++++++++++++++++++++++++----------
iw/partition_dialog_gui.py | 58 +++++++++++++++++-----
iw/partition_ui_helpers_gui.py | 2 +
iw/raid_dialog_gui.py | 52 ++++++++++++++++----
4 files changed, 169 insertions(+), 48 deletions(-)

diff --git a/iw/lvm_dialog_gui.py b/iw/lvm_dialog_gui.py
index 7a98d99..6ea54ab 100644
--- a/iw/lvm_dialog_gui.py
+++ b/iw/lvm_dialog_gui.py
@@ -46,11 +46,12 @@ class VolumeGroupEditor:
vg = LVMVolumeGroupDevice('tmp-%s' % self.vg.name,
parents=pvs, peSize=self.peSize)
for lv in self.lvs.values():
- LVMLogicalVolumeDevice(lv['name'], vg, format=lv['format'],
+ _l = LVMLogicalVolumeDevice(lv['name'], vg, format=lv['format'],
size=lv['size'], exists=lv['exists'],
stripes=lv['stripes'],
logSize=lv['logSize'],
snapshotSpace=lv['snapshotSpace'])
+ _l.originalFormat = lv['originalFormat']

return vg

@@ -405,23 +406,31 @@ class VolumeGroupEditor:
# appear. Note that if the format is swap or Raiddevice, the mount
# point is none-sense.
templuks = None
- usedev = None
- for _lv in tempvg.lvs:
- if _lv.lvname == lv['name']:
- templv = _lv
- usedev = templv
- if templv.format.type == "luks":
- templuks = LUKSDevice("luks-%s" % lv['name'],
- parents=[templv],
- format=self.luks[lv['name']],
- exists=templv.format.exists)
- usedev = templuks
- break
+ templv = self.getLVByName(lv['name'], vg=tempvg)
+ usedev = templv
+ if templv.format.type == "luks":
+ templuks = LUKSDevice("luks-%s" % lv['name'],
+ parents=[templv],
+ format=self.luks[lv['name']],
+ exists=templv.format.exists)
+ usedev = templuks

if lv['format'].type == "luks":
format = self.luks[lv['name']]
else:
format = lv['format']
+
+ if lv['exists']:
+ _origlv = self.getLVByName(lv['name'])
+ originalFormat = _origlv.originalFormat
+ if originalFormat.type == "luks":
+ try:
+ _origluks = self.storage.devicetree.getChildren(_origlv)[0]
+ except IndexError:
+ pass
+ else:
+ originalFormat = _origluks.originalFormat
+
mountCombo = createMountPointCombo(usedev, excludeMountPoints=["/boot"])


@@ -467,16 +476,13 @@ class VolumeGroupEditor:
else:
# File system type lable & combo
newfstypelabel = createAlignedLabel(_("Original File System Type:"))
- if format.type:
- newfstypeCombo = gtk.Label(format.name)
- else:
- newfstypeCombo = gtk.Label(_("Unknown"))
+ newfstypeCombo = gtk.Label(originalFormat.name)

# File system label label & combo
- if getattr(format, "label", None):
+ if getattr(originalFormat, "label", None):
newfslabellabel = createAlignedLabel(_("Original File System "
"Label:"))
- newfslableCombo = gtk.Label(format.label)
+ newfslableCombo = gtk.Label(originalFormat.label)

# Logical Volume name label & entry
lvnamelabel = createAlignedLabel(_("Logical Volume Name:"))
@@ -737,7 +743,12 @@ class VolumeGroupEditor:
format = templv.format

templv.format = format
- elif format.mountable:
+ elif self.fsoptionsDict.has_key("formatcb") and
+ not self.fsoptionsDict["formatcb"].get_active():
+ templv.format = templv.originalFormat
+ format = templv.format
+
+ if format.mountable:
format.mountpoint = mountpoint

if self.fsoptionsDict.has_key("migratecb") and
@@ -770,6 +781,7 @@ class VolumeGroupEditor:
self.lvs[templv.lvname] = {'name': templv.lvname,
'size': templv.size,
'format': templv.format,
+ 'originalFormat': templv.originalFormat,
'stripes': templv.stripes,
'logSize': templv.logSize,
'snapshotSpace': templv.snapshotSpace,
@@ -817,9 +829,11 @@ class VolumeGroupEditor:

tempvg = self.getTempVG()
name = self.storage.createSuggestedLVName(tempvg)
+ format = getFormat(self.storage.defaultFSType)
self.lvs[name] = {'name': name,
'size': free,
- 'format': getFormat(self.storage.defaultFSType),
+ 'format': format,
+ 'originalFormat': format,
'stripes': 1,
'logSize': 0,
'snapshotSpace': 0,
@@ -1073,12 +1087,7 @@ class VolumeGroupEditor:
log.debug("lv %s already exists" % lv.lvname)
# this lv is preexisting. check for resize and reformat.
# first, get the real/original lv
- origlv = None
- for _lv in self.vg.lvs:
- if _lv.lvname == lv.lvname:
- origlv = _lv
- break
-
+ origlv = self.getLVByName(lv.lvname)
if lv.resizable and lv.targetSize != origlv.size:
actions.append(ActionResizeDevice(origlv, lv.targetSize))

@@ -1100,6 +1109,39 @@ class VolumeGroupEditor:
usedev = origlv
format = lv.format

+ # no formatting action requested, meaning we should
+ # cancel all format create/destroy actions
+ if format == usedev.originalFormat:
+ devicetree = self.storage.devicetree
+ cancel = []
+ if origlv.originalFormat.type == "luks":
+ path = "/dev/mapper/luks-%s" % origlv.originalFormat.uuid
+ cancel.extend(devicetree.findActions(path=path))
+
+ cancel.extend(devicetree.findActions(type="create" ,
+ object="format",
+ devid=origlv.id))
+ cancel.extend(devicetree.findActions(type="destroy ",
+ object="format",
+ devid=origlv.id))
+ for action in cancel:
+ devicetree.cancelAction(action)
+
+ # even though we cancelled a bunch of actions, it's
+ # pretty much impossible to be sure we cancelled them
+ # in the correct order. make sure things are back to
+ # their original state.
+ origlv.format = request.originalFormat
+ if origlv.format.type == "luks":
+ try:
+ usedev = devicetree.getChildren(origlv)[0]
+ except IndexError:
+ usedev = origlv
+ else:
+ usedev.format = usedev.originalFormat
+ else:
+ usedev = origlv
+
if hasattr(format, "mountpoint"):
usedev.format.mountpoint = format.mountpoint

@@ -1164,6 +1206,14 @@ class VolumeGroupEditor:
self.dialog.destroy()
self.dialog = None

+ def getLVByName(self, name, vg=None):
+ if vg is None:
+ vg = self.vg
+
+ for lv in vg.lvs:
+ if lv.lvname == name or lv.name == name:
+ return lv
+
def __init__(self, anaconda, intf, parent, vg, isNew = 0):
self.storage = anaconda.storage

@@ -1192,6 +1242,7 @@ class VolumeGroupEditor:
self.lvs[lv.lvname] = {"name": lv.lvname,
"size": lv.size,
"format": copy.copy(lv.format),
+ "originalFormat": lv.originalFormat,
"stripes": lv.stripes,
"logSize": lv.logSize,
"snapshotSpace": lv.snapshotSpace,
diff --git a/iw/partition_dialog_gui.py b/iw/partition_dialog_gui.py
index 52e06d5..b621087 100644
--- a/iw/partition_dialog_gui.py
+++ b/iw/partition_dialog_gui.py
@@ -287,12 +287,39 @@ class PartitionEditor:
actions.append(ActionCreateDevice(luksdev))
actions.append(ActionCreateFormat(luksdev))
elif not self.fsoptionsDict["formatcb"].get_active():
- creates = devicetree.findActions(type="create",
- object="format",
- devid=usedev.id)
- for action in creates:
+ # if the format checkbutton is inactive, cancel all
+ # actions on this device that create or destroy
+ # formats
+ cancel = []
+ if request.originalFormat.type == "luks":
+ path = "/dev/mapper/luks-%s" % request.originalFormat.uuid
+ cancel.extend(devicetree.findActions(path=path))
+
+ cancel.extend(devicetree.findActions(type="destroy ",
+ object="format",
+ devid=request.id))
+ cancel.extend(devicetree.findActions(type="create" ,
+ object="format",
+ devid=request.id))
+ cancel.reverse()
+ for action in cancel:
devicetree.cancelAction(action)

+ # even though we cancelled a bunch of actions, it's
+ # pretty much impossible to be sure we cancelled them
+ # in the correct order. make sure things are back to
+ # their original state.
+ request.format = request.originalFormat
+ if request.format.type == "luks":
+ try:
+ usedev = devicetree.getChildren(request)[0]
+ except IndexError:
+ usedev = request
+ else:
+ usedev.format = usedev.originalFormat
+ else:
+ usedev = request
+
if usedev.format.mountable:
usedev.format.mountpoint = mountpoint
elif self.origrequest.protected and usedev.format.mountable:
@@ -416,15 +443,22 @@ class PartitionEditor:

row = row + 1

- # original fs label
- if usereq.format.exists and
- getattr(usereq.format, "label", None):
- maintable.attach(createAlignedLabel(_("Original File System "
- "Label:")),
+ # original fs type and label
+ if self.origrequest.exists:
+ maintable.attach(createAlignedLabel(_("Original File System Type:")),
0, 1, row, row + 1)
- fslabel = gtk.Label(usereq.format.label)
- maintable.attach(fslabel, 1, 2, row, row + 1)
- row = row + 1
+ self.fstypeCombo = gtk.Label(usereq.originalFormat.name)
+
+ maintable.attach(self.fstypeCombo, 1, 2, row, row + 1)
+ row += 1
+
+ if getattr(usereq.originalFormat, "label", None):
+ maintable.attach(createAlignedLabel(_("Original File System "
+ "Label:")),
+ 0, 1, row, row + 1)
+ fslabel = gtk.Label(usereq.originalFormat.label)
+ maintable.attach(fslabel, 1, 2, row, row + 1)
+ row = row + 1

# size
if not self.origrequest.exists:
diff --git a/iw/partition_ui_helpers_gui.py b/iw/partition_ui_helpers_gui.py
index 46e2efb..ec8d236 100644
--- a/iw/partition_ui_helpers_gui.py
+++ b/iw/partition_ui_helpers_gui.py
@@ -401,6 +401,8 @@ def createPreExistFSOptionSection(origrequest, maintable, row, mountCombo,

if luksdev:
lukscb.set_active(1)
+
+ if origrequest.originalFormat.type == "luks":
lukscb.set_data("encrypted", 1)
else:
lukscb.set_data("encrypted", 0)
diff --git a/iw/raid_dialog_gui.py b/iw/raid_dialog_gui.py
index 086c562..8e31767 100644
--- a/iw/raid_dialog_gui.py
+++ b/iw/raid_dialog_gui.py
@@ -279,7 +279,45 @@ class RaidEditor:
luksdev = None

actions.append(ActionDestroyFormat(self.origreques t))
- elif self.origrequest.format.mountable:
+ elif self.fsoptionsDict.has_key("formatcb") and
+ not self.fsoptionsDict["formatcb"].get_active():
+ # if the format checkbutton is inactive, cancel all
+ # actions on this device that create or destroy formats
+ devicetree = self.storage.devicetree
+ request = self.origrequest
+ cancel = []
+ if request.originalFormat.type == "luks":
+ path = "/dev/mapper/luks-%s" % request.originalFormat.uuid
+ cancel.extend(devicetree.findActions(path=path))
+
+ cancel.extend(devicetree.findActions(type="destroy ",
+ object="format",
+ devid=request.id))
+ cancel.extend(devicetree.findActions(type="create" ,
+ object="format",
+ devid=request.id))
+ for action in cancel:
+ devicetree.cancelAction(action)
+
+ # even though we cancelled a bunch of actions, it's
+ # pretty much impossible to be sure we cancelled them
+ # in the correct order. make sure things are back to
+ # their original state.
+ request.format = request.originalFormat
+ if request.format.type == "luks":
+ try:
+ usedev = devicetree.getChildren(request)[0]
+ except IndexError:
+ usedev = request
+ else:
+ usedev.format = usedev.originalFormat
+ else:
+ usedev = request
+
+ if usedev.format.mountable:
+ usedev.format.mountpoint = mountpoint
+
+ if self.origrequest.format.mountable:
self.origrequest.format.mountpoint = mountpoint

if self.fsoptionsDict.has_key("migratecb") and
@@ -408,22 +446,18 @@ class RaidEditor:
lbl.set_mnemonic_widget(self.fstypeCombo)
maintable.attach(self.fstypeCombo, 1, 2, row, row + 1)
row += 1
- elif format.exists:
+ else:
maintable.attach(createAlignedLabel(_("Original File System Type:")),
0, 1, row, row + 1)
- if format.type:
- self.fstypeCombo = gtk.Label(format.name)
- else:
- self.fstypeCombo = gtk.Label(_("Unknown"))
-
+ self.fstypeCombo = gtk.Label(usedev.originalFormat.name)
maintable.attach(self.fstypeCombo, 1, 2, row, row + 1)
row += 1

- if getattr(format, "label", None):
+ if getattr(usedev.originalFormat, "label", None):
maintable.attach(createAlignedLabel(_("Original File System "
"Label:")),
0, 1, row, row + 1)
- maintable.attach(gtk.Label(format.label),
+ maintable.attach(gtk.Label(usedev.originalFormat.l abel),
1, 2, row, row + 1)
row += 1

--
1.6.6

_______________________________________________
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:56 AM.

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