Enable client V2 to download images

Added the CLI option image-download to download an image via API V2.
Added utility function to save an image.
Added common iterator to validate the checksum.

Related to bp glance-client-v2

Change-Id: I0247f5a3462142dc5e9f3dc16cbe00c8e3d42f42
This commit is contained in:
Lars Gellrich
2012-08-01 16:04:37 +00:00
parent 354c98b087
commit 137b3cf975
8 changed files with 287 additions and 7 deletions
+11
View File
@@ -49,3 +49,14 @@ def do_explain(gc, args):
formatters = {'Attribute': lambda m: m.name}
columns = ['Attribute', 'Description']
utils.print_list(schema.properties, columns, formatters)
@utils.arg('--file', metavar='<FILE>',
help='Local file to save downloaded image data to. '
'If this is not specified the image data will be '
'written to stdout.')
@utils.arg('id', metavar='<IMAGE_ID>', help='ID of image to download.')
def do_image_download(gc, args):
"""Download a specific image."""
body = gc.images.data(args.id)
utils.save_image(body, args.file)