Fix method signatures unmatching in db api
There are a few method signatures in db/api.py who unmatches their children. For example `get_bay_list` ``` def get_bay_list(self, context, columns=None, filters=None, limit=None, marker=None, sort_key=None, sort_dir=None): ``` The argument `columns` is never being respected or used in children or elsewhere. After collecting a few opinions we decided to remove the unused argument `column` from the base methods in db/api.py. Besides, there is another unmatch in db/api.py ``` def get_service_by_name(self, bay_name): ``` It misses argument `context` compared to its only child in db/sqlalchemy/api.py. This patch adds the argument `context`. Closes-Bug: #1459662 Change-Id: If4f60661c9cd182d6bbe4539b3c594fb45744874
This commit is contained in:
parent
b5b1ba4d14
commit
fd34adb8e7
|
@ -41,16 +41,14 @@ class Connection(object):
|
|||
"""Constructor."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_bay_list(self, context, columns=None, filters=None, limit=None,
|
||||
def get_bay_list(self, context, filters=None, limit=None,
|
||||
marker=None, sort_key=None, sort_dir=None):
|
||||
"""Get specific columns for matching bays.
|
||||
"""Get matching bays.
|
||||
|
||||
Return a list of the specified columns for all bays that match the
|
||||
specified filters.
|
||||
|
||||
:param context: The security context
|
||||
:param columns: List of column names to return.
|
||||
Defaults to 'id' column when columns == None.
|
||||
:param filters: Filters to apply. Defaults to None.
|
||||
|
||||
:param limit: Maximum number of bays to return.
|
||||
|
@ -159,17 +157,15 @@ class Connection(object):
|
|||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_baymodel_list(self, context, columns=None, filters=None,
|
||||
def get_baymodel_list(self, context, filters=None,
|
||||
limit=None, marker=None, sort_key=None,
|
||||
sort_dir=None):
|
||||
"""Get specific columns for matching baymodels.
|
||||
"""Get matching baymodels.
|
||||
|
||||
Return a list of the specified columns for all baymodels that match the
|
||||
specified filters.
|
||||
|
||||
:param context: The security context
|
||||
:param columns: List of column names to return.
|
||||
Defaults to 'id' column when columns == None.
|
||||
:param filters: Filters to apply. Defaults to None.
|
||||
|
||||
:param limit: Maximum number of baymodels to return.
|
||||
|
@ -244,17 +240,15 @@ class Connection(object):
|
|||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_container_list(self, context, columns=None, filters=None,
|
||||
def get_container_list(self, context, filters=None,
|
||||
limit=None, marker=None, sort_key=None,
|
||||
sort_dir=None):
|
||||
"""Get specific columns for matching containers.
|
||||
"""Get matching containers.
|
||||
|
||||
Return a list of the specified columns for all containers that match
|
||||
the specified filters.
|
||||
|
||||
:param context: The security context
|
||||
:param columns: List of column names to return.
|
||||
Defaults to 'id' column when columns == None.
|
||||
:param filters: Filters to apply. Defaults to None.
|
||||
|
||||
:param limit: Maximum number of containers to return.
|
||||
|
@ -330,16 +324,14 @@ class Connection(object):
|
|||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_node_list(self, context, columns=None, filters=None, limit=None,
|
||||
def get_node_list(self, context, filters=None, limit=None,
|
||||
marker=None, sort_key=None, sort_dir=None):
|
||||
"""Get specific columns for matching nodes.
|
||||
"""Get for matching nodes.
|
||||
|
||||
Return a list of the specified columns for all nodes that match the
|
||||
specified filters.
|
||||
|
||||
:param context: The security context
|
||||
:param columns: List of column names to return.
|
||||
Defaults to 'id' column when columns == None.
|
||||
:param filters: Filters to apply. Defaults to None.
|
||||
|
||||
:param limit: Maximum number of nodes to return.
|
||||
|
@ -404,16 +396,14 @@ class Connection(object):
|
|||
:raises: NodeNotFound
|
||||
"""
|
||||
@abc.abstractmethod
|
||||
def get_pod_list(self, context, columns=None, filters=None, limit=None,
|
||||
def get_pod_list(self, context, filters=None, limit=None,
|
||||
marker=None, sort_key=None, sort_dir=None):
|
||||
"""Get specific columns for matching pods.
|
||||
"""Get matching pods.
|
||||
|
||||
Return a list of the specified columns for all pods that match the
|
||||
specified filters.
|
||||
|
||||
:param context: The security context
|
||||
:param columns: List of column names to return.
|
||||
Defaults to 'id' column when columns == None.
|
||||
:param filters: Filters to apply. Defaults to None.
|
||||
|
||||
:param limit: Maximum number of pods to return.
|
||||
|
@ -494,16 +484,14 @@ class Connection(object):
|
|||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_service_list(self, context, columns=None, filters=None, limit=None,
|
||||
def get_service_list(self, context, filters=None, limit=None,
|
||||
marker=None, sort_key=None, sort_dir=None):
|
||||
"""Get specific columns for matching services.
|
||||
"""Get matching services.
|
||||
|
||||
Return a list of the specified columns for all services that match the
|
||||
specified filters.
|
||||
|
||||
:param context: The security context
|
||||
:param columns: List of column names to return.
|
||||
Defaults to 'id' column when columns == None.
|
||||
:param filters: Filters to apply. Defaults to None.
|
||||
|
||||
:param limit: Maximum number of services to return.
|
||||
|
@ -561,7 +549,7 @@ class Connection(object):
|
|||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_service_by_name(self, bay_name):
|
||||
def get_service_by_name(self, context, service_name):
|
||||
"""Return a service.
|
||||
|
||||
:param context: The security context
|
||||
|
@ -586,16 +574,14 @@ class Connection(object):
|
|||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_rc_list(self, context, columns=None, filters=None, limit=None,
|
||||
def get_rc_list(self, context, filters=None, limit=None,
|
||||
marker=None, sort_key=None, sort_dir=None):
|
||||
"""Get specific columns for matching ReplicationController.
|
||||
"""Get matching ReplicationControllers.
|
||||
|
||||
Return a list of the specified columns for all rcs that match the
|
||||
specified filters.
|
||||
|
||||
:param context: The security context
|
||||
:param columns: List of column names to return.
|
||||
Defaults to 'id' column when columns == None.
|
||||
:param filters: Filters to apply. Defaults to None.
|
||||
|
||||
:param limit: Maximum number of pods to return.
|
||||
|
|
|
@ -115,7 +115,7 @@ class DbBayTestCase(base.DbTestCase):
|
|||
def test_get_bay_list_baymodel_not_exist(self):
|
||||
utils.create_test_bay()
|
||||
self.assertEqual(1, len(self.dbapi.get_bay_list(self.context)))
|
||||
res = self.dbapi.get_bay_list(self.context, {
|
||||
res = self.dbapi.get_bay_list(self.context, filters={
|
||||
'baymodel_id': magnum_utils.generate_uuid()})
|
||||
self.assertEqual(0, len(res))
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ class DbPodTestCase(base.DbTestCase):
|
|||
res = self.dbapi.get_pod_list(self.context,
|
||||
{'bay_uuid': self.bay.uuid})
|
||||
self.assertEqual(1, len(res))
|
||||
res = self.dbapi.get_pod_list(self.context, {
|
||||
res = self.dbapi.get_pod_list(self.context, filters={
|
||||
'bay_uuid': magnum_utils.generate_uuid()})
|
||||
self.assertEqual(0, len(res))
|
||||
|
||||
|
|
|
@ -84,10 +84,10 @@ class DbRCTestCase(base.DbTestCase):
|
|||
self.assertEqual(sorted(uuids), sorted(rc_uuids))
|
||||
|
||||
def test_get_rc_list_bay_not_exist(self):
|
||||
rc = self.dbapi.get_rc_list(self.context,
|
||||
{'bay_uuid': self.bay.uuid})
|
||||
rc = self.dbapi.get_rc_list(self.context, filters={
|
||||
'bay_uuid': self.bay.uuid})
|
||||
self.assertEqual(1, len(rc))
|
||||
rc = self.dbapi.get_rc_list(self.context, {
|
||||
rc = self.dbapi.get_rc_list(self.context, filters={
|
||||
'bay_uuid': magnum_utils.generate_uuid()})
|
||||
self.assertEqual(0, len(rc))
|
||||
|
||||
|
|
|
@ -125,10 +125,10 @@ class DbServiceTestCase(base.DbTestCase):
|
|||
self.assertEqual([service2.id], [r.id for r in res])
|
||||
|
||||
def test_get_service_list_bay_not_exist(self):
|
||||
res = self.dbapi.get_service_list(self.context,
|
||||
{'bay_uuid': self.bay.uuid})
|
||||
res = self.dbapi.get_service_list(self.context, filters={
|
||||
'bay_uuid': self.bay.uuid})
|
||||
self.assertEqual(1, len(res))
|
||||
res = self.dbapi.get_service_list(self.context, {
|
||||
res = self.dbapi.get_service_list(self.context, filters={
|
||||
'bay_uuid': magnum_utils.generate_uuid()})
|
||||
self.assertEqual(0, len(res))
|
||||
|
||||
|
|
Loading…
Reference in New Issue