Merge "Add purge flag in image_meta_to_headers"

This commit is contained in:
Jenkins 2016-07-05 12:53:28 +00:00 committed by Gerrit Code Review
commit 0b2c35e3d7
2 changed files with 9 additions and 2 deletions

View File

@ -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

View File

@ -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)