summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2009-04-30 14:56:45 -0400
committerChris Lumens <clumens@redhat.com>2009-05-01 17:06:55 -0400
commit54f10188d21312b1d51369aebccf6f4535e07d6a (patch)
treee28aa002b0ba79a8898f87169543551b2776befe
parentc25d4bcb43f462c05723774237104a7f5bd5fdb3 (diff)
downloadanaconda-54f10188d21312b1d51369aebccf6f4535e07d6a.tar.gz
anaconda-54f10188d21312b1d51369aebccf6f4535e07d6a.tar.xz
anaconda-54f10188d21312b1d51369aebccf6f4535e07d6a.zip
Break the complex should-clear logic out of clearPartitions.
-rw-r--r--storage/partitioning.py56
1 files changed, 27 insertions, 29 deletions
diff --git a/storage/partitioning.py b/storage/partitioning.py
index 663d1f18f..c2972fade 100644
--- a/storage/partitioning.py
+++ b/storage/partitioning.py
@@ -249,6 +249,31 @@ def doAutoPartition(anaconda):
anaconda.id.storage.reset()
return DISPATCH_BACK
+def shouldClear(part, clearPartType, clearPartDisks=None, protectedPartitions=None):
+ if not isinstance(part, PartitionDevice):
+ return False
+
+ # If we got a list of disks to clear, make sure this one's on it
+ if clearPartDisks and part.disk.name not in clearPartDisks:
+ return False
+
+ # Don't clear partitions holding install media.
+ if protectedPartitions and part.name in protectedPartitions:
+ return False
+
+ # We don't want to fool with extended partitions, freespace, &c
+ if part.partType not in [parted.PARTITION_NORMAL, parted.PARTITION_LOGICAL]:
+ return False
+
+ if clearPartType != CLEARPART_TYPE_ALL and not part.format.linuxNative and \
+ not part.getFlag(parted.PARTITION_LVM) and \
+ not part.getFlag(parted.PARTIITON_RAID) and \
+ not part.getFlag(parted.PARTITION_SWAP):
+ return False
+
+ # TODO: do platform-specific checks on ia64, pSeries, iSeries, mac
+
+ return True
def clearPartitions(storage):
""" Clear partitions and dependent devices from disks.
@@ -276,35 +301,8 @@ def clearPartitions(storage):
clearparts = [] # list of partitions we'll remove
for part in partitions:
log.debug("clearpart: looking at %s" % part.name)
- clear = False # whether or not we will clear this partition
-
- # if we got a list of disks to clear, make sure this one's on it
- if storage.clearPartDisks and \
- part.disk.name not in storage.clearPartDisks:
- continue
-
- # don't clear partitions holding install media
- if part.name in storage.protectedPartitions:
- continue
-
- # we don't want to fool with extended partitions, freespace, &c
- if part.partType not in (parted.PARTITION_NORMAL,
- parted.PARTITION_LOGICAL):
- continue
-
- if storage.clearPartType == CLEARPART_TYPE_ALL:
- clear = True
- else:
- if part.format and part.format.linuxNative:
- clear = True
- elif part.partedPartition.getFlag(parted.PARTITION_LVM) or \
- part.partedPartition.getFlag(parted.PARTITION_RAID) or \
- part.partedPartition.getFlag(parted.PARTITION_SWAP):
- clear = True
-
- # TODO: do platform-specific checks on ia64, pSeries, iSeries, mac
-
- if not clear:
+ if not shouldClear(part, storage.clearPartType, storage.clearPartDisks,
+ storage.protectedPartitions):
continue
log.debug("clearing %s" % part.name)