[PATCH 5/7] Add flag indicating whether a device can be activated/deactivated.

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

 



---
 pyanaconda/storage/devices.py |  130 +++++++++++++++++++++++++++++++++--------
 1 files changed, 106 insertions(+), 24 deletions(-)

diff --git a/pyanaconda/storage/devices.py b/pyanaconda/storage/devices.py
index 5462eee..e723dcf 100644
--- a/pyanaconda/storage/devices.py
+++ b/pyanaconda/storage/devices.py
@@ -478,6 +478,7 @@ class StorageDevice(Device):
 
         self.protected = False
         self.immutable = None
+        self.controllable = True
 
         self.format = format
         self.originalFormat = self.format
@@ -627,10 +628,14 @@ class StorageDevice(Device):
 
     def setup(self, intf=None, orig=False):
         """ Open, or set up, a device. """
-        log_method_call(self, self.name, orig=orig, status=self.status)
+        log_method_call(self, self.name, orig=orig, status=self.status,
+                        controllable=self.controllable)
         if not self.exists:
             raise DeviceError("device has not been created", self.name)
 
+        if not self.controllable:
+            return
+
         self.setupParents(orig=orig)
         for parent in self.parents:
             if orig:
@@ -640,10 +645,14 @@ class StorageDevice(Device):
 
     def teardown(self, recursive=None):
         """ Close, or tear down, a device. """
-        log_method_call(self, self.name, status=self.status)
+        log_method_call(self, self.name, status=self.status,
+                        controllable=self.controllable)
         if not self.exists and not recursive:
             raise DeviceError("device has not been created", self.name)
 
+        if not self.controllable:
+            return
+
         if self.status:
             if self.originalFormat.exists:
                 self.originalFormat.teardown()
@@ -882,7 +891,8 @@ class DiskDevice(StorageDevice):
 
     def setup(self, intf=None, orig=False):
         """ Open, or set up, a device. """
-        log_method_call(self, self.name, orig=orig, status=self.status)
+        log_method_call(self, self.name, orig=orig, status=self.status,
+                        controllable=self.controllable)
         if not os.path.exists(self.path):
             raise DeviceError("device does not exist", self.name)
 
@@ -1397,10 +1407,14 @@ class PartitionDevice(StorageDevice):
 
     def teardown(self, recursive=None):
         """ Close, or tear down, a device. """
-        log_method_call(self, self.name, status=self.status)
+        log_method_call(self, self.name, status=self.status,
+                        controllable=self.controllable)
         if not self.exists and not recursive:
             raise DeviceError("device has not been created", self.name)
 
+        if not self.controllable:
+            return
+
         if self.status:
             if self.originalFormat.exists:
                 self.originalFormat.teardown()
@@ -1662,10 +1676,14 @@ class DMLinearDevice(DMDevice):
 
     def setup(self, intf=None, orig=False):
         """ Open, or set up, a device. """
-        log_method_call(self, self.name, orig=orig, status=self.status)
+        log_method_call(self, self.name, orig=orig, status=self.status,
+                        controllable=self.controllable)
         if not self.exists:
             raise DeviceError("device has not been created", self.name)
 
+        if not self.controllable:
+            return
+
         if self.status:
             return
 
@@ -1704,7 +1722,8 @@ class DMLinearDevice(DMDevice):
 
     def teardown(self, recursive=None):
         """ Close, or tear down, a device. """
-        log_method_call(self, self.name, status=self.status)
+        log_method_call(self, self.name, status=self.status,
+                        controllable=self.controllable)
         if not self.exists and not recursive:
             raise DeviceError("device has not been created", self.name)
 
@@ -1798,10 +1817,14 @@ class LUKSDevice(DMCryptDevice):
 
     def setup(self, intf=None, orig=False):
         """ Open, or set up, a device. """
-        log_method_call(self, self.name, orig=orig, status=self.status)
+        log_method_call(self, self.name, orig=orig, status=self.status,
+                        controllable=self.controllable)
         if not self.exists:
             raise DeviceError("device has not been created", self.name)
 
+        if not self.controllable:
+            return
+
         self.slave.setup(orig=orig)
         if orig:
             self.slave.originalFormat.setup()
@@ -1815,10 +1838,14 @@ class LUKSDevice(DMCryptDevice):
 
     def teardown(self, recursive=False):
         """ Close, or tear down, a device. """
-        log_method_call(self, self.name, status=self.status)
+        log_method_call(self, self.name, status=self.status,
+                        controllable=self.controllable)
         if not self.exists and not recursive:
             raise DeviceError("device has not been created", self.name)
 
+        if not self.controllable:
+            return
+
         if self.status:
             if self.originalFormat.exists:
                 self.originalFormat.teardown()
@@ -2078,10 +2105,14 @@ class LVMVolumeGroupDevice(DMDevice):
             XXX we don't do anything like "vgchange -ay" because we don't
                 want all of the LVs activated, just the VG itself.
         """
-        log_method_call(self, self.name, orig=orig, status=self.status)
+        log_method_call(self, self.name, orig=orig, status=self.status,
+                        controllable=self.controllable)
         if not self.exists:
             raise DeviceError("device has not been created", self.name)
 
+        if not self.controllable:
+            return
+
         if self.status:
             return
 
@@ -2092,10 +2123,14 @@ class LVMVolumeGroupDevice(DMDevice):
 
     def teardown(self, recursive=None):
         """ Close, or tear down, a device. """
-        log_method_call(self, self.name, status=self.status)
+        log_method_call(self, self.name, status=self.status,
+                        controllable=self.controllable)
         if not self.exists and not recursive:
             raise DeviceError("device has not been created", self.name)
 
+        if not self.controllable:
+            return
+
         if self.status:
             lvm.vgdeactivate(self.name)
 
@@ -2489,13 +2524,17 @@ class LVMLogicalVolumeDevice(DMDevice):
 
     def setup(self, intf=None, orig=False):
         """ Open, or set up, a device. """
-        log_method_call(self, self.name, orig=orig, status=self.status)
+        log_method_call(self, self.name, orig=orig, status=self.status,
+                        controllable=self.controllable)
         if not self.exists:
             raise DeviceError("device has not been created", self.name)
 
         if self.status:
             return
 
+        if not self.controllable:
+            return
+
         self.vg.setup(orig=orig)
         lvm.lvactivate(self.vg.name, self._name)
 
@@ -2505,10 +2544,14 @@ class LVMLogicalVolumeDevice(DMDevice):
 
     def teardown(self, recursive=None):
         """ Close, or tear down, a device. """
-        log_method_call(self, self.name, status=self.status)
+        log_method_call(self, self.name, status=self.status,
+                        controllable=self.controllable)
         if not self.exists and not recursive:
             raise DeviceError("device has not been created", self.name)
 
+        if not self.controllable:
+            return
+
         if self.status:
             if self.originalFormat.exists:
                 self.originalFormat.teardown()
@@ -2947,13 +2990,17 @@ class MDRaidArrayDevice(StorageDevice):
 
     def setup(self, intf=None, orig=False):
         """ Open, or set up, a device. """
-        log_method_call(self, self.name, orig=orig, status=self.status)
+        log_method_call(self, self.name, orig=orig, status=self.status,
+                        controllable=self.controllable)
         if not self.exists:
             raise DeviceError("device has not been created", self.name)
 
         if self.status:
             return
 
+        if not self.controllable:
+            return
+
         disks = []
         for member in self.devices:
             member.setup(orig=orig)
@@ -2977,10 +3024,14 @@ class MDRaidArrayDevice(StorageDevice):
 
     def teardown(self, recursive=None):
         """ Close, or tear down, a device. """
-        log_method_call(self, self.name, status=self.status)
+        log_method_call(self, self.name, status=self.status,
+                        controllable=self.controllable)
         if not self.exists and not recursive:
             raise DeviceError("device has not been created", self.name)
 
+        if not self.controllable:
+            return
+
         if self.status:
             if self.originalFormat.exists:
                 self.originalFormat.teardown()
@@ -3203,13 +3254,18 @@ class DMRaidArrayDevice(DMDevice):
 
     def setup(self, intf=None, orig=False):
         """ Open, or set up, a device. """
-        log_method_call(self, self.name, orig=orig, status=self.status)
+        log_method_call(self, self.name, orig=orig, status=self.status,
+                        controllable=self.controllable)
+        if not self.controllable:
+            return
+
         StorageDevice.setup(self, intf=intf, orig=orig)
         self.activate()
 
     def teardown(self, recursive=None):
         """ Close, or tear down, a device. """
-        log_method_call(self, self.name, status=self.status)
+        log_method_call(self, self.name, status=self.status,
+                        controllable=self.controllable)
         if not self.exists and not recursive:
             raise DeviceError("device has not been created", self.name)
 
@@ -3319,11 +3375,15 @@ class MultipathDevice(DMDevice):
 
     def teardown(self, recursive=None):
         """ Tear down the mpath device. """
-        log_method_call(self, self.name, status=self.status)
+        log_method_call(self, self.name, status=self.status,
+                        controllable=self.controllable)
 
         if not self.exists and not recursive:
             raise DeviceError("device has not been created", self.name)
 
+        if not self.controllable:
+            return
+
         if self.status:
             # in case format is not a disklabel but a filesystem
             if self.originalFormat.exists:
@@ -3363,11 +3423,15 @@ class MultipathDevice(DMDevice):
 
     def setup(self, intf=None, orig=False):
         """ Open, or set up, a device. """
-        log_method_call(self, self.name, orig=orig, status=self.status)
+        log_method_call(self, self.name, orig=orig, status=self.status,
+                        controllable=self.controllable)
 
         if self.status:
             return
 
+        if not self.controllable:
+            return
+
         StorageDevice.setup(self, intf=intf, orig=orig)
         udev_settle()
         rc = iutil.execWithRedirect("multipath",
@@ -3412,11 +3476,13 @@ class NoDevice(StorageDevice):
 
     def setup(self, intf=None, orig=False):
         """ Open, or set up, a device. """
-        log_method_call(self, self.name, orig=orig, status=self.status)
+        log_method_call(self, self.name, orig=orig, status=self.status,
+                        controllable=self.controllable)
 
     def teardown(self, recursive=False):
         """ Close, or tear down, a device. """
-        log_method_call(self, self.name, status=self.status)
+        log_method_call(self, self.name, status=self.status,
+                        controllable=self.controllable)
 
     def create(self, intf=None):
         """ Create the device. """
@@ -3489,6 +3555,9 @@ class FileDevice(StorageDevice):
         return os.path.normpath("%s%s" % (root, self.name))
 
     def setup(self, intf=None, orig=False):
+        if not self.controllable:
+            return
+
         StorageDevice.setup(self, orig=orig)
         if self.format and self.format.exists and not self.format.status:
             self.format.device = self.path
@@ -3500,6 +3569,9 @@ class FileDevice(StorageDevice):
                 parent.format.setup()
 
     def teardown(self, recursive=None):
+        if not self.controllable:
+            return
+
         StorageDevice.teardown(self)
         if self.format and self.format.exists and not self.format.status:
             self.format.device = self.path
@@ -3635,13 +3707,17 @@ class LoopDevice(StorageDevice):
 
     def setup(self, intf=None, orig=False):
         """ Open, or set up, a device. """
-        log_method_call(self, self.name, orig=orig, status=self.status)
+        log_method_call(self, self.name, orig=orig, status=self.status,
+                        controllable=self.controllable)
         if not self.exists:
             raise DeviceError("device has not been created", self.name)
 
         if self.status:
             return
 
+        if not self.controllable:
+            return
+
         loop.loop_setup(self.slave.path)
         udev_settle()
         self.updateName()
@@ -3650,10 +3726,14 @@ class LoopDevice(StorageDevice):
 
     def teardown(self, recursive=False):
         """ Close, or tear down, a device. """
-        log_method_call(self, self.name, status=self.status)
+        log_method_call(self, self.name, status=self.status,
+                        controllable=self.controllable)
         if not self.exists and not recursive:
             raise DeviceError("device has not been created", self.name)
 
+        if not self.controllable:
+            return
+
         if self.status:
             if self.originalFormat.exists:
                 self.originalFormat.teardown()
@@ -3887,11 +3967,13 @@ class NFSDevice(StorageDevice, NetworkStorageDevice):
 
     def setup(self, intf=None, orig=False):
         """ Open, or set up, a device. """
-        log_method_call(self, self.name, orig=orig, status=self.status)
+        log_method_call(self, self.name, orig=orig, status=self.status,
+                        controllable=self.controllable)
 
     def teardown(self, recursive=None):
         """ Close, or tear down, a device. """
-        log_method_call(self, self.name, status=self.status)
+        log_method_call(self, self.name, status=self.status,
+                        controllable=self.controllable)
 
     def create(self, intf=None):
         """ Create the device. """
-- 
1.7.3.3

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux