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

[PATCH 1/2] Adjust remaining PartitionDevices' names after removing a partition.



Since parted renames/renumbers partitions, we need to update the names
of the PartitionDevice instances so that they are in sync with the parted
Partition.
---
 storage/devicetree.py |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/storage/devicetree.py b/storage/devicetree.py
index 1af24c3..63fc18b 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -713,6 +713,14 @@ class DeviceTree(object):
 
             dev.disk.partedDisk.removePartition(dev.partedPartition)
 
+            # adjust all other PartitionDevice instances belonging to the
+            # same disk so the device name matches the potentially altered
+            # name of the parted.Partition
+            for device in self._devices:
+                if isinstance(device, PartitionDevice) and \
+                   device.disk == dev.disk:
+                    device.updateName()
+
         self._devices.remove(dev)
         log.debug("removed %s (%s) from device tree" % (dev.name,
                                                         dev.type))
-- 
1.6.0.6


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