Remove unused DB API and Service object API

This patch removes unused DB API 'get_services_by_bay_uuid',
Service object layer API 'list_by_bay_uuid' and the
associated unit tests. There are no consumers of this
code as this code is not invoked by anyone. Cleaning
this up will help to remove some dead code.

Also, added a related bug which will serve as a placeholder
to re-add the removed code.

Closes-Bug: #1490381
Related-Bug: #1499121

Change-Id: I09434dee206099ccd4e78eede7c157c64e6343ea
This commit is contained in:
Vilobh Meshram 2015-09-29 16:07:01 -07:00
parent f3e09133e9
commit bb9379de5c
6 changed files with 1 additions and 58 deletions

View File

@ -532,14 +532,6 @@ class Connection(object):
:returns: A service.
"""
@abc.abstractmethod
def get_services_by_bay_uuid(self, bay_uuid):
"""List all the services for a given bay.
:param bay_uuid: The uuid of a bay.
:returns: A list of services.
"""
@abc.abstractmethod
def get_service_by_name(self, context, service_name):
"""Return a service.

View File

@ -769,15 +769,6 @@ class Connection(api.Connection):
except NoResultFound:
raise exception.ServiceNotFound(service=service_uuid)
def get_services_by_bay_uuid(self, context, bay_uuid):
# First verify whether the Bay exists
self.get_bay_by_uuid(context, bay_uuid)
query = model_query(models.Service).filter_by(bay_uuid=bay_uuid)
try:
return query.all()
except NoResultFound:
raise exception.ServiceNotFound(bay=bay_uuid)
def get_service_by_name(self, context, service_name):
query = model_query(models.Service)
query = self._add_tenant_filters(context, query)

View File

@ -97,18 +97,6 @@ class Service(base.MagnumPersistentObject, base.MagnumObject,
service = Service._from_db_object(cls(context), db_service)
return service
@base.remotable_classmethod
def list_by_bay_uuid(cls, context, bay_uuid):
"""Return a list of :class:`Service` objects associated with a given bay.
:param bay_uuid: the uuid of a bay.
:param context: Security context
:returns: a list of class:`Service` object.
"""
db_services = cls.dbapi.get_services_by_bay_uuid(context,
bay_uuid)
return Service._from_db_object_list(db_services, cls, context)
@base.remotable_classmethod
def list(cls, context, limit=None, marker=None,
sort_key=None, sort_dir=None):

View File

@ -147,23 +147,6 @@ class DbServiceTestCase(base.DbTestCase):
'bay_uuid': magnum_utils.generate_uuid()})
self.assertEqual(0, len(res))
def test_get_services_by_bay_uuid(self):
res = self.dbapi.get_services_by_bay_uuid(self.context,
self.bay.uuid)
self.assertEqual(self.service.id, res[0].id)
def test_get_services_by_bay_uuid_that_does_not_exist(self):
self.assertRaises(exception.BayNotFound,
self.dbapi.get_services_by_bay_uuid,
self.context,
magnum_utils.generate_uuid())
def test_destroy_service(self):
self.dbapi.destroy_service(self.service.id)
self.assertRaises(exception.ServiceNotFound,
self.dbapi.get_service_by_id,
self.context, self.service.id)
def test_destroy_service_by_uuid(self):
self.assertIsNotNone(self.dbapi.get_service_by_uuid(self.context,
self.service.uuid))

View File

@ -433,7 +433,7 @@ object_data = {
'Node': '1.0-30943e6e3387a2fae7490b57c4239a17',
'Pod': '1.1-7a31c372f163742845c10a008f47cc15',
'ReplicationController': '1.0-782b7deb9307b2807101541b7e58b8a2',
'Service': '1.0-d4b8c0f3a234aec35d273196e18f7ed1',
'Service': '1.0-a8cf7e95fced904419164dbcb6d32b38',
'X509KeyPair': '1.0-fd008eba0fbc390e0e5da247bba4eedd',
'MagnumService': '1.0-2d397ec59b0046bd5ec35cd3e06efeca',
}

View File

@ -55,17 +55,6 @@ class TestServiceObject(base.DbTestCase):
mock_get_service.assert_called_once_with(self.context, name)
self.assertEqual(self.context, service._context)
def test_list_by_bay_uuid(self):
bay_uuid = self.fake_service['bay_uuid']
with mock.patch.object(self.dbapi, 'get_services_by_bay_uuid',
autospec=True) as mock_get_service:
mock_get_service.return_value = [self.fake_service]
services = objects.Service.list_by_bay_uuid(self.context,
bay_uuid)
self.assertThat(services, HasLength(1))
mock_get_service.assert_called_once_with(self.context,
bay_uuid)
def test_list(self):
with mock.patch.object(self.dbapi, 'get_service_list',
autospec=True) as mock_get_list: