summaryrefslogtreecommitdiffstats
path: root/partitions.py
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2005-03-28 21:36:59 +0000
committerPeter Jones <pjones@redhat.com>2005-03-28 21:36:59 +0000
commite1b00db6c794295a0e68ffc8a498f54eed78ebd0 (patch)
tree4ebb3a3addbeaa7f0a565efc864eadad0785199f /partitions.py
parentdc3bdef00ab252648dd31edae9ab299af7007c19 (diff)
downloadanaconda-e1b00db6c794295a0e68ffc8a498f54eed78ebd0.tar.gz
anaconda-e1b00db6c794295a0e68ffc8a498f54eed78ebd0.tar.xz
anaconda-e1b00db6c794295a0e68ffc8a498f54eed78ebd0.zip
update LV snapshot delete code
Diffstat (limited to 'partitions.py')
-rw-r--r--partitions.py39
1 files changed, 25 insertions, 14 deletions
diff --git a/partitions.py b/partitions.py
index 1a582a432..f6e65496e 100644
--- a/partitions.py
+++ b/partitions.py
@@ -192,7 +192,6 @@ class Partitions:
lvm.vgactivate()
pvs = lvm.pvlist()
- snapshots = {}
for (vg, size, pesize) in lvm.vglist():
try:
preexist_size = float(size)
@@ -219,10 +218,10 @@ class Partitions:
vgid = self.addRequest(spec)
for (lvvg, lv, size, lvorigin) in lvm.lvlist():
+ if lvorigin:
+ continue
if lvvg != vg:
continue
- snapshots.setdefault(lvorigin, [])
- snapshots[lvorigin].append(lv)
# size is number of bytes, we want size in megs
lvsize = float(size)
@@ -239,16 +238,9 @@ class Partitions:
spec = partRequests.LogicalVolumeRequestSpec(fsystem,
format = format, size = lvsize, volgroup = vgid,
- lvname = lv, mountpoint = mnt, preexist = 1,
- lvorigin = lvorigin)
+ lvname = lv, mountpoint = mnt, preexist = 1)
self.addRequest(spec)
- for origin, snapnames in snapshots.items():
- parent = self.getRequestByLogicalVolumeName(origin)
- for snapname in snapnames:
- child = self.getRequestByLogicalVolumeName(snapname)
- parent.snapshots.append(child)
-
for vg in lvm.partialvgs():
spec = partRequests.PartialVolumeGroupSpec(vgname = vg)
self.addDelete(spec)
@@ -1249,13 +1241,34 @@ class Partitions:
diskset.startAllRaid()
lvm.vgactivate()
+ snapshots = {}
+ for (lvvg, lv, size, lvorigin) in lvm.lvlist():
+ snapshots.setdefault(lv, [])
+ if lvorigin:
+ snapshots.setdefault(lvorigin, [])
+ snapshots[lvorigin].append((lv, lvvg))
+
+ lvm_parent_deletes = []
+ tmp = {}
+ def addSnap(name, vg):
+ snaps = snapshots[name]
+ for snap, snapvg in snaps:
+ addSnap(snap, snapvg)
+ if not tmp.has_key((name, vg)):
+ tmp[(name, vg)] = 1
+ lvm_parent_deletes.append((name,vg))
+
# now, go through and delete logical volumes
for delete in self.deletes:
if isinstance(delete, partRequests.DeleteLogicalVolumeSpec):
if not delete.beenDeleted():
- lvm.lvremove(delete.name, delete.vg)
+ addSnap(delete.name, delete.vg)
delete.setDeleted(1)
+ for name,vg in lvm_parent_deletes:
+ log("removing lv %s" % (name,))
+ lvm.lvremove(name, vg)
+
# now, go through and delete volume groups
for delete in self.deletes:
if isinstance(delete, partRequests.DeleteVolumeGroupSpec):
@@ -1292,8 +1305,6 @@ class Partitions:
self.addDelete(delete)
elif isinstance(req, partRequests.LogicalVolumeRequestSpec):
if id == req.volumeGroup:
- for child in req.snapshots:
- toRemove.append(child)
toRemove.append(req)
tmp = self.getRequestByID(req.volumeGroup)
if not tmp: