From e8006761d7c1f0392c2675e3eb6e8d1c49c3ecb9 Mon Sep 17 00:00:00 2001 From: ghanshyam Date: Fri, 27 Mar 2015 17:20:58 +0900 Subject: [PATCH] Fix v2.1 list-host to remove 'services' filter In v2.1, list-host supports 'services' filter also But this is not case with v2 API. v2 list-host does not support 'services' filter. v2.1 APIs should be same as v2 in all cases/scenarios. This is bug fix so not putting as microversions, its just a change to the v2.1 code so it is equivalent to v2. If later needed then, this can be reverted back as current ways via microversion. This was no best test coverage to catch this kind of issue. This was caught while merging the v2 and v2.1 tests - Ibd53a7ddd4792942fe2dc45121dcc25fc9864903 Change-Id: I11210babde0c5a668c794cd6aae7eb8c5093a99c Closes-Bug: #1437184 --- .../hosts-list-compute-service-resp.json | 9 ------- .../api/openstack/compute/plugins/v3/hosts.py | 3 --- .../hosts-list-compute-service-resp.json.tpl | 9 ------- nova/tests/functional/v3/test_hosts.py | 6 ----- .../openstack/compute/contrib/test_hosts.py | 25 ------------------- 5 files changed, 52 deletions(-) delete mode 100644 doc/v3/api_samples/os-hosts/hosts-list-compute-service-resp.json delete mode 100644 nova/tests/functional/v3/api_samples/os-hosts/hosts-list-compute-service-resp.json.tpl diff --git a/doc/v3/api_samples/os-hosts/hosts-list-compute-service-resp.json b/doc/v3/api_samples/os-hosts/hosts-list-compute-service-resp.json deleted file mode 100644 index 7d10989bbb8c..000000000000 --- a/doc/v3/api_samples/os-hosts/hosts-list-compute-service-resp.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "hosts": [ - { - "host_name": "09c025b0efc64211bd23fc50fa974cdf", - "service": "compute", - "zone": "nova" - } - ] -} diff --git a/nova/api/openstack/compute/plugins/v3/hosts.py b/nova/api/openstack/compute/plugins/v3/hosts.py index 4bae00c5a131..243f77dbff96 100644 --- a/nova/api/openstack/compute/plugins/v3/hosts.py +++ b/nova/api/openstack/compute/plugins/v3/hosts.py @@ -84,9 +84,6 @@ class HostController(wsgi.Controller): zone = req.GET.get('zone', None) if zone: filters['availability_zone'] = zone - service = req.GET.get('service') - if service: - filters['topic'] = service services = self.api.service_get_all(context, filters=filters, set_zones=True) hosts = [] diff --git a/nova/tests/functional/v3/api_samples/os-hosts/hosts-list-compute-service-resp.json.tpl b/nova/tests/functional/v3/api_samples/os-hosts/hosts-list-compute-service-resp.json.tpl deleted file mode 100644 index 846988bd8081..000000000000 --- a/nova/tests/functional/v3/api_samples/os-hosts/hosts-list-compute-service-resp.json.tpl +++ /dev/null @@ -1,9 +0,0 @@ -{ - "hosts": [ - { - "host_name": "%(host_name)s", - "service": "compute", - "zone": "nova" - } - ] -} diff --git a/nova/tests/functional/v3/test_hosts.py b/nova/tests/functional/v3/test_hosts.py index ba21d0c4b6c2..ac97aee4cb31 100644 --- a/nova/tests/functional/v3/test_hosts.py +++ b/nova/tests/functional/v3/test_hosts.py @@ -50,9 +50,3 @@ class HostsSampleJsonTest(api_sample_base.ApiSampleTestBaseV3): response = self._do_get('os-hosts') subs = self._get_regexes() self._verify_response('hosts-list-resp', subs, response, 200) - - def test_hosts_list_compute_service(self): - response = self._do_get('os-hosts?service=compute') - subs = self._get_regexes() - self._verify_response('hosts-list-compute-service-resp', - subs, response, 200) diff --git a/nova/tests/unit/api/openstack/compute/contrib/test_hosts.py b/nova/tests/unit/api/openstack/compute/contrib/test_hosts.py index 4c229011c3bc..5737e1009520 100644 --- a/nova/tests/unit/api/openstack/compute/contrib/test_hosts.py +++ b/nova/tests/unit/api/openstack/compute/contrib/test_hosts.py @@ -131,16 +131,6 @@ class FakeRequestWithNovaZone(object): GET = {"zone": "nova"} -class FakeRequestWithNovaService(object): - environ = {"nova.context": context_maker.get_admin_context()} - GET = {"service": "compute"} - - -class FakeRequestWithInvalidNovaService(object): - environ = {"nova.context": context_maker.get_admin_context()} - GET = {"service": "invalid"} - - class HostTestCaseV21(test.TestCase): """Test Case for hosts.""" validation_ex = exception.ValidationError @@ -392,27 +382,12 @@ class HostTestCaseV21(test.TestCase): hosts = result['hosts'] self.assertEqual(fake_hosts.HOST_LIST_NOVA_ZONE, hosts) - def test_list_hosts_with_service(self): - result = self.controller.index(FakeRequestWithNovaService()) - self.assertEqual(fake_hosts.HOST_LIST_NOVA_ZONE, result['hosts']) - - def test_list_hosts_with_invalid_service(self): - result = self.controller.index(FakeRequestWithInvalidNovaService()) - self.assertEqual([], result['hosts']) - class HostTestCaseV20(HostTestCaseV21): validation_ex = webob.exc.HTTPBadRequest policy_ex = webob.exc.HTTPForbidden Controller = os_hosts_v2.HostController - # Note: V2 api don't support list with services - def test_list_hosts_with_service(self): - pass - - def test_list_hosts_with_invalid_service(self): - pass - def test_list_hosts_with_non_admin(self): self.assertRaises(exception.AdminRequired, self.controller.index, fakes.HTTPRequest.blank(''))