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

[PATCH 2/5] Store immutable info into the device for easier access



Related: rhbz#593642
---
 storage/__init__.py   |    5 ++---
 storage/devices.py    |    1 +
 storage/devicetree.py |    9 ++++-----
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/storage/__init__.py b/storage/__init__.py
index abe5e0f..38bce75 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -692,9 +692,8 @@ class Storage(object):
                     msg += "%s: %s" % (dev, reasons[dev])
                 return msg
 
-        for i in self.devicetree.immutableDevices:
-            if i[0] == device.name:
-                return i[1]
+        if device.immutable:
+            return device.immutable
 
         return False
 
diff --git a/storage/devices.py b/storage/devices.py
index d6c8066..93b90ec 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -461,6 +461,7 @@ class StorageDevice(Device):
         self.bus = bus
 
         self.protected = False
+        self.immutable = None
 
         self.format = format
         self.originalFormat = self.format
diff --git a/storage/devicetree.py b/storage/devicetree.py
index 39f1dcc..61f1643 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -186,7 +186,6 @@ class DeviceTree(object):
         self._ignoredDisks = []
         for disk in ignored:
             self.addIgnoredDisk(disk)
-        self.immutableDevices = []
         lvm.lvm_cc_resetFilter()
 
     def addIgnoredDisk(self, disk):
@@ -1886,8 +1885,8 @@ class DeviceTree(object):
                     lvm.blacklistVG(device.name)
                     for parent in device.parents:
                         if parent.type == "partition":
-                            self.immutableDevices.append([parent.name,
-                                _("This partition is part of an inconsistent LVM Volume Group.")])
+                            parent.immutable = \
+                                _("This partition is part of an inconsistent LVM Volume Group.")
                         else:
                             self._removeDevice(parent, moddisk=False)
                             self.addIgnoredDisk(parent.name)
@@ -1934,8 +1933,8 @@ class DeviceTree(object):
                     # ignore all the pvs
                     for parent in device.vg.parents:
                         if parent.type == "partition":
-                            self.immutableDevices.append([parent.name,
-                                _("This partition is part of an inconsistent LVM Volume Group.")])
+                            parent.immutable = \
+                                _("This partition is part of an inconsistent LVM Volume Group.")
                         else:
                             self._removeDevice(parent, moddisk=False)
                             self.addIgnoredDisk(parent.name)
-- 
1.7.0.1


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