Add support for image size in v2 api upload
Some backend stores e.g. RBD, will fail if told to create an image without a valid size (RBD will fail to write to a zero-size image). Here we add support to allow the image size to be provided when doing an upload. The result is that the upload content-length will be set if available either from checking the supplied file object or as provided by user. Closes-Bug: 1220197 Change-Id: Ia1f2ea5680a139750d931591949b3e0058148b4b
This commit is contained in:
@@ -218,12 +218,17 @@ def do_image_download(gc, args):
|
||||
help=('Local file that contains disk image to be uploaded'
|
||||
' during creation. Alternatively, images can be passed'
|
||||
' to the client via stdin.'))
|
||||
@utils.arg('--size', metavar='<IMAGE_SIZE>', type=int,
|
||||
help='Size in bytes of image to be uploaded. Default is to get '
|
||||
'size from provided data object but this is supported in case '
|
||||
'where size cannot be inferred.',
|
||||
default=None)
|
||||
@utils.arg('id', metavar='<IMAGE_ID>',
|
||||
help='ID of image to upload data to.')
|
||||
def do_image_upload(gc, args):
|
||||
"""Upload data for a specific image."""
|
||||
image_data = utils.get_data_file(args)
|
||||
gc.images.upload(args.id, image_data)
|
||||
gc.images.upload(args.id, image_data, args.size)
|
||||
|
||||
|
||||
@utils.arg('id', metavar='<IMAGE_ID>', help='ID of image to delete.')
|
||||
|
||||
Reference in New Issue
Block a user