[PATCH 1/5] Do not allow modification or removal of protected devices.

David Lehman dlehman at redhat.com
Tue Sep 16 21:01:49 UTC 2014


---
 blivet/__init__.py     | 9 +++++++++
 blivet/partitioning.py | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/blivet/__init__.py b/blivet/__init__.py
index b7a092e..de76353 100644
--- a/blivet/__init__.py
+++ b/blivet/__init__.py
@@ -1287,6 +1287,9 @@ class Blivet(object):
             :type device: :class:`~.devices.StorageDevice`
             :rtype: None
         """
+        if device.protected:
+            raise ValueError("cannot modify protected device")
+
         if device.format.exists and device.format.type and \
            not device.formatImmutable:
             # schedule destruction of any formatting while we're at it
@@ -1309,6 +1312,9 @@ class Blivet(object):
             :class:`~.deviceaction.ActionDestroyFormat` prior to calling this
             method.
         """
+        if device.protected:
+            raise ValueError("cannot modify protected device")
+
         self.devicetree.registerAction(ActionDestroyFormat(device))
         self.devicetree.registerAction(ActionCreateFormat(device, fmt))
 
@@ -1338,6 +1344,9 @@ class Blivet(object):
             If the device has formatting that is recognized as being resizable
             an action will be scheduled to resize it as well.
         """
+        if device.protected:
+            raise ValueError("cannot modify protected device")
+
         classes = []
         if device.resizable:
             classes.append(ActionResizeDevice)
diff --git a/blivet/partitioning.py b/blivet/partitioning.py
index 48d72ff..957ce04 100644
--- a/blivet/partitioning.py
+++ b/blivet/partitioning.py
@@ -852,7 +852,7 @@ def doPartitioning(storage):
         :raises: :class:`~.errors.PartitioningError`
         :returns: :const:`None`
     """
-    disks = storage.partitioned
+    disks = [d for d in storage.partitioned if not d.protected]
     for disk in disks:
         try:
             disk.setup()
-- 
1.9.3



More information about the anaconda-patches mailing list