[PATCH 02/11] Add a convenience method for scheduling resize actions.
David Lehman
dlehman at redhat.com
Thu Aug 16 21:48:41 UTC 2012
---
pyanaconda/storage/__init__.py | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/pyanaconda/storage/__init__.py b/pyanaconda/storage/__init__.py
index 70e772c..fdf97d6 100644
--- a/pyanaconda/storage/__init__.py
+++ b/pyanaconda/storage/__init__.py
@@ -1231,6 +1231,24 @@ class Storage(object):
self.devicetree.registerAction(ActionDestroyFormat(device))
self.devicetree.registerAction(ActionCreateFormat(device, format))
+ def resizeDevice(self, device, new_size):
+ classes = []
+ if device.resizable:
+ classes.append(ActionResizeDevice)
+
+ if device.format.resizable:
+ classes.append(ActionResizeFormat)
+
+ if not classes:
+ raise ValueError("device cannot be resized")
+
+ # if this is a shrink, schedule the format resize first
+ if new_size < device.size:
+ classes.reverse()
+
+ for action_class in classes:
+ self.devicetree.registerAction(action_class(device, new_size))
+
def formatByDefault(self, device):
"""Return whether the device should be reformatted by default."""
formatlist = ['/boot', '/var', '/tmp', '/usr']
--
1.7.7.6
More information about the anaconda-patches
mailing list