[PATCH 1/2] Add a preCommitFixup hook to StorageDevice classes

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

 



It turns out we need to do some fixup's before committing not only for
PartitionDevices, but also for other devices. So add a generic
preCommitFixup hook to StorageDevice classes, and replace
resetPartedPartition with it.

Related: rhbz#584596
---
 storage/devices.py    |    6 +++++-
 storage/devicetree.py |   13 ++++++-------
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index 1af4ecf..a990708 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -713,6 +713,10 @@ class StorageDevice(Device):
                       lambda d,f: d._setFormat(f),
                       doc="The device's formatting.")
 
+    def preCommitFixup(self, *args, **kwargs):
+        """ Do any necessary pre-commit fixups."""
+        pass
+
     def create(self, intf=None):
         """ Create the device. """
         log_method_call(self, self.name, status=self.status)
@@ -1128,7 +1132,7 @@ class PartitionDevice(StorageDevice):
     partedPartition = property(lambda d: d._getPartedPartition(),
                                lambda d,p: d._setPartedPartition(p))
 
-    def resetPartedPartition(self):
+    def preCommitFixup(self, *args, **kwargs):
         """ Re-get self.partedPartition from the original disklabel. """
         log_method_call(self, self.name)
         if not self.exists:
diff --git a/storage/devicetree.py b/storage/devicetree.py
index c96bfbd..0bc07e5 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -631,16 +631,15 @@ class DeviceTree(object):
                    device.originalFormat != device.format:
                     device.originalFormat.resetPartedDisk()
 
-        # reget parted.Partition for remaining preexisting devices
+        # Call preCommitFixup on all devices
         for device in self.devices:
-            if isinstance(device, PartitionDevice) and device.exists:
-                device.resetPartedPartition()
+            device.preCommitFixup()
 
-        # reget parted.Partition for existing devices we're removing
+        # Also call preCommitFixup on any devices we're going to
+        # destroy (these are already removed from the tree)
         for action in self._actions:
-            if isinstance(action.device, PartitionDevice) and \
-               action.device.exists:
-                action.device.resetPartedPartition()
+            if isinstance(action, ActionDestroyDevice):
+                action.device.preCommitFixup()
 
         # setup actions to create any extended partitions we added
         #
-- 
1.7.0.1

_______________________________________________
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