Merge "Make glance web uploads streamable"
This commit is contained in:
commit
b8bd93c029
@ -163,16 +163,19 @@ class GlanceV2Wrapper(GlanceWrapper):
|
||||
timeout = time.time() - start
|
||||
|
||||
image_data = None
|
||||
response = None
|
||||
try:
|
||||
if os.path.isfile(image_location):
|
||||
image_data = open(image_location)
|
||||
else:
|
||||
response = requests.get(image_location)
|
||||
response = requests.get(image_location, stream=True)
|
||||
image_data = response.raw
|
||||
self.client.images.upload(image.id, image_data)
|
||||
finally:
|
||||
if image_data is not None:
|
||||
image_data.close()
|
||||
if response is not None:
|
||||
response.close()
|
||||
|
||||
return utils.wait_for_status(
|
||||
image, ["active"],
|
||||
|
@ -180,7 +180,7 @@ class GlanceV2WrapperTestCase(test.ScenarioTestCase, GlanceWrapperTestBase):
|
||||
mock_open.assert_called_once_with(location)
|
||||
else:
|
||||
data = mock_requests_get.return_value.raw
|
||||
mock_requests_get.assert_called_once_with(location)
|
||||
mock_requests_get.assert_called_once_with(location, stream=True)
|
||||
data.close.assert_called_once_with()
|
||||
self.client().images.upload.assert_called_once_with(created_image.id,
|
||||
data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user