Support to upload an image which is from a https server

Looks there is not a better way, As a simple solution, do not
verify the CA file.

Change-Id: I6ba87ce7cffdf4d150fc69470414555648248ebe
This commit is contained in:
chenhb 2019-08-22 19:08:10 +08:00
parent 33da0db504
commit 32bbc091bb
2 changed files with 4 additions and 2 deletions

View File

@ -46,7 +46,8 @@ class GlanceV2Service(service.Service, glance_common.GlanceMixin):
if os.path.isfile(image_location): if os.path.isfile(image_location):
image_data = open(image_location, "rb") image_data = open(image_location, "rb")
else: else:
response = requests.get(image_location, stream=True) response = requests.get(image_location, stream=True,
verify=False)
image_data = response.raw image_data = response.raw
self._clients.glance("2").images.upload(image_id, image_data) self._clients.glance("2").images.upload(image_id, image_data)
finally: finally:

View File

@ -54,7 +54,8 @@ class GlanceV2ServiceTestCase(test.TestCase):
self.service.upload_data(image_id, image_location=location) self.service.upload_data(image_id, image_location=location)
mock_requests_get.assert_called_once_with(location, stream=True) mock_requests_get.assert_called_once_with(location, stream=True,
verify=False)
self.gc.images.upload.assert_called_once_with( self.gc.images.upload.assert_called_once_with(
image_id, mock_requests_get.return_value.raw) image_id, mock_requests_get.return_value.raw)