From 98fd7160e794a4deedfc5299e062c93e5ffca27d Mon Sep 17 00:00:00 2001 From: Zhenguo Niu Date: Fri, 18 Aug 2017 10:33:58 +0800 Subject: [PATCH] Remove the duplicate flavor disable check We moved the admin role check to db api side, so common users will get a NotFound error, if they try to get a disabled flavor. Also we check whether the flavor disabled on api side, if so, we will raise a FlavorDisabled error to admin users. Change-Id: I4b4595bab266a7041b860e582c64a0198e50c322 --- mogan/engine/api.py | 2 -- mogan/tests/unit/engine/test_engine_api.py | 20 -------------------- 2 files changed, 22 deletions(-) diff --git a/mogan/engine/api.py b/mogan/engine/api.py index 017182b1..78c63f31 100644 --- a/mogan/engine/api.py +++ b/mogan/engine/api.py @@ -82,8 +82,6 @@ class API(object): requested_networks, user_data, key_name, max_count): """Verify all the input parameters""" - if flavor['disabled']: - raise exception.FlavorNotFound(flavor_id=flavor['uuid']) if user_data: l = len(user_data) diff --git a/mogan/tests/unit/engine/test_engine_api.py b/mogan/tests/unit/engine/test_engine_api.py index 5de9d38f..c8f4999f 100644 --- a/mogan/tests/unit/engine/test_engine_api.py +++ b/mogan/tests/unit/engine/test_engine_api.py @@ -70,26 +70,6 @@ class ComputeAPIUnitTest(base.DbTestCase): self.assertEqual('test_az', base_opts['availability_zone']) self.assertIsNone(key_pair) - def test__validate_and_build_base_options_flavor_disabled(self): - flavor = self._create_flavor() - flavor.disabled = True - flavor.save() - - self.assertRaises( - exception.FlavorNotFound, - self.engine_api._validate_and_build_base_options, - self.context, - flavor, - 'fake-uuid', - 'fake-name', - 'fake-descritpion', - 'test_az', - {'k1', 'v1'}, - [{'uuid': 'fake'}], - None, - None, - 1) - @mock.patch('mogan.network.api.get_client') def test__check_requested_networks(self, mock_get_client): mock_get_client.return_value = mock.MagicMock()