From 40c6c1a9d29608a04f2062e63dcc395acbb0dffd Mon Sep 17 00:00:00 2001 From: Senhua Huang Date: Thu, 23 May 2013 07:17:38 -0700 Subject: Deprecate compute_api_class option in the config Add a function "get_compute_api_class_name" within nova.compute that returns nova.compute.cells_api.ComputeCellsAPI if cell is enabled and this cell is an API cell, and returns compute.api.API otherwise. Add an option "cell_type" to the config in group "cells". Use the default value of "cell_type" (None) for legacy configuration. Change-Id: I32f5ccf789c657b563c165bfa8244e819b1a79a6 Fixes: bug #1049249 --- nova/tests/compute/test_compute.py | 24 ++++++++++++++++++++++++ nova/tests/compute/test_host_api.py | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'nova/tests') diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 491ecf544..26ddc497a 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -9276,3 +9276,27 @@ class CheckRequestedImageTestCase(test.TestCase): self.compute_api._check_requested_image(self.context, image['id'], image, self.instance_type) + + +class ComputeAPIClassNameTestCase(test.TestCase): + def setUp(self): + super(ComputeAPIClassNameTestCase, self).setUp() + + def test_default_compute_api_class_name(self): + result = compute.get_compute_api_class_name() + self.assertEqual('nova.compute.api.API', result) + + def test_cell_compute_api_class_name(self): + self.flags(enable=True, group='cells') + self.flags(cell_type='api', group='cells') + result = compute.get_compute_api_class_name() + self.assertEqual('nova.compute.cells_api.ComputeCellsAPI', result) + self.flags(cell_type='compute', group='cells') + result = compute.get_compute_api_class_name() + self.assertEqual('nova.compute.api.API', result) + + def test_illegal_cell_compute_api_class_name(self): + self.flags(enable=True, group='cells') + self.flags(cell_type='fake_cell_type', group='cells') + self.assertRaises(exception.InvalidInput, + compute.get_compute_api_class_name) diff --git a/nova/tests/compute/test_host_api.py b/nova/tests/compute/test_host_api.py index 6a87205ae..f9ef3894d 100644 --- a/nova/tests/compute/test_host_api.py +++ b/nova/tests/compute/test_host_api.py @@ -252,7 +252,8 @@ class ComputeHostAPITestCase(test.TestCase): class ComputeHostAPICellsTestCase(ComputeHostAPITestCase): def setUp(self): - self.flags(compute_api_class='nova.compute.cells_api.ComputeCellsAPI') + self.flags(enable=True, group='cells') + self.flags(cell_type='api', group='cells') super(ComputeHostAPICellsTestCase, self).setUp() def _mock_rpc_call(self, expected_message, result=None): -- cgit