Merge "Use explicit select condition in SQL query in "_port_filter_hook""
This commit is contained in:
commit
fcb2c7e2c8
@ -42,6 +42,7 @@ from oslo_db import exception as os_db_exc
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
from oslo_utils import uuidutils
|
||||
from sqlalchemy import and_
|
||||
from sqlalchemy import exc as sql_exc
|
||||
from sqlalchemy import func
|
||||
from sqlalchemy import not_
|
||||
@ -111,10 +112,9 @@ def _update_subnetpool_dict(orig_pool, new_pool):
|
||||
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 |= (models_v2.Port.network_id.in_(
|
||||
context.session.query(models_v2.Network.id).
|
||||
filter(context.project_id == models_v2.Network.project_id).
|
||||
subquery()))
|
||||
conditions |= and_(
|
||||
models_v2.Port.network_id == models_v2.Network.id,
|
||||
models_v2.Network.project_id == context.project_id)
|
||||
return conditions
|
||||
|
||||
|
||||
@ -1576,6 +1576,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
||||
Port.fixed_ips.any(IPAllocation.subnet_id.in_(subnet_ids)))
|
||||
if limit:
|
||||
query = query.limit(limit)
|
||||
query = query.distinct()
|
||||
return query
|
||||
|
||||
@db_api.retry_if_session_inactive()
|
||||
|
Loading…
x
Reference in New Issue
Block a user