summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-10-07 14:11:28 +0000
committerGerrit Code Review <review@openstack.org>2014-10-07 14:11:28 +0000
commit2a9934ad1950f3be8ca27a66c1bf43c8c538ceb6 (patch)
treeb21c0e984fd5d65f03e8e314cb5d7c3f146d3b4c
parent8c14e4cb2ddc916c911370d72810535a035d6f6a (diff)
parent0f3b518028196b5c8c36b378928dae31c2c4a6fa (diff)
downloadglance-2a9934ad1950f3be8ca27a66c1bf43c8c538ceb6.tar.gz
Merge "Mark custom properties in image schema as non-base" into proposed/juno
-rw-r--r--glance/api/v2/images.py6
-rw-r--r--glance/tests/unit/v2/test_images_resource.py16
2 files changed, 21 insertions, 1 deletions
diff --git a/glance/api/v2/images.py b/glance/api/v2/images.py
index ffa8e2667..92e1c5c0a 100644
--- a/glance/api/v2/images.py
+++ b/glance/api/v2/images.py
@@ -815,7 +815,11 @@ def get_schema(custom_properties=None):
schema = glance.schema.PermissiveSchema('image', properties, links)
else:
schema = glance.schema.Schema('image', properties)
- schema.merge_properties(custom_properties or {})
+
+ if custom_properties:
+ for property_value in custom_properties.values():
+ property_value['is_base'] = False
+ schema.merge_properties(custom_properties)
return schema
diff --git a/glance/tests/unit/v2/test_images_resource.py b/glance/tests/unit/v2/test_images_resource.py
index 27c767f7d..cfba9b5ff 100644
--- a/glance/tests/unit/v2/test_images_resource.py
+++ b/glance/tests/unit/v2/test_images_resource.py
@@ -3255,3 +3255,19 @@ class TestImageSchemaFormatConfiguration(test_utils.BaseTestCase):
expected = ['mark']
actual = schema.properties['container_format']['enum']
self.assertEqual(expected, actual)
+
+
+class TestImageSchemaDeterminePropertyBasis(test_utils.BaseTestCase):
+ def test_custom_property_marked_as_non_base(self):
+ self.config(allow_additional_image_properties=False)
+ custom_image_properties = {
+ 'pants': {
+ 'type': 'string',
+ },
+ }
+ schema = glance.api.v2.images.get_schema(custom_image_properties)
+ self.assertFalse(schema.properties['pants'].get('is_base', True))
+
+ def test_base_property_marked_as_base(self):
+ schema = glance.api.v2.images.get_schema()
+ self.assertTrue(schema.properties['disk_format'].get('is_base', True))