[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH 1/1] Make sure that removePartition does not change the obj (496660)



---
 storage/devicetree.py |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/storage/devicetree.py b/storage/devicetree.py
index 3837b45..b0459de 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -712,6 +712,19 @@ class DeviceTree(object):
                         "Logical partitions present." % dev.name)
 
             dev.disk.partedDisk.removePartition(dev.partedPartition)
+            # Removing a partition from this disk means that some partition
+            # objects are going to change.  We need to make sure that all
+            # the self._devices that are partitions have a partedPartition
+            # that point to the new object.
+            # Should this be in pyparted?
+            for device in self._devices:
+                if device.type == "partition" and \
+                        device.disk == dev.disk:
+                    #Now look for the appropriate partition
+                    for partition in device.disk.partedDisk.partitions:
+                        if partition.path == device.partedPartition.path and \
+                                partition is not device.partedPartition:
+                            device.partedPartition = partition
 
         self._devices.remove(dev)
         log.debug("removed %s (%s) from device tree" % (dev.name,
-- 
1.6.0.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]