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 08-17-2011, 07:04 PM
David Lehman
 
Default Clean up obsolete extended partitions if partitioning fails. (#672010)

If we have an extended partition from a previous run through
doPartitioning and then partitioning fails we have to make sure
that obsolete extended is removed before we return control to
the partition gui.
---
pyanaconda/storage/partitioning.py | 112 +++++++++++++++++++-----------------
1 files changed, 59 insertions(+), 53 deletions(-)

diff --git a/pyanaconda/storage/partitioning.py b/pyanaconda/storage/partitioning.py
index e4a9c41..237e55e 100644
--- a/pyanaconda/storage/partitioning.py
+++ b/pyanaconda/storage/partitioning.py
@@ -876,6 +876,49 @@ def getFreeRegions(disks):

return free

+def updateExtendedPartitions(storage, disks):
+ # XXX hack -- if we created any extended partitions we need to add
+ # them to the tree now
+ for disk in disks:
+ extended = disk.format.extendedPartition
+ if not extended:
+ # remove any obsolete extended partitions
+ for part in storage.partitions:
+ if part.disk == disk and part.isExtended:
+ if part.exists:
+ storage.destroyDevice(part)
+ else:
+ storage.devicetree._removeDevice(part, moddisk=False)
+ continue
+
+ extendedName = devicePathToName(extended.getDeviceNodeName())
+ # remove any obsolete extended partitions
+ for part in storage.partitions:
+ if part.disk == disk and part.isExtended and
+ part.partedPartition not in disk.format.partitions:
+ if part.exists:
+ storage.destroyDevice(part)
+ else:
+ storage.devicetree._removeDevice(part, moddisk=False)
+
+ device = storage.devicetree.getDeviceByName(extendedName)
+ if device:
+ if not device.exists:
+ # created by us, update partedPartition
+ device.partedPartition = extended
+ continue
+
+ # This is a little odd because normally instantiating a partition
+ # that does not exist means leaving self.parents empty and instead
+ # populating self.req_disks. In this case, we need to skip past
+ # that since this partition is already defined.
+ device = PartitionDevice(extendedName, parents=disk)
+ device.parents = [disk]
+ device.partedPartition = extended
+ # just add the device for now -- we'll handle actions at the last
+ # moment to simplify things
+ storage.devicetree._addDevice(device)
+
def doPartitioning(storage, bootloader=None):
""" Allocate and grow partitions.

@@ -931,63 +974,26 @@ def doPartitioning(storage, bootloader=None):

removeNewPartitions(disks, partitions)
free = getFreeRegions(disks)
- allocatePartitions(storage, disks, partitions, free, bootloader=bootloader)
- growPartitions(disks, partitions, free)

- # The number and thus the name of partitions may have changed now,
- # allocatePartitions() takes care of this for new partitions, but not
- # for pre-existing ones, so we update the name of all partitions here
- for part in storage.partitions:
- # needed because of XXX hack below
- if part.isExtended:
- continue
- part.updateName()
-
- # XXX hack -- if we created any extended partitions we need to add
- # them to the tree now
- for disk in disks:
- extended = disk.format.extendedPartition
- if not extended:
- # remove any obsolete extended partitions
- for part in storage.partitions:
- if part.disk == disk and part.isExtended:
- if part.exists:
- storage.destroyDevice(part)
- else:
- storage.devicetree._removeDevice(part, moddisk=False)
- continue
-
- extendedName = devicePathToName(extended.getDeviceNodeName())
- # remove any obsolete extended partitions
+ try:
+ allocatePartitions(storage, disks, partitions, free,
+ bootloader=bootloader)
+ growPartitions(disks, partitions, free)
+ finally:
+ # The number and thus the name of partitions may have changed now,
+ # allocatePartitions() takes care of this for new partitions, but not
+ # for pre-existing ones, so we update the name of all partitions here
for part in storage.partitions:
- if part.disk == disk and part.isExtended and
- part.partedPartition not in disk.format.partitions:
- if part.exists:
- storage.destroyDevice(part)
- else:
- storage.devicetree._removeDevice(part, moddisk=False)
-
- device = storage.devicetree.getDeviceByName(extendedName)
- if device:
- if not device.exists:
- # created by us, update partedPartition
- device.partedPartition = extended
- continue
+ # leave extended partitions as-is -- we'll handle them separately
+ if part.isExtended:
+ continue
+ part.updateName()

- # This is a little odd because normally instantiating a partition
- # that does not exist means leaving self.parents empty and instead
- # populating self.req_disks. In this case, we need to skip past
- # that since this partition is already defined.
- device = PartitionDevice(extendedName, parents=disk)
- device.parents = [disk]
- device.partedPartition = extended
- # just add the device for now -- we'll handle actions at the last
- # moment to simplify things
- storage.devicetree._addDevice(device)
+ updateExtendedPartitions(storage, disks)

- # make sure the stage1_device gets updated
- if storage.anaconda:
- storage.anaconda.bootloader.stage1_device = None
+ # make sure the stage1_device gets updated
+ if storage.anaconda:
+ storage.anaconda.bootloader.stage1_device = None

def allocatePartitions(storage, disks, partitions, freespace, bootloader=None):
""" Allocate partitions based on requested features.
--
1.7.3.4

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

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