Add purge flag in image_meta_to_headers
When calling image_client_v1's update_image with "purge" flag, it raise 400 Bad Request with message "Bad header: x-image-meta-purge-props". This is to add purge transform in image_meta_to_headers to support purge flag. Change-Id: I2a30c2fc746701805f9e9cc77068c7eaa17dbcb8 Closes-Bug: #1597591
This commit is contained in:
parent
61b82bf236
commit
43488a5d9a
@ -47,6 +47,11 @@ def image_meta_to_headers(**metadata):
|
||||
fields_copy = copy.deepcopy(metadata)
|
||||
|
||||
copy_from = fields_copy.pop('copy_from', None)
|
||||
purge = fields_copy.pop('purge_props', None)
|
||||
|
||||
if purge is not None:
|
||||
headers['x-glance-registry-purge-props'] = purge
|
||||
|
||||
if copy_from is not None:
|
||||
headers['x-glance-api-copy-from'] = copy_from
|
||||
|
||||
|
@ -46,7 +46,8 @@ class TestImage(base.TestCase):
|
||||
disk_format='vhd',
|
||||
copy_from='http://localhost/images/10',
|
||||
properties={'foo': 'bar'},
|
||||
api={'abc': 'def'})
|
||||
api={'abc': 'def'},
|
||||
purge_props=True)
|
||||
|
||||
expected = {
|
||||
'x-image-meta-name': 'test',
|
||||
@ -54,6 +55,7 @@ class TestImage(base.TestCase):
|
||||
'x-image-meta-disk_format': 'vhd',
|
||||
'x-glance-api-copy-from': 'http://localhost/images/10',
|
||||
'x-image-meta-property-foo': 'bar',
|
||||
'x-glance-api-property-abc': 'def'
|
||||
'x-glance-api-property-abc': 'def',
|
||||
'x-glance-registry-purge-props': True
|
||||
}
|
||||
self.assertEqual(expected, observed)
|
||||
|
Loading…
Reference in New Issue
Block a user