From 8b7ae92532fb49d0a344a3a04738999dcc979b45 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Fri, 7 Jun 2002 05:21:26 +0000 Subject: clearpart needs to go through and delete raid or lvm devices sitting on top of physical partitions as it goes through --- autopart.py | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'autopart.py') diff --git a/autopart.py b/autopart.py index fe772eac7..15c5b3117 100644 --- a/autopart.py +++ b/autopart.py @@ -760,7 +760,9 @@ def doPartitioning(diskset, requests, doRefresh = 1): diskset.refreshDevices() # XXX - handle delete requests for delete in requests.deletes: - deletePart(diskset, delete) + if isinstance(delete, partRequests.DeleteSpec): + deletePart(diskset, delete) + # FIXME: do we need to do anything with other types of deletes?? newParts = partlist() (ret, msg) = processPartitioning(diskset, requests, newParts) @@ -782,6 +784,38 @@ def doPartitioning(diskset, requests, doRefresh = 1): # more specific message? raise PartitioningWarning, _("Boot partition %s may not meet booting constraints for your architecture. Creation of a boot disk is highly encouraged.") %(requests.getBootableRequest().mountpoint) +# remove metadevices (lvm and raid) from partitions which depend on +# the request which had the given id. to be called from within clearpart +# NOTE: I am called recursively to handle LVM on top of RAID and LVs in VGs +def doClearDependentDevices(partitions, id): + toRemove = [] + for req in partitions.requests: + if isinstance(req, partRequests.RaidRequestSpec): + if id in req.raidmembers: + toRemove.append(req) + elif isinstance(req, partRequests.VolumeGroupRequestSpec): + if id in req.physicalVolumes: + toRemove.append(req) + delete = partRequests.DeleteVolumeGroupSpec(req.volumeGroupName) + partitions.addDelete(delete) + elif isinstance(req, partRequests.LogicalVolumeRequestSpec): + if id == req.volumeGroup: + toRemove.append(req) + tmp = partitions.getRequestByID(req.volumeGroup) + if not tmp: + log("Unable to find the vg for %s" (req.logicalVolumeName,)) + vgname = req.volumeGroup + else: + vgname = tmp.volumeGroupName + delete = partRequests.DeleteLogicalVolumeSpec(req.logicalVolumeName, + vgname) + partitions.addDelete(delete) + + for request in toRemove: + doClearDependentDevices(partitions, request.uniqueID) + partitions.removeRequest(request) + + # given clearpart specification execute it # probably want to reset diskset and partition request lists before calling # this the first time @@ -823,6 +857,7 @@ def doClearPartAction(partitions, diskset): part = disk.next_partition(part) continue + doClearDependentDevices(partitions, old.uniqueID) partitions.removeRequest(old) drive = partedUtils.get_partition_drive(part) -- cgit