Use container_format and disk_format as-is in v2
Rather than force a painful migration to type and format, use container_format and disk_format as they are in the v1 API for v2 since there isn't a clear path to an interoperable alternative. Related to bp api-2 Change-Id: If8161390abf17961885e5c02e38d635b287aeca4
This commit is contained in:
parent
f6840263de
commit
54cf135061
|
@ -1,14 +1 @@
|
|||
{
|
||||
"type": {
|
||||
"type": "string",
|
||||
"description": "The type code for the image",
|
||||
"required": true,
|
||||
"enum": ["kernel", "ramdisk", "filesystem", "iso9660", "disk"]
|
||||
},
|
||||
"format": {
|
||||
"type": "string",
|
||||
"description": "The format code for the image",
|
||||
"required": true,
|
||||
"enum": ["raw", "vhd", "vmdk", "vdi", "qcow2", "qed"]
|
||||
}
|
||||
}
|
||||
{}
|
||||
|
|
|
@ -267,6 +267,11 @@ class ResponseSerializer(wsgi.JSONResponseSerializer):
|
|||
_image[key] = image[key]
|
||||
if CONF.show_image_direct_url and image['location']:
|
||||
_image['direct_url'] = image['location']
|
||||
|
||||
for key in ['container_format', 'disk_format']:
|
||||
if image.get(key):
|
||||
_image[key] = image[key]
|
||||
|
||||
_image['visibility'] = 'public' if image['is_public'] else 'private'
|
||||
_image = self.schema.filter(_image)
|
||||
_image['self'] = self._get_image_href(image)
|
||||
|
@ -348,6 +353,19 @@ _BASE_PROPERTIES = {
|
|||
'type': 'integer',
|
||||
'description': 'Size of image file in bytes',
|
||||
},
|
||||
'container_format': {
|
||||
'type': 'string',
|
||||
'description': '',
|
||||
'type': 'string',
|
||||
'enum': ['bare', 'ovf', 'ami', 'aki', 'ari'],
|
||||
},
|
||||
'disk_format': {
|
||||
'type': 'string',
|
||||
'description': '',
|
||||
'type': 'string',
|
||||
'enum': ['raw', 'vhd', 'vmdk', 'vdi', 'iso', 'qcow2',
|
||||
'aki', 'ari', 'ami'],
|
||||
},
|
||||
'created_at': {
|
||||
'type': 'string',
|
||||
'description': 'Date and time of image registration',
|
||||
|
|
|
@ -1,14 +1 @@
|
|||
{
|
||||
"type": {
|
||||
"type": "string",
|
||||
"description": "The type code for the image",
|
||||
"required": false,
|
||||
"enum": ["kernel", "ramdisk", "filesystem", "iso9660", "disk"]
|
||||
},
|
||||
"format": {
|
||||
"type": "string",
|
||||
"description": "The format code for the image",
|
||||
"required": false,
|
||||
"enum": ["raw", "vhd", "vmdk", "vdi", "qcow2", "qed"]
|
||||
}
|
||||
}
|
||||
{}
|
||||
|
|
|
@ -44,8 +44,8 @@ class TestSchemas(functional.FunctionalTest):
|
|||
'updated_at',
|
||||
'tags',
|
||||
'size',
|
||||
'type',
|
||||
'format',
|
||||
'container_format',
|
||||
'disk_format',
|
||||
'self',
|
||||
'file',
|
||||
'status',
|
||||
|
|
|
@ -65,6 +65,8 @@ class TestImagesController(test_utils.BaseTestCase):
|
|||
'name': '1',
|
||||
'is_public': True,
|
||||
'size': 256,
|
||||
'container_format': 'ami',
|
||||
'disk_format': 'ami',
|
||||
},
|
||||
{
|
||||
'id': UUID2,
|
||||
|
@ -72,6 +74,8 @@ class TestImagesController(test_utils.BaseTestCase):
|
|||
'name': '2',
|
||||
'is_public': True,
|
||||
'size': 512,
|
||||
'container_format': None,
|
||||
'disk_format': None,
|
||||
},
|
||||
{
|
||||
'id': UUID3,
|
||||
|
@ -79,6 +83,8 @@ class TestImagesController(test_utils.BaseTestCase):
|
|||
'name': '3',
|
||||
'is_public': True,
|
||||
'size': 512,
|
||||
'container_format': None,
|
||||
'disk_format': None,
|
||||
},
|
||||
{
|
||||
'id': UUID4,
|
||||
|
@ -86,6 +92,8 @@ class TestImagesController(test_utils.BaseTestCase):
|
|||
'name': '4',
|
||||
'is_public': False,
|
||||
'size': 1024,
|
||||
'container_format': None,
|
||||
'disk_format': None,
|
||||
},
|
||||
]
|
||||
[self.db.image_create(None, image) for image in self.images]
|
||||
|
@ -303,6 +311,8 @@ class TestImagesController(test_utils.BaseTestCase):
|
|||
'tags': [],
|
||||
'properties': {},
|
||||
'deleted': False,
|
||||
'container_format': None,
|
||||
'disk_format': None,
|
||||
}
|
||||
self.assertEqual(expected, output)
|
||||
|
||||
|
@ -364,6 +374,8 @@ class TestImagesController(test_utils.BaseTestCase):
|
|||
'tags': ['ping', 'pong'],
|
||||
'properties': {},
|
||||
'deleted': False,
|
||||
'container_format': 'ami',
|
||||
'disk_format': 'ami',
|
||||
}
|
||||
self.assertEqual(expected, output)
|
||||
|
||||
|
@ -698,6 +710,8 @@ class TestImagesSerializer(test_utils.BaseTestCase):
|
|||
'updated_at': DATETIME,
|
||||
'tags': ['one', 'two'],
|
||||
'size': 1024,
|
||||
'container_format': 'ami',
|
||||
'disk_format': 'ami',
|
||||
},
|
||||
{
|
||||
'id': unit_test_utils.UUID2,
|
||||
|
@ -711,6 +725,8 @@ class TestImagesSerializer(test_utils.BaseTestCase):
|
|||
'updated_at': DATETIME,
|
||||
'tags': [],
|
||||
'size': None,
|
||||
'container_format': None,
|
||||
'disk_format': None,
|
||||
},
|
||||
]
|
||||
expected = {
|
||||
|
@ -725,6 +741,8 @@ class TestImagesSerializer(test_utils.BaseTestCase):
|
|||
'updated_at': ISOTIME,
|
||||
'tags': ['one', 'two'],
|
||||
'size': 1024,
|
||||
'container_format': 'ami',
|
||||
'disk_format': 'ami',
|
||||
'self': '/v2/images/%s' % unit_test_utils.UUID1,
|
||||
'file': '/v2/images/%s/file' % unit_test_utils.UUID1,
|
||||
'schema': '/v2/schemas/image',
|
||||
|
@ -769,6 +787,8 @@ class TestImagesSerializer(test_utils.BaseTestCase):
|
|||
'updated_at': DATETIME,
|
||||
'tags': ['one', 'two'],
|
||||
'size': 1024,
|
||||
'container_format': 'ami',
|
||||
'disk_format': 'ami',
|
||||
},
|
||||
{
|
||||
'id': unit_test_utils.UUID2,
|
||||
|
@ -782,6 +802,8 @@ class TestImagesSerializer(test_utils.BaseTestCase):
|
|||
'updated_at': DATETIME,
|
||||
'tags': [],
|
||||
'size': None,
|
||||
'container_format': None,
|
||||
'disk_format': None,
|
||||
},
|
||||
]
|
||||
expected = {
|
||||
|
@ -796,6 +818,8 @@ class TestImagesSerializer(test_utils.BaseTestCase):
|
|||
'updated_at': ISOTIME,
|
||||
'tags': ['one', 'two'],
|
||||
'size': 1024,
|
||||
'container_format': 'ami',
|
||||
'disk_format': 'ami',
|
||||
'self': '/v2/images/%s' % unit_test_utils.UUID1,
|
||||
'file': '/v2/images/%s/file' % unit_test_utils.UUID1,
|
||||
'schema': '/v2/schemas/image',
|
||||
|
@ -841,6 +865,8 @@ class TestImagesSerializer(test_utils.BaseTestCase):
|
|||
'updated_at': DATETIME,
|
||||
'tags': ['one', 'two'],
|
||||
'size': 1024,
|
||||
'container_format': 'ami',
|
||||
'disk_format': 'ami',
|
||||
},
|
||||
{
|
||||
'id': unit_test_utils.UUID2,
|
||||
|
@ -854,6 +880,8 @@ class TestImagesSerializer(test_utils.BaseTestCase):
|
|||
'updated_at': DATETIME,
|
||||
'tags': [],
|
||||
'size': None,
|
||||
'container_format': None,
|
||||
'disk_format': None,
|
||||
},
|
||||
]
|
||||
expected = {
|
||||
|
@ -868,6 +896,8 @@ class TestImagesSerializer(test_utils.BaseTestCase):
|
|||
'updated_at': ISOTIME,
|
||||
'tags': ['one', 'two'],
|
||||
'size': 1024,
|
||||
'container_format': 'ami',
|
||||
'disk_format': 'ami',
|
||||
'self': '/v2/images/%s' % unit_test_utils.UUID1,
|
||||
'file': '/v2/images/%s/file' % unit_test_utils.UUID1,
|
||||
'schema': '/v2/schemas/image',
|
||||
|
|
|
@ -28,8 +28,11 @@ class TestSchemasController(test_utils.BaseTestCase):
|
|||
req = unit_test_utils.get_fake_request()
|
||||
output = self.controller.image(req)
|
||||
self.assertEqual(output['name'], 'image')
|
||||
self.assertTrue('status' in output['properties'],
|
||||
"'status' key missing from image schema")
|
||||
expected = set(['status', 'name', 'tags', 'checksum', 'created_at',
|
||||
'disk_format', 'updated_at', 'visibility', 'self',
|
||||
'file', 'container_format', 'schema', 'id', 'size',
|
||||
'direct_url'])
|
||||
self.assertEqual(set(output['properties'].keys()), expected)
|
||||
|
||||
def test_images(self):
|
||||
req = unit_test_utils.get_fake_request()
|
||||
|
|
Loading…
Reference in New Issue