Merge "Support streaming download of the image"
This commit is contained in:
@@ -153,6 +153,7 @@ class ImageCloudMixin(openstackcloud._OpenStackCloudMixin):
|
|||||||
output_path=None,
|
output_path=None,
|
||||||
output_file=None,
|
output_file=None,
|
||||||
chunk_size=1024 * 1024,
|
chunk_size=1024 * 1024,
|
||||||
|
stream=False,
|
||||||
):
|
):
|
||||||
"""Download an image by name or ID
|
"""Download an image by name or ID
|
||||||
|
|
||||||
@@ -164,6 +165,7 @@ class ImageCloudMixin(openstackcloud._OpenStackCloudMixin):
|
|||||||
this or output_path must be specified
|
this or output_path must be specified
|
||||||
:param int chunk_size: size in bytes to read from the wire and buffer
|
:param int chunk_size: size in bytes to read from the wire and buffer
|
||||||
at one time. Defaults to 1024 * 1024 = 1 MiB
|
at one time. Defaults to 1024 * 1024 = 1 MiB
|
||||||
|
:param: bool stream: whether to stream the output in chunk_size.
|
||||||
|
|
||||||
:returns: When output_path and output_file are not given - the bytes
|
:returns: When output_path and output_file are not given - the bytes
|
||||||
comprising the given Image when stream is False, otherwise a
|
comprising the given Image when stream is False, otherwise a
|
||||||
@@ -190,7 +192,10 @@ class ImageCloudMixin(openstackcloud._OpenStackCloudMixin):
|
|||||||
image = self.image.find_image(name_or_id, ignore_missing=False)
|
image = self.image.find_image(name_or_id, ignore_missing=False)
|
||||||
|
|
||||||
return self.image.download_image(
|
return self.image.download_image(
|
||||||
image, output=output_file or output_path, chunk_size=chunk_size
|
image,
|
||||||
|
output=output_file or output_path,
|
||||||
|
chunk_size=chunk_size,
|
||||||
|
stream=stream,
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_image_exclude(self, name_or_id, exclude):
|
def get_image_exclude(self, name_or_id, exclude):
|
||||||
|
|||||||
Reference in New Issue
Block a user