diff --git a/glance/api/v2/images.py b/glance/api/v2/images.py index d1741eda7a..ddab33a23d 100644 --- a/glance/api/v2/images.py +++ b/glance/api/v2/images.py @@ -704,7 +704,7 @@ def get_base_properties(): '-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}$'), }, 'name': { - 'type': 'string', + 'type': ['null', 'string'], 'description': _('Descriptive name for the image'), 'maxLength': 255, }, @@ -724,32 +724,32 @@ def get_base_properties(): 'description': _('If true, image will not be deletable.'), }, 'checksum': { - 'type': 'string', + 'type': ['null', 'string'], 'description': _('md5 hash of image contents. (READ-ONLY)'), 'maxLength': 32, }, 'owner': { - 'type': 'string', + 'type': ['null', 'string'], 'description': _('Owner of the image'), 'maxLength': 255, }, 'size': { - 'type': 'integer', + 'type': ['null', 'integer'], 'description': _('Size of image file in bytes (READ-ONLY)'), }, 'virtual_size': { - 'type': 'integer', + 'type': ['null', 'integer'], 'description': _('Virtual size of image in bytes (READ-ONLY)'), }, 'container_format': { - 'type': 'string', + 'type': ['null', 'string'], 'description': _('Format of the container'), - 'enum': CONF.image_format.container_formats, + 'enum': [None] + CONF.image_format.container_formats, }, 'disk_format': { - 'type': 'string', + 'type': ['null', 'string'], 'description': _('Format of the disk'), - 'enum': CONF.image_format.disk_formats, + 'enum': [None] + CONF.image_format.disk_formats, }, 'created_at': { 'type': 'string', diff --git a/glance/tests/unit/v2/test_images_resource.py b/glance/tests/unit/v2/test_images_resource.py index be43cd1a60..57e19a464c 100644 --- a/glance/tests/unit/v2/test_images_resource.py +++ b/glance/tests/unit/v2/test_images_resource.py @@ -3321,7 +3321,7 @@ class TestImagesSerializerDirectUrl(test_utils.BaseTestCase): class TestImageSchemaFormatConfiguration(test_utils.BaseTestCase): def test_default_disk_formats(self): schema = glance.api.v2.images.get_schema() - expected = ['ami', 'ari', 'aki', 'vhd', 'vmdk', 'raw', 'qcow2', + expected = [None, 'ami', 'ari', 'aki', 'vhd', 'vmdk', 'raw', 'qcow2', 'vdi', 'iso'] actual = schema.properties['disk_format']['enum'] self.assertEqual(expected, actual) @@ -3329,20 +3329,20 @@ class TestImageSchemaFormatConfiguration(test_utils.BaseTestCase): def test_custom_disk_formats(self): self.config(disk_formats=['gabe'], group="image_format") schema = glance.api.v2.images.get_schema() - expected = ['gabe'] + expected = [None, 'gabe'] actual = schema.properties['disk_format']['enum'] self.assertEqual(expected, actual) def test_default_container_formats(self): schema = glance.api.v2.images.get_schema() - expected = ['ami', 'ari', 'aki', 'bare', 'ovf', 'ova'] + expected = [None, 'ami', 'ari', 'aki', 'bare', 'ovf', 'ova'] actual = schema.properties['container_format']['enum'] self.assertEqual(expected, actual) def test_custom_container_formats(self): self.config(container_formats=['mark'], group="image_format") schema = glance.api.v2.images.get_schema() - expected = ['mark'] + expected = [None, 'mark'] actual = schema.properties['container_format']['enum'] self.assertEqual(expected, actual)