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. Partial-Bug: #1649317 Change-Id: Idfee69b124f4ab8e2998da8492c5fa627f705bb9
This commit is contained in:
parent
62fb004af6
commit
495b7863a0
|
@ -45,12 +45,6 @@ _deprecate._moved_global('ExternalNetwork', new_module=ext_net_models)
|
|||
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(ext_net_models.ExternalNetwork,
|
||||
(original_model.id ==
|
||||
ext_net_models.ExternalNetwork.network_id))
|
||||
return query
|
||||
|
||||
@staticmethod
|
||||
def _network_filter_hook(context, original_model, conditions):
|
||||
if conditions is not None and not hasattr(conditions, '__iter__'):
|
||||
|
@ -73,10 +67,8 @@ class External_net_db_mixin(object):
|
|||
if not vals:
|
||||
return query
|
||||
if vals[0]:
|
||||
return query.filter(
|
||||
ext_net_models.ExternalNetwork.network_id != expr.null())
|
||||
return query.filter(
|
||||
ext_net_models.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
|
||||
|
@ -84,7 +76,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')
|
||||
|
||||
|
|
Loading…
Reference in New Issue