mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-22 13:34:07 +03:00
create: Show progress of container bootstrap
Display the current status and progress from virt-bootstrap.
This commit is contained in:
parent
ebf9d294ef
commit
10799edd76
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user