From 9fb5d374a34feb220cf2831bb3b2ed46a3a6a984 Mon Sep 17 00:00:00 2001 From: Haiwei Xu Date: Tue, 12 May 2015 17:44:24 +0900 Subject: [PATCH] Image_id should be a required option when creating a baymodel Closes-Bug: #1454038 Change-Id: I3c57af68f15149b54f2e6688a7b97237404c8a3c --- magnum/api/controllers/v1/baymodel.py | 3 ++- magnum/tests/unit/api/controllers/v1/test_baymodel.py | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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):