[blivet/rhel7/master] Add a property for read-only devices.
David Shea
dshea at redhat.com
Tue Sep 9 18:48:37 UTC 2014
Add read-only devices to the devicetree, and return read-only devices as
protected.
Resolves: rhbz#1072619
---
blivet/devices.py | 20 +++++++++++++++++++-
blivet/devicetree.py | 12 ++++--------
2 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/blivet/devices.py b/blivet/devices.py
index bab785d..0febc2a 100644
--- a/blivet/devices.py
+++ b/blivet/devices.py
@@ -562,7 +562,8 @@ class StorageDevice(Device):
self._model = model
self.bus = bus
- self.protected = False
+ self._readonly = False
+ self._protected = False
self.controllable = not flags.testing
self.format = fmt
@@ -805,6 +806,23 @@ class StorageDevice(Device):
else:
raise errors.DeviceError("device type %s is not resizable" % self.type)
+ @property
+ def readonly(self):
+ # A device is read-only if it or any parent device is read-only
+ return self._readonly or any(p.readonly for p in self.parents)
+
+ @readonly.setter
+ def readonly(self, value):
+ self._readonly = value
+
+ @property
+ def protected(self):
+ return self.readonly or self._protected
+
+ @protected.setter
+ def protected(self, value):
+ self._protected = value
+
#
# setup
#
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index 7c92288..74a485e 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -658,14 +658,6 @@ class DeviceTree(object):
# ignore loop devices unless they're backed by a file
return (not loop.get_backing_file(name))
- if self.udevDeviceIsDisk(info):
- # Ignore any readonly disks
- if util.get_sysfs_attr(info["sysfs_path"], 'ro') == '1':
- log.debug("Ignoring read only device %s", name)
- # FIXME: We have to handle this better, ie: not ignore these.
- self.addIgnoredDisk(name)
- return True
-
# FIXME: check for virtual devices whose slaves are on the ignore list
def udevDeviceIsDisk(self, info):
@@ -1218,6 +1210,10 @@ class DeviceTree(object):
log.debug("no device obtained for %s", name)
return
+ # If this device is read-only, mark it as such now.
+ if self.udevDeviceIsDisk(info) and util.get_sysfs_attr(info["sysfs_path"], 'ro') == '1':
+ device.readonly = True
+
# If this device is protected, mark it as such now. Once the tree
# has been populated, devices' protected attribute is how we will
# identify protected devices.
--
2.1.0
More information about the anaconda-patches
mailing list