replicator: dump: Display more info

Display a bit more info when doing `glance-replicator dump`.

  - image name
  - image size
  - output filename

Change-Id: Ifce1ee402b41991dd37e7a4a2f2f513350506710
This commit is contained in:
Marc Abramowitz 2016-07-07 10:14:32 -07:00
parent 5f6dc003ae
commit de98965b34

View File

@ -374,11 +374,21 @@ def replication_dump(options, args):
client = imageservice(http_client.HTTPConnection(server, port),
options.mastertoken)
for image in client.get_images():
LOG.debug('Considering: %s', image['id'])
LOG.debug('Considering: %(image_id)s (%(image_name)s) '
'(%(image_size)d bytes)',
{'image_id': image['id'],
'image_name': image.get('name', '--unnamed--'),
'image_size': image['size']})
data_path = os.path.join(path, image['id'])
data_filename = data_path + '.img'
if not os.path.exists(data_path):
LOG.info(_LI('Storing: %s'), image['id'])
LOG.info(_LI('Storing: %(image_id)s (%(image_name)s)'
' (%(image_size)d bytes) in %(data_filename)s'),
{'image_id': image['id'],
'image_name': image.get('name', '--unnamed--'),
'image_size': image['size'],
'data_filename': data_filename})
# Dump glance information
if six.PY3:
@ -395,7 +405,7 @@ def replication_dump(options, args):
# only dump active images.
LOG.debug('Image %s is active', image['id'])
image_response = client.get_image(image['id'])
with open(data_path + '.img', 'wb') as f:
with open(data_filename, 'wb') as f:
while True:
chunk = image_response.read(options.chunksize)
if not chunk:
@ -631,7 +641,7 @@ def replication_compare(options, args):
LOG.warn(_LW('Image %(image_id)s ("%(image_name)s") '
'entirely missing from the destination')
% {'image_id': image['id'],
'image_name': image['name']})
'image_name': image.get('name', '--unnamed')})
differences[image['id']] = 'missing'
return differences