Upload images to swift as application/octet-stream

To be fair, this should have been pretty obvious when we wrote it. Of
course glance images are application/octet-stream.

Also, update the comment about the swift bug, since it's not a swift bug
- it's doing exactly what we told it to do.

Change-Id: Id992ef12e017d84a01249555518c86fb20280053
This commit is contained in:
Monty Taylor 2017-01-23 19:12:39 +01:00
parent 14c371e944
commit 48e7eb06cd
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
2 changed files with 4 additions and 8 deletions

View File

@ -95,12 +95,6 @@ class ShadeAdapter(adapter.Adapter):
'text/plain',
'application/octet-stream'):
return response
elif response.headers.get('X-Static-Large-Object'):
# Workaround what seems to be a bug in swift where SLO objects
# return Content-Type application/json but contain
# application/octet-stream
# Bug filed: https://bugs.launchpad.net/swift/+bug/1658295
return response
else:
if not response.content:
# This doens't have any content

View File

@ -14,6 +14,7 @@ import collections
import functools
import hashlib
import ipaddress
import json
import jsonpatch
import operator
import os
@ -3516,7 +3517,8 @@ class OpenStackCloud(_normalize.Normalizer):
self.create_object(
container, name, filename,
md5=md5, sha256=sha256)
md5=md5, sha256=sha256,
**{'content-type': 'application/octet-stream'})
if not current_image:
current_image = self.get_image(name)
# TODO(mordred): Can we do something similar to what nodepool does
@ -5972,7 +5974,7 @@ class OpenStackCloud(_normalize.Normalizer):
return self._object_store_client.put(
endpoint,
params={'multipart-manifest': 'put'},
headers=headers, json=manifest)
headers=headers, data=json.dumps(manifest))
def _finish_large_object_dlo(self, endpoint, headers):
headers = headers.copy()