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

[PATCH 1/2] Add a deviceMostlyImmutable method.



The difference between this and deviceImmutable is that deviceImmutable means
you really can't do anything with a device.  deviceMostlyImmutable means you
can't modify or delete a device, but you can deal with it on a read-only
basis.  The only reason for this is to be able to mount the hdiso install
source.
---
 storage/__init__.py |   26 ++++++++++++++++++++------
 1 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/storage/__init__.py b/storage/__init__.py
index d7b53b6..30ea050 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -480,13 +480,30 @@ class Storage(object):
         return dests
 
     def deviceImmutable(self, device):
+        """Return any reason the device cannot be modified/removed, or False.
+
+           Reasons include all the reasons from deviceMostlyImmutable,
+           plus if the device is a protected partition.
+        """
+        reason = self.deviceMostlyImmutable(device)
+        if reason:
+            return reason
+        else:
+            if device.name in self.protectedPartitions:
+                return _("This partition is holding the data for the hard "
+                          "drive install.")
+
+        return False
+
+    def deviceMostlyImmutable(self, device):
         """ Return any reason the device cannot be modified/removed.
 
-            Return False if the device can be removed.
+            Return False if the device can be removed.  Protected partitions
+            can be manipulated on a read-only basis.  That check will have to
+            be enforced throughout the code as needed.
 
             Devices that cannot be removed include:
 
-                - protected partitions
                 - devices that are part of an md array or lvm vg
                 - extended partition containing logical partitions that
                   meet any of the above criteria
@@ -495,10 +512,7 @@ class Storage(object):
         if not isinstance(device, Device):
             raise ValueError("arg1 (%s) must be a Device instance" % device)
 
-        if device.name in self.protectedPartitions:
-            return _("This partition is holding the data for the hard "
-                      "drive install.")
-        elif isinstance(device, PartitionDevice) and device.isProtected:
+        if isinstance(device, PartitionDevice) and device.isProtected:
             # LDL formatted DASDs always have one partition, you'd have to
             # reformat the DASD in CDL mode to get rid of it
             return _("You cannot delete a partition of a LDL formatted "
-- 
1.6.1.3


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