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

[rhel6-branch 2/2] mpath: update parted object in DMDevice.setup()



consecutive teardowns() and setups() can change its /dev/mapper/dm-X path.
---
 storage/devices.py |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index 7ef1160..6aa8972 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -534,6 +534,11 @@ class StorageDevice(Device):
 
         return self._partedDevice
 
+    def updatePartedDevice(self):
+       new_parted_device  = parted.Device(path=self.path)
+       if self._partedDevice != new_parted_device:
+           self._partedDevice = new_parted_device
+
     def _getTargetSize(self):
         return self._targetSize
 
@@ -1557,6 +1562,12 @@ class DMDevice(StorageDevice):
 
         return _status
 
+    def setup(self, intf=None, orig=False):
+        StorageDevice.setup(self, intf, orig)
+        # dm-X number can change between teardown() and setup(), keep the parted
+        # object in sync
+        self.updatePartedDevice()
+
     def updateSysfsPath(self):
         """ Update this device's sysfs path. """
         log_method_call(self, self.name, status=self.status)
-- 
1.7.1.1


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