Signed-off-by: Vratislav Podzimek <vpodzime(a)redhat.com>
---
blivet/__init__.py | 25 ++++++++++++++++++++-----
blivet/deviceaction.py | 20 ++++++++++++--------
blivet/devicetree.py | 6 +++---
3 files changed, 35 insertions(+), 16 deletions(-)
diff --git a/blivet/__init__.py b/blivet/__init__.py
index 2d69eb1..109f7b8 100644
--- a/blivet/__init__.py
+++ b/blivet/__init__.py
@@ -149,8 +149,14 @@ def storageInitialize(storage, ksdata, protected):
if d.name not in ksdata.ignoredisk.ignoredisk]
log.debug("onlyuse is now: %s" %
(",".join(ksdata.ignoredisk.onlyuse)))
-def turnOnFilesystems(storage, mountOnly=False):
- """ Perform installer-specific activation of storage configuration.
"""
+def turnOnFilesystems(storage, mountOnly=False, callbacks=None):
+ """
+ Perform installer-specific activation of storage configuration.
+
+ :param callbacks: callbacks that should be run (see doIt for more info)
+
+ """
+
if not flags.installer_mode:
return
@@ -162,7 +168,7 @@ def turnOnFilesystems(storage, mountOnly=False):
storage.devicetree.teardownAll()
try:
- storage.doIt()
+ storage.doIt(callbacks=callbacks)
except FSResizeError as e:
if os.path.exists("/tmp/resize.out"):
details = open("/tmp/resize.out", "r").read()
@@ -302,8 +308,17 @@ class Blivet(object):
self.roots = []
self.services = set()
- def doIt(self):
- self.devicetree.processActions()
+ def doIt(self, callbacks=None):
+ """
+ Do overall storage setup except for writing configuration files.
+
+ :param callbacks: a dictionary mapping action keywords to functions,
+ that should be called (see below for more info)
+ :type callbacks: dict (str -> function)
+
+ """
+
+ self.devicetree.processActions(callbacks=callbacks)
self.doEncryptionPassphraseRetrofits()
# now set the boot partition's flag
diff --git a/blivet/deviceaction.py b/blivet/deviceaction.py
index 202a66c..d139436 100644
--- a/blivet/deviceaction.py
+++ b/blivet/deviceaction.py
@@ -160,8 +160,12 @@ class DeviceAction(object):
self.id = DeviceAction._id
DeviceAction._id += 1
- def execute(self):
- """ perform the action """
+ def execute(self, callbacks=None):
+ """
+ perform the action
+ :param callbacks: see Blivet.doIt
+
+ """
pass
def cancel(self):
@@ -268,7 +272,7 @@ class ActionCreateDevice(DeviceAction):
# FIXME: assert device.fs is None
DeviceAction.__init__(self, device)
- def execute(self):
+ def execute(self, callbacks=None):
self.device.create()
def requires(self, action):
@@ -314,7 +318,7 @@ class ActionDestroyDevice(DeviceAction):
if device.exists:
device.teardown()
- def execute(self):
+ def execute(self, callbacks=None):
self.device.destroy()
# Make sure libparted does not keep cached info for this device
@@ -399,7 +403,7 @@ class ActionResizeDevice(DeviceAction):
self.device.targetSize = newsize
- def execute(self):
+ def execute(self, callbacks=None):
self.device.resize()
def cancel(self):
@@ -447,7 +451,7 @@ class ActionCreateFormat(DeviceAction):
else:
self.origFormat = getFormat(None)
- def execute(self):
+ def execute(self, callbacks=None):
msg = _("Creating %(type)s on %(device)s") % {"type":
self.device.format.type, "device": self.device.path}
with progress_report(msg):
self.device.setup()
@@ -521,7 +525,7 @@ class ActionDestroyFormat(DeviceAction):
device.format.teardown()
self.device.format = None
- def execute(self):
+ def execute(self, callbacks=None):
""" wipe the filesystem signature from the device
"""
self.device.setup(orig=True)
self.format.destroy()
@@ -588,7 +592,7 @@ class ActionResizeFormat(DeviceAction):
self.origSize = self.device.format.targetSize
self.device.format.targetSize = newsize
- def execute(self):
+ def execute(self, callbacks=None):
msg = _("Resizing filesystem on %(device)s") % {"device":
self.device.path}
with progress_report(msg):
self.device.setup(orig=True)
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index 9159d9e..8707616 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -185,7 +185,7 @@ class DeviceTree(object):
actions.append(self._actions[idx])
self._actions = actions
- def processActions(self, dryRun=None):
+ def processActions(self, dryRun=None, callbacks=None):
""" Execute all registered actions. """
log.info("resetting parted disks...")
for device in self.devices:
@@ -234,12 +234,12 @@ class DeviceTree(object):
log.info("executing action: %s" % action)
if not dryRun:
try:
- action.execute()
+ action.execute(callbacks)
except DiskLabelCommitError:
# it's likely that a previous format destroy action
# triggered setup of an lvm or md device.
self.teardownAll()
- action.execute()
+ action.execute(callbacks)
udev_settle()
for device in self._devices:
--
1.7.11.7