Image_id should be a required option when creating a baymodel

Closes-Bug: #1454038
Change-Id: I3c57af68f15149b54f2e6688a7b97237404c8a3c
This commit is contained in:
Haiwei Xu 2015-05-12 17:44:24 +09:00
parent 16e7e71467
commit 9fb5d374a3
2 changed files with 8 additions and 1 deletions

View File

@ -62,7 +62,8 @@ class BayModel(base.APIBase):
coe = wsme.wsproperty(wtypes.text, _get_coe, _set_coe, mandatory=True)
"""The Container Orchestration Engine for this bay model"""
image_id = wtypes.StringType(min_length=1, max_length=255)
image_id = wsme.wsattr(wtypes.StringType(min_length=1, max_length=255),
mandatory=True)
"""The image name or UUID to use as a base image for this baymodel"""
flavor_id = wtypes.StringType(min_length=1, max_length=255)

View File

@ -499,6 +499,12 @@ class TestPost(api_base.FunctionalTest):
response = self.post_json('/baymodels', cdict, expect_errors=True)
self.assertEqual(409, response.status_int)
def test_create_baymodel_without_image_id(self):
cdict = apiutils.baymodel_post_data()
del cdict['image_id']
response = self.post_json('/baymodels', cdict, expect_errors=True)
self.assertEqual(400, response.status_int)
class TestDelete(api_base.FunctionalTest):