[master] Give blivet callbacks for reporting partitioning progress
Vratislav Podzimek
vpodzime at redhat.com
Wed Aug 27 14:16:56 UTC 2014
Instead of forcing blivet to import our stuff for reporting installation
progress we can (have to now, acutally) give it callbacks that make sure
partitioning progress is reported to user.
Also provide functions hiding the details of the progressQ.
Related: rhbz#1073679
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
pyanaconda/install.py | 24 ++++++++++++++++--------
pyanaconda/progress.py | 15 ++++++++++++++-
2 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/pyanaconda/install.py b/pyanaconda/install.py
index 8e7d0d6..18043f1 100644
--- a/pyanaconda/install.py
+++ b/pyanaconda/install.py
@@ -20,9 +20,9 @@
# Red Hat Author(s): Chris Lumens <clumens at redhat.com>
#
-from blivet import turnOnFilesystems
+from blivet import turnOnFilesystems, callbacks
from pyanaconda.bootloader import writeBootLoader
-from pyanaconda.progress import progress_report, progressQ
+from pyanaconda.progress import progress_report, progress_message, progress_step, progress_complete, progress_init
from pyanaconda.users import createLuserConf, getPassAlgo, Users
from pyanaconda import flags
from pyanaconda import iutil
@@ -69,7 +69,7 @@ def doConfiguration(storage, payload, ksdata, instClass):
if willRunRealmd:
step_count += 1
- progressQ.send_init(step_count)
+ progress_init(step_count)
# Now run the execute methods of ksdata that require an installed system
# to be present first.
@@ -114,7 +114,7 @@ def doConfiguration(storage, payload, ksdata, instClass):
# kickstart file over if one exists).
_writeKS(ksdata)
- progressQ.send_complete()
+ progress_complete()
def moveBootMntToPhysical(storage):
"""Move the /boot mount to /mnt/sysimage/boot."""
@@ -158,13 +158,13 @@ def doInstall(storage, payload, ksdata, instClass):
# This should be the only thread running, wait for the others to finish if not.
if threadMgr.running > 1:
- progressQ.send_init(steps+1)
+ progress_init(steps+1)
with progress_report(_("Waiting for %s threads to finish") % (threadMgr.running-1)):
map(log.debug, ("Thread %s is running" % n for n in threadMgr.names))
threadMgr.wait_all()
else:
- progressQ.send_init(steps)
+ progress_init(steps)
with progress_report(_("Setting up the installation environment")):
ksdata.firstboot.setup(storage, ksdata, instClass)
@@ -175,7 +175,15 @@ def doInstall(storage, payload, ksdata, instClass):
# Do partitioning.
payload.preStorage()
- turnOnFilesystems(storage, mountOnly=flags.flags.dirInstall)
+ # callbacks for blivet
+ message_clbk = lambda clbk_data: progress_message(clbk_data.msg)
+ step_clbk = lambda clbk_data: progress_step(clbk_data.msg)
+ callbacks_reg = callbacks.create_new_callbacks_register(create_format_pre=message_clbk,
+ create_format_post=step_clbk,
+ resize_format_pre=message_clbk,
+ resize_format_post=step_clbk)
+
+ turnOnFilesystems(storage, mountOnly=flags.flags.dirInstall, callbacks=callbacks_reg)
write_storage_late = (flags.flags.livecdInstall or ksdata.ostreesetup.seen
or ksdata.method.method == "liveimg"
and not flags.flags.dirInstall)
@@ -241,4 +249,4 @@ def doInstall(storage, payload, ksdata, instClass):
moveBootMntToPhysical(storage)
payload.postInstall()
- progressQ.send_complete()
+ progress_complete()
diff --git a/pyanaconda/progress.py b/pyanaconda/progress.py
index 6c72d8a..dc7a38c 100644
--- a/pyanaconda/progress.py
+++ b/pyanaconda/progress.py
@@ -45,7 +45,20 @@ progressQ.addMessage("quit", 1) # exit_code
# Afterwards, the progress bar is updated to reflect that the task is done.
@contextmanager
def progress_report(message):
+ progress_message(message)
+ yield
+ progress_step(message)
+
+def progress_message(message):
progressQ.send_message(message)
log.info(message)
- yield
+
+def progress_step(message):
progressQ.send_step()
+ log.info(message)
+
+def progress_init(steps):
+ progressQ.send_init(steps)
+
+def progress_complete():
+ progressQ.send_complete()
--
1.9.3
More information about the anaconda-patches
mailing list