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
This commit is contained in:
ghanshyam 2015-03-27 17:20:58 +09:00
parent fc5e6315af
commit e8006761d7
5 changed files with 0 additions and 52 deletions

View File

@ -1,9 +0,0 @@
{
"hosts": [
{
"host_name": "09c025b0efc64211bd23fc50fa974cdf",
"service": "compute",
"zone": "nova"
}
]
}

View File

@ -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 = []

View File

@ -1,9 +0,0 @@
{
"hosts": [
{
"host_name": "%(host_name)s",
"service": "compute",
"zone": "nova"
}
]
}

View File

@ -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)

View File

@ -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(''))