Get rid of _network_model_hook for external_net

The network already has a joined relationship to the external
network table so we can leverage that instead of causing an
additional join for the filtering criteria.

Conflicts:
	neutron/db/external_net_db.py

Partial-Bug: #1649317
Change-Id: Idfee69b124f4ab8e2998da8492c5fa627f705bb9
(cherry picked from commit 495b7863a0)
This commit is contained in:
Kevin Benton 2017-01-09 05:30:56 -08:00 committed by Daniel Alvarez
parent e334c042a4
commit acebb8f3f5
1 changed files with 3 additions and 9 deletions

View File

@ -61,12 +61,6 @@ class ExternalNetwork(model_base.BASEV2):
class External_net_db_mixin(object):
"""Mixin class to add external network methods to db_base_plugin_v2."""
def _network_model_hook(self, context, original_model, query):
query = query.outerjoin(ExternalNetwork,
(original_model.id ==
ExternalNetwork.network_id))
return query
def _network_filter_hook(self, context, original_model, conditions):
if conditions is not None and not hasattr(conditions, '__iter__'):
conditions = (conditions, )
@ -88,8 +82,8 @@ class External_net_db_mixin(object):
if not vals:
return query
if vals[0]:
return query.filter((ExternalNetwork.network_id != expr.null()))
return query.filter((ExternalNetwork.network_id == expr.null()))
return query.filter(models_v2.Network.external.has())
return query.filter(~models_v2.Network.external.has())
# TODO(salvatore-orlando): Perform this operation without explicitly
# referring to db_base_plugin_v2, as plugins that do not extend from it
@ -97,7 +91,7 @@ class External_net_db_mixin(object):
db_base_plugin_v2.NeutronDbPluginV2.register_model_query_hook(
models_v2.Network,
"external_net",
'_network_model_hook',
None,
'_network_filter_hook',
'_network_result_filter_hook')