Merge "Use explicit inner join for networks in port query"
This commit is contained in:
commit
a26e957d34
@ -114,11 +114,18 @@ def _update_subnetpool_dict(orig_pool, new_pool):
|
||||
return updated
|
||||
|
||||
|
||||
def _port_query_hook(context, original_model, query):
|
||||
# Apply the port query only in non-admin and non-advsvc context
|
||||
if ndb_utils.model_query_scope_is_project(context, original_model):
|
||||
query = query.join(models_v2.Network,
|
||||
models_v2.Network.id == models_v2.Port.network_id)
|
||||
return query
|
||||
|
||||
|
||||
def _port_filter_hook(context, original_model, conditions):
|
||||
# Apply the port filter only in non-admin and non-advsvc context
|
||||
if ndb_utils.model_query_scope_is_project(context, original_model):
|
||||
conditions |= and_(
|
||||
models_v2.Port.network_id == models_v2.Network.id,
|
||||
models_v2.Network.project_id == context.project_id)
|
||||
return conditions
|
||||
|
||||
@ -154,7 +161,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
||||
model_query.register_hook(
|
||||
models_v2.Port,
|
||||
"port",
|
||||
query_hook=None,
|
||||
query_hook=_port_query_hook,
|
||||
filter_hook=_port_filter_hook,
|
||||
result_filters=None)
|
||||
return super(NeutronDbPluginV2, cls).__new__(cls, *args, **kwargs)
|
||||
|
Loading…
x
Reference in New Issue
Block a user