Add `extra_specs` to flavor create JSON schema

We should make it possible to create flavor with extra specs.

Partially Implements: bp new-flavor

Change-Id: I424e3aa6e04a0ca0e7da2784e8ff8fe9dd5ca724
This commit is contained in:
Zhenguo Niu 2017-06-19 13:23:21 +08:00
parent b4ae79c2be
commit 446df0263b
3 changed files with 5 additions and 2 deletions

View File

@ -22,6 +22,7 @@ create_flavor = {
"properties": {
'name': parameter_types.name,
'description': parameter_types.description,
'extra_specs': parameter_types.metadata,
'is_public': parameter_types.boolean,
'disabled': parameter_types.boolean,
},

View File

@ -38,15 +38,16 @@ class TestFlavor(v1_test.APITestV1):
self.post_json('/flavors', body, headers=self.headers, status=201)
def test_flavor_post(self):
body = {"name": "test", "description": "just test"}
body = {"name": "test", "description": "just test",
"extra_specs": {"k1": "v1"}}
resp = self.post_json(
'/flavors', body, headers=self.headers, status=201)
resp = resp.json
self.assertEqual('test', resp['name'])
self.assertEqual('just test', resp['description'])
self.assertEqual(True, resp['is_public'])
self.assertEqual({'k1': 'v1'}, resp['extra_specs'])
self.assertIn('uuid', resp)
self.assertIn('extra_specs', resp)
self.assertIn('links', resp)
def test_flavor_get_all(self):

View File

@ -199,6 +199,7 @@ def get_test_flavor(**kw):
'uuid': kw.get('uuid', uuidutils.generate_uuid()),
'name': kw.get('name', 'test'),
'description': kw.get('description', 'test'),
'extra_specs': kw.get('extra_specs', {}),
'is_public': kw.get('is_public', 1),
'disabled': kw.get('disabled', 0),
'updated_at': kw.get('updated_at'),