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

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

 



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

diff --git a/virtManager/create.py b/virtManager/create.py
index a3d8ac4..447e9de 100644
--- a/virtManager/create.py
+++ b/virtManager/create.py
@@ -2511,7 +2511,7 @@ class vmmCreate(vmmGObjectUI):
 
         if bootstrap_args:
             # Start container bootstrap
-            self._create_directory_tree(asyncjob, bootstrap_args)
+            self._create_directory_tree(asyncjob, meter, bootstrap_args)
 
         # Build a list of pools we should refresh, if we are creating storage
         refresh_pools = []
@@ -2599,28 +2599,36 @@ class vmmCreate(vmmGObjectUI):
         return True
 
 
-    def _create_directory_tree(self, asyncjob, bootstrap_args):
+    def _create_directory_tree(self, asyncjob, meter, bootstrap_args):
         """
         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': bootstrap_args['src'],
                   'dest': bootstrap_args['dest'],
-                  'not_secure': bootstrap_args['insecure']}
+                  'not_secure': bootstrap_args['insecure'],
+                  'progress_cb': progress_update_cb}
         if bootstrap_args['user'] and bootstrap_args['passwd']:
             kwargs['username'] = bootstrap_args['user']
             kwargs['password'] = bootstrap_args['passwd']
-
         logging.debug('Start container bootstrap')
         try:
             virtBootstrap.bootstrap(**kwargs)
-- 
2.9.4

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list



[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux