From 15e266ce2b9100f3fd8f98230b9ffab9adb163f4 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Tue, 4 Sep 2012 14:16:17 -0700 Subject: Makes sure new flavors default to is_public=True The default for is_public is true in the database, but new flavors created through the extension was defaulting is_public=None and passing it through to the db layer where it gets converted to False. This patch fixes the issue by defaulting is_public to True at the api layer. Incldes a broken test to verify. Fixes bug 1046040 Change-Id: I4c361c0055a14de29e364868074e17cf3ec23220 --- .../compute/contrib/test_flavor_manage.py | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/api/openstack/compute/contrib/test_flavor_manage.py b/nova/tests/api/openstack/compute/contrib/test_flavor_manage.py index 68d8ee750..7406b0fd9 100644 --- a/nova/tests/api/openstack/compute/contrib/test_flavor_manage.py +++ b/nova/tests/api/openstack/compute/contrib/test_flavor_manage.py @@ -117,6 +117,45 @@ class FlavorManageTest(test.TestCase): for key in expected["flavor"]: self.assertEquals(body["flavor"][key], expected["flavor"][key]) + def test_create_public_default(self): + flavor = { + "flavor": { + "name": "test", + "ram": 512, + "vcpus": 2, + "disk": 1, + "OS-FLV-EXT-DATA:ephemeral": 1, + "id": 1234, + "swap": 512, + "rxtx_factor": 1, + } + } + + expected = { + "flavor": { + "name": "test", + "ram": 512, + "vcpus": 2, + "disk": 1, + "OS-FLV-EXT-DATA:ephemeral": 1, + "id": 1234, + "swap": 512, + "rxtx_factor": 1, + "os-flavor-access:is_public": True, + } + } + + self.stubs.Set(instance_types, "create", fake_create) + url = '/v2/fake/flavors' + req = webob.Request.blank(url) + req.headers['Content-Type'] = 'application/json' + req.method = 'POST' + req.body = jsonutils.dumps(flavor) + res = req.get_response(fakes.wsgi_app()) + body = jsonutils.loads(res.body) + for key in expected["flavor"]: + self.assertEquals(body["flavor"][key], expected["flavor"][key]) + def test_instance_type_exists_exception_returns_409(self): expected = { "flavor": { -- cgit