diff --git a/magnum/api/controllers/v1/baymodel.py b/magnum/api/controllers/v1/baymodel.py index 0628a45cd5..592a6537c8 100644 --- a/magnum/api/controllers/v1/baymodel.py +++ b/magnum/api/controllers/v1/baymodel.py @@ -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) diff --git a/magnum/tests/unit/api/controllers/v1/test_baymodel.py b/magnum/tests/unit/api/controllers/v1/test_baymodel.py index 6a64a1a5d7..1649fdb148 100644 --- a/magnum/tests/unit/api/controllers/v1/test_baymodel.py +++ b/magnum/tests/unit/api/controllers/v1/test_baymodel.py @@ -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):