[virt-tools-list] [virt-manager] [PATCH v3 2/4] create: Show progress of container bootstrap

Radostin Stoyanov rstoyanov1 at gmail.com
Tue Jul 11 00:07:21 UTC 2017


Display the current status and progress from virt-bootstrap.
---
 virtManager/create.py | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/virtManager/create.py b/virtManager/create.py
index 75fd553..b0ebbf1 100644
--- a/virtManager/create.py
+++ b/virtManager/create.py
@@ -2505,8 +2505,8 @@ class vmmCreate(vmmGObjectUI):
             passwd = self._get_config_oscontainer_source_password()
             insecure = self._get_config_oscontainer_isecure()
 
-            self._create_directory_tree(asyncjob, src_url, dest, user, passwd,
-                                        insecure)
+            self._create_directory_tree(asyncjob, meter, src_url, dest, user,
+                                        passwd, insecure)
 
         # Build a list of pools we should refresh, if we are creating storage
         refresh_pools = []
@@ -2594,22 +2594,32 @@ class vmmCreate(vmmGObjectUI):
         return True
 
 
-    def _create_directory_tree(self, asyncjob, src, dest, user, passwd, insecure):
+    def _create_directory_tree(self, asyncjob, meter, src, dest, user,
+                               passwd, insecure):
         """
         Call bootstrap method from virtBootstrap.
         """
         import virtBootstrap
 
+        meter.start(text=_("Bootstraping container"), size=100)
+        def progress_update_cb(prog):
+            meter.text = _(prog['status'])
+            meter.update(prog['value'])
+
         # Use string buffer to store log messages
         log_stream = cStringIO.StringIO()
 
         # Get virt-bootstrap logger
         vbLogger = logging.getLogger('virtBootstrap')
         vbLogger.setLevel(logging.DEBUG)
-        vbLogger.addHandler(logging.StreamHandler(log_stream))
+        # Create hander to store log messages in the string buffer
+        hdlr = logging.StreamHandler(log_stream)
+        hdlr.setFormatter(logging.Formatter('%(message)s'))
+        vbLogger.addHandler(hdlr)
 
         # Key word arguments to be passed
         kwargs = {'uri': src, 'dest': dest, 'not_secure': insecure}
+        kwargs['progress_cb'] = progress_update_cb
         if user and passwd:
             kwargs['username'] = user
             kwargs['password'] = passwd
-- 
2.9.4




More information about the virt-tools-list mailing list