Merge "Move _get_marker_obj() out of CommonDbMixin."
This commit is contained in:
commit
3c014b854a
@ -120,3 +120,21 @@ def filter_non_model_columns(data, model):
|
||||
data.items() if k in columns or
|
||||
isinstance(getattr(model, k, None),
|
||||
associationproxy.AssociationProxy))
|
||||
|
||||
|
||||
# NOTE: This used to be CommonDbMixin._get_marker_obj
|
||||
def get_marker_obj(plugin, context, resource, limit, marker):
|
||||
"""Retrieve a resource marker object.
|
||||
|
||||
This function is used to invoke:
|
||||
plugin._get_<resource>(context, marker)
|
||||
It is used for pagination.
|
||||
|
||||
:param plugin: The plugin processing the request.
|
||||
:param context: The request context.
|
||||
:param resource: The resource name.
|
||||
:param limit: Indicates if pagination is in effect.
|
||||
:param marker: The id of the marker object.
|
||||
"""
|
||||
if limit and marker:
|
||||
return getattr(plugin, '_get_%s' % resource)(context, marker)
|
||||
|
@ -95,10 +95,9 @@ class CommonDbMixin(object):
|
||||
def _get_collection_count(context, model, filters=None):
|
||||
return _model_query.get_collection_count(context, model, filters)
|
||||
|
||||
# TODO(HenryG): Remove this when available in neutron-lib
|
||||
def _get_marker_obj(self, context, resource, limit, marker):
|
||||
if limit and marker:
|
||||
return getattr(self, '_get_%s' % resource)(context, marker)
|
||||
return None
|
||||
return ndb_utils.get_marker_obj(self, context, resource, limit, marker)
|
||||
|
||||
@staticmethod
|
||||
def _filter_non_model_columns(data, model):
|
||||
|
@ -251,7 +251,8 @@ class DbBasePluginCommon(common_db_mixin.CommonDbMixin):
|
||||
def _get_subnets(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
marker_obj = self._get_marker_obj(context, 'subnet', limit, marker)
|
||||
marker_obj = db_utils.get_marker_obj(self, context, 'subnet',
|
||||
limit, marker)
|
||||
make_subnet_dict = functools.partial(self._make_subnet_dict,
|
||||
context=context)
|
||||
return model_query.get_collection(context, models_v2.Subnet,
|
||||
|
@ -461,7 +461,8 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
||||
def get_networks(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
marker_obj = self._get_marker_obj(context, 'network', limit, marker)
|
||||
marker_obj = ndb_utils.get_marker_obj(self, context, 'network',
|
||||
limit, marker)
|
||||
make_network_dict = functools.partial(self._make_network_dict,
|
||||
context=context)
|
||||
return model_query.get_collection(context, models_v2.Network,
|
||||
@ -1370,7 +1371,8 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
||||
def get_ports(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
marker_obj = self._get_marker_obj(context, 'port', limit, marker)
|
||||
marker_obj = ndb_utils.get_marker_obj(self, context, 'port',
|
||||
limit, marker)
|
||||
query = self._get_ports_query(context, filters=filters,
|
||||
sorts=sorts, limit=limit,
|
||||
marker_obj=marker_obj,
|
||||
|
@ -561,7 +561,8 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
||||
def get_routers(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
marker_obj = self._get_marker_obj(context, 'router', limit, marker)
|
||||
marker_obj = db_utils.get_marker_obj(self, context, 'router',
|
||||
limit, marker)
|
||||
return model_query.get_collection(context, l3_models.Router,
|
||||
self._make_router_dict,
|
||||
filters=filters, fields=fields,
|
||||
@ -1380,8 +1381,8 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
||||
def get_floatingips(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
marker_obj = self._get_marker_obj(context, 'floatingip', limit,
|
||||
marker)
|
||||
marker_obj = db_utils.get_marker_obj(self, context, 'floatingip',
|
||||
limit, marker)
|
||||
if filters is not None:
|
||||
for key, val in API_TO_DB_COLUMN_MAP.items():
|
||||
if key in filters:
|
||||
|
@ -143,8 +143,8 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
||||
else:
|
||||
tenant_id = context.tenant_id
|
||||
self._ensure_default_security_group(context, tenant_id)
|
||||
marker_obj = self._get_marker_obj(context, 'security_group', limit,
|
||||
marker)
|
||||
marker_obj = db_utils.get_marker_obj(self, context, 'security_group',
|
||||
limit, marker)
|
||||
return model_query.get_collection(context,
|
||||
sg_models.SecurityGroup,
|
||||
self._make_security_group_dict,
|
||||
@ -603,8 +603,9 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
||||
def get_security_group_rules(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
marker_obj = self._get_marker_obj(context, 'security_group_rule',
|
||||
limit, marker)
|
||||
marker_obj = db_utils.get_marker_obj(self, context,
|
||||
'security_group_rule',
|
||||
limit, marker)
|
||||
return model_query.get_collection(context,
|
||||
sg_models.SecurityGroupRule,
|
||||
self._make_security_group_rule_dict,
|
||||
|
Loading…
Reference in New Issue
Block a user