From fa3752efdb787c0e3e71f6690b701235e79ae697 Mon Sep 17 00:00:00 2001 From: wangxiyuan Date: Wed, 24 May 2017 11:31:11 +0800 Subject: [PATCH] Remove service filter for service list The "service" filter for service list was deprecated in 2013.7(Havana). Remove related code now is safe enough. Change-Id: I02e6345df69a26e0ce1fe1c1537a819206d77960 --- cinder/api/contrib/services.py | 6 - .../tests/unit/api/contrib/test_services.py | 138 ------------------ ...emove_service_filter-380e7990bfdbddc8.yaml | 4 + 3 files changed, 4 insertions(+), 144 deletions(-) create mode 100644 releasenotes/notes/remove_service_filter-380e7990bfdbddc8.yaml diff --git a/cinder/api/contrib/services.py b/cinder/api/contrib/services.py index 5ce7ac2f961..4a78665377c 100644 --- a/cinder/api/contrib/services.py +++ b/cinder/api/contrib/services.py @@ -16,7 +16,6 @@ from oslo_config import cfg from oslo_log import log as logging -from oslo_log import versionutils from oslo_utils import timeutils from six.moves import http_client import webob.exc @@ -71,11 +70,6 @@ class ServiceController(wsgi.Controller): filters['host'] = req.GET['host'] if 'binary' in req.GET: filters['binary'] = req.GET['binary'] - elif 'service' in req.GET: - filters['binary'] = req.GET['service'] - versionutils.report_deprecated_feature(LOG, _( - "Query by service parameter is deprecated. " - "Please use binary parameter instead.")) services = objects.ServiceList.get_all(context, filters) diff --git a/cinder/tests/unit/api/contrib/test_services.py b/cinder/tests/unit/api/contrib/test_services.py index f977a370292..ea193fc7606 100644 --- a/cinder/tests/unit/api/contrib/test_services.py +++ b/cinder/tests/unit/api/contrib/test_services.py @@ -120,14 +120,6 @@ class FakeRequest(object): self.api_version_request = api_version.APIVersionRequest(version) -# NOTE(uni): deprecating service request key, binary takes precedence -# Still keeping service key here for API compatibility sake. -class FakeRequestWithService(FakeRequest): - def __init__(self, **kwargs): - kwargs.setdefault('service', 'cinder-volume') - super(FakeRequestWithService, self).__init__(**kwargs) - - class FakeRequestWithBinary(FakeRequest): def __init__(self, **kwargs): kwargs.setdefault('binary', 'cinder-volume') @@ -140,14 +132,6 @@ class FakeRequestWithHost(FakeRequest): super(FakeRequestWithHost, self).__init__(**kwargs) -# NOTE(uni): deprecating service request key, binary takes precedence -# Still keeping service key here for API compatibility sake. -class FakeRequestWithHostService(FakeRequestWithService): - def __init__(self, **kwargs): - kwargs.setdefault('host', 'host1') - super(FakeRequestWithHostService, self).__init__(**kwargs) - - class FakeRequestWithHostBinary(FakeRequestWithBinary): def __init__(self, **kwargs): kwargs.setdefault('host', 'host1') @@ -456,94 +440,6 @@ class ServicesTest(test.TestCase): 'disabled_reason': 'test2'}]} self.assertEqual(response, res_dict) - def test_services_list_with_service(self): - req = FakeRequestWithService() - res_dict = self.controller.index(req) - - response = {'services': [ - {'binary': 'cinder-volume', - 'host': 'host1', - 'zone': 'cinder', - 'status': 'disabled', - 'state': 'up', - 'updated_at': datetime.datetime(2012, 10, 29, - 13, 42, 5)}, - {'binary': 'cinder-volume', - 'host': 'host2', - 'zone': 'cinder', - 'status': 'disabled', - 'state': 'down', - 'updated_at': datetime.datetime(2012, 9, 18, - 8, 3, 38)}, - {'binary': 'cinder-volume', - 'host': 'host2', - 'zone': 'cinder', - 'status': 'disabled', - 'state': 'down', - 'updated_at': datetime.datetime(2012, 10, 29, - 13, 42, 5)}, - {'binary': 'cinder-volume', - 'host': 'host2', - 'zone': 'cinder', - 'status': 'enabled', - 'state': 'down', - 'updated_at': datetime.datetime(2012, 9, 18, - 8, 3, 38)}]} - self.assertEqual(response, res_dict) - - def test_services_detail_with_service(self): - self.ext_mgr.extensions['os-extended-services'] = True - self.controller = services.ServiceController(self.ext_mgr) - req = FakeRequestWithService() - res_dict = self.controller.index(req) - - response = {'services': [ - {'binary': 'cinder-volume', - 'replication_status': None, - 'active_backend_id': None, - 'frozen': False, - 'host': 'host1', - 'zone': 'cinder', - 'status': 'disabled', - 'state': 'up', - 'updated_at': datetime.datetime(2012, 10, 29, - 13, 42, 5), - 'disabled_reason': 'test2'}, - {'binary': 'cinder-volume', - 'replication_status': None, - 'active_backend_id': None, - 'frozen': False, - 'host': 'host2', - 'zone': 'cinder', - 'status': 'disabled', - 'state': 'down', - 'updated_at': datetime.datetime(2012, 9, 18, - 8, 3, 38), - 'disabled_reason': 'test4'}, - {'binary': 'cinder-volume', - 'replication_status': None, - 'active_backend_id': None, - 'frozen': False, - 'host': 'host2', - 'zone': 'cinder', - 'status': 'disabled', - 'state': 'down', - 'updated_at': datetime.datetime(2012, 10, 29, - 13, 42, 5), - 'disabled_reason': 'test5'}, - {'binary': 'cinder-volume', - 'replication_status': None, - 'active_backend_id': None, - 'frozen': False, - 'host': 'host2', - 'zone': 'cinder', - 'status': 'enabled', - 'state': 'down', - 'updated_at': datetime.datetime(2012, 9, 18, - 8, 3, 38), - 'disabled_reason': ''}]} - self.assertEqual(response, res_dict) - def test_services_list_with_binary(self): req = FakeRequestWithBinary() res_dict = self.controller.index(req) @@ -632,40 +528,6 @@ class ServicesTest(test.TestCase): 'disabled_reason': ''}]} self.assertEqual(response, res_dict) - def test_services_list_with_host_service(self): - req = FakeRequestWithHostService() - res_dict = self.controller.index(req) - - response = {'services': [ - {'binary': 'cinder-volume', - 'host': 'host1', - 'zone': 'cinder', - 'status': 'disabled', - 'state': 'up', - 'updated_at': datetime.datetime(2012, 10, 29, - 13, 42, 5)}]} - self.assertEqual(response, res_dict) - - def test_services_detail_with_host_service(self): - self.ext_mgr.extensions['os-extended-services'] = True - self.controller = services.ServiceController(self.ext_mgr) - req = FakeRequestWithHostService() - res_dict = self.controller.index(req) - - response = {'services': [ - {'binary': 'cinder-volume', - 'replication_status': None, - 'active_backend_id': None, - 'host': 'host1', - 'zone': 'cinder', - 'status': 'disabled', - 'state': 'up', - 'updated_at': datetime.datetime(2012, 10, 29, - 13, 42, 5), - 'disabled_reason': 'test2', - 'frozen': False}]} - self.assertEqual(response, res_dict) - def test_services_list_with_host_binary(self): req = FakeRequestWithHostBinary() res_dict = self.controller.index(req) diff --git a/releasenotes/notes/remove_service_filter-380e7990bfdbddc8.yaml b/releasenotes/notes/remove_service_filter-380e7990bfdbddc8.yaml new file mode 100644 index 00000000000..dec11dcdb86 --- /dev/null +++ b/releasenotes/notes/remove_service_filter-380e7990bfdbddc8.yaml @@ -0,0 +1,4 @@ +--- +upgrade: + - The ``service`` filter for service list API was deprecated 3 years ago in + 2013 July (Havana). Removed this filter and please use "binary" instead.