summaryrefslogtreecommitdiffstats
path: root/pyanaconda
diff options
context:
space:
mode:
authorDavid Lehman <dlehman@redhat.com>2012-06-27 13:20:23 -0500
committerDavid Lehman <dlehman@redhat.com>2012-07-03 10:41:26 -0500
commit9d5f53e8fb1e9fb354e49a53f8306401f90bbf23 (patch)
treeb311266f38ba58c988e66979efedf90b4c5e66e7 /pyanaconda
parent9bcb5a9b066c9161970e4905c78508454d56a940 (diff)
downloadanaconda-9d5f53e8fb1e9fb354e49a53f8306401f90bbf23.tar.gz
anaconda-9d5f53e8fb1e9fb354e49a53f8306401f90bbf23.tar.xz
anaconda-9d5f53e8fb1e9fb354e49a53f8306401f90bbf23.zip
Move disk initialization code into a reinitializeDisk method.
Diffstat (limited to 'pyanaconda')
-rw-r--r--pyanaconda/storage/__init__.py42
1 files changed, 29 insertions, 13 deletions
diff --git a/pyanaconda/storage/__init__.py b/pyanaconda/storage/__init__.py
index 612ee7dee..4eeed5316 100644
--- a/pyanaconda/storage/__init__.py
+++ b/pyanaconda/storage/__init__.py
@@ -525,12 +525,7 @@ class Storage(object):
for disk in self.disks:
if disk.format.type is None:
log.info("zerombr: initializing %s" % disk.name)
-
- labelType = storage.platform.bestDiskLabelType(disk)
- newLabel = getFormat("disklabel", device=disk.path,
- labelType=labelType)
- create_action = ActionCreateFormat(disk, format=newLabel)
- storage.devicetree.registerAction(create_action)
+ self.reinitializeDisk(disk)
# we may have added candidate boot disks just above by initializing
self.updateBootLoaderDiskList()
@@ -891,6 +886,18 @@ class Storage(object):
if disk.format.labelType == self.platform.bestDiskLabelType(disk):
continue
+ self.reinitializeDisk(disk)
+
+ self.updateBootLoaderDiskList()
+
+ def reinitializeDisk(self, disk):
+ """ (Re)initialize a disk by creating a disklabel on it.
+
+ The disk should not contain any partitions except perhaps for a
+ magic partitions on mac and sun disklabels.
+ """
+ # first, remove magic mac/sun partitions from the parted Disk
+ if disk.partitioned:
magic_partitions = {"mac": 1, "sun": 3}
if disk.format.labelType in magic_partitions:
number = magic_partitions[disk.format.labelType]
@@ -903,14 +910,23 @@ class Storage(object):
# disk. Still, we need it out of the devicetree.
self.devicetree._removeDevice(part, moddisk=False)
- destroy_action = ActionDestroyFormat(disk)
- newLabel = getFormat("disklabel", device=disk.path,
- labelType=nativeLabelType)
- create_action = ActionCreateFormat(disk, format=newLabel)
- self.devicetree.registerAction(destroy_action)
- self.devicetree.registerAction(create_action)
+ if disk.partitioned and disk.format.partitions:
+ raise ValueError("cannot reinitialize a disk that has partitions")
- self.updateBootLoaderDiskList()
+ # remove existing formatting from the disk
+ destroy_action = ActionDestroyFormat(disk)
+ self.devicetree.registerAction(destroy_action)
+
+ if self.platform:
+ labelType = self.platform.bestDiskLabelType(disk)
+ else:
+ labelType = None
+
+ # create a new disklabel on the disk
+ newLabel = getFormat("disklabel", device=disk.path,
+ labelType=labelType)
+ create_action = ActionCreateFormat(disk, format=newLabel)
+ self.devicetree.registerAction(create_action)
def removeEmptyExtendedPartitions(self):
for disk in self.partitioned: