diff --git a/neutron/db/db_base_plugin_v2.py b/neutron/db/db_base_plugin_v2.py index 84d0ed840b..0a9176b553 100644 --- a/neutron/db/db_base_plugin_v2.py +++ b/neutron/db/db_base_plugin_v2.py @@ -100,11 +100,16 @@ class CommonDbMixin(object): for _name, hooks in self._model_query_hooks.get(model, {}).iteritems(): query_hook = hooks.get('query') - filter_hook = hooks.get('filter') + if isinstance(query_hook, basestring): + query_hook = getattr(self, query_hook, None) if query_hook: - query = query_hook(self, context, model, query) + query = query_hook(context, model, query) + + filter_hook = hooks.get('filter') + if isinstance(filter_hook, basestring): + filter_hook = getattr(self, filter_hook, None) if filter_hook: - query_filter = filter_hook(self, context, model, query_filter) + query_filter = filter_hook(context, model, query_filter) # NOTE(salvatore-orlando): 'if query_filter' will try to evaluate the # condition, raising an exception @@ -142,8 +147,11 @@ class CommonDbMixin(object): for _name, hooks in self._model_query_hooks.get(model, {}).iteritems(): result_filter = hooks.get('result_filters', None) + if isinstance(result_filter, basestring): + result_filter = getattr(self, result_filter, None) + if result_filter: - query = result_filter(self, query, filters) + query = result_filter(query, filters) return query def _get_collection_query(self, context, model, filters=None, diff --git a/neutron/db/l3_db.py b/neutron/db/l3_db.py index 5e84c2ceee..d1830778d6 100644 --- a/neutron/db/l3_db.py +++ b/neutron/db/l3_db.py @@ -120,9 +120,9 @@ class L3_NAT_db_mixin(l3.RouterPluginBase): db_base_plugin_v2.NeutronDbPluginV2.register_model_query_hook( models_v2.Network, "external_net", - _network_model_hook, - _network_filter_hook, - _network_result_filter_hook) + '_network_model_hook', + '_network_filter_hook', + '_network_result_filter_hook') def _get_router(self, context, id): try: diff --git a/neutron/db/portbindings_db.py b/neutron/db/portbindings_db.py index 8340e0f098..678f743345 100644 --- a/neutron/db/portbindings_db.py +++ b/neutron/db/portbindings_db.py @@ -61,9 +61,9 @@ class PortBindingMixin(portbindings_base.PortBindingBaseMixin): db_base_plugin_v2.NeutronDbPluginV2.register_model_query_hook( models_v2.Port, "portbindings_port", - _port_model_hook, + '_port_model_hook', None, - _port_result_filter_hook) + '_port_result_filter_hook') def _process_portbindings_create_and_update(self, context, port_data, port):