Set metadata headers on object create
It's a common swift deployment pattern for an update to be a server-side object copy, which is quite expensive. Rather than doing a second update step, just set the headers when we upload the image. Change-Id: Ic4f5ddddfc403f21eba5972b24a3968ae3ce0a58
This commit is contained in:
parent
de4d00be19
commit
353875b55e
@ -1970,6 +1970,11 @@ class OpenStackCloud(object):
|
||||
if not filename:
|
||||
filename = name
|
||||
|
||||
if not md5 or not sha256:
|
||||
(md5, sha256) = self._get_file_hashes(filename)
|
||||
headers[OBJECT_MD5_KEY] = md5
|
||||
headers[OBJECT_SHA256_KEY] = sha256
|
||||
|
||||
# On some clouds this is not necessary. On others it is. I'm confused.
|
||||
self.create_container(container)
|
||||
|
||||
@ -1979,13 +1984,8 @@ class OpenStackCloud(object):
|
||||
"swift uploading {filename} to {container}/{name}".format(
|
||||
filename=filename, container=container, name=name))
|
||||
self.manager.submitTask(_tasks.ObjectCreate(
|
||||
container=container, obj=name, contents=fileobj))
|
||||
|
||||
(md5, sha256) = self._get_file_hashes(filename)
|
||||
headers[OBJECT_MD5_KEY] = md5
|
||||
headers[OBJECT_SHA256_KEY] = sha256
|
||||
self.manager.submitTask(_tasks.ObjectUpdate(
|
||||
container=container, obj=name, headers=headers))
|
||||
container=container, obj=name, contents=fileobj,
|
||||
headers=headers))
|
||||
|
||||
def delete_object(self, container, name):
|
||||
if not self.get_object_metadata(container, name):
|
||||
|
@ -347,11 +347,7 @@ class TestMemoryCache(base.TestCase):
|
||||
'x-object-meta-x-shade-sha256': mock.ANY},
|
||||
'obj': '99 name',
|
||||
'container': 'image_upload_v2_test_container'}
|
||||
swift_mock.post_object.assert_called_with(**args)
|
||||
swift_mock.put_object.assert_called_with(
|
||||
contents=mock.ANY,
|
||||
obj='99 name',
|
||||
container='image_upload_v2_test_container')
|
||||
swift_mock.put_object.assert_called_with(contents=mock.ANY, **args)
|
||||
glance_mock.tasks.create.assert_called_with(type='import', input={
|
||||
'import_from': 'image_upload_v2_test_container/99 name',
|
||||
'image_properties': {'name': '99 name'}})
|
||||
|
Loading…
x
Reference in New Issue
Block a user