Fix port listing for trunks case

the project_id might already be in the params of GET request
(as with trunk create or edit forms).

Also, fix tenant vs project filtering in getting trunks

Closes-Bug: #2121586
Change-Id: Iacc24398526d344d49da9830e2667a70fec4d879
Signed-off-by: Pavlo Shchelokovskyy <shchelokovskyy@gmail.com>
This commit is contained in:
Pavlo Shchelokovskyy
2025-08-20 11:54:28 +00:00
parent 2792db67a7
commit dc868dc531
2 changed files with 5 additions and 4 deletions

View File

@@ -1874,6 +1874,8 @@ def port_list_with_trunk_types(request, **params):
trunk_filters = {}
if 'tenant_id' in params:
trunk_filters['tenant_id'] = params['tenant_id']
elif 'project_id' in params:
trunk_filters['project_id'] = params['project_id']
trunks = networkclient(request).trunks(**trunk_filters)
parent_ports = set(t['port_id'] for t in trunks)
# Create a dict map for child ports (port ID to trunk info)

View File

@@ -138,10 +138,9 @@ class Ports(generic.View):
a port.
"""
# https://opendev.org/openstack/neutron/src/branch/master/neutron/tests/unit/extensions/v2attributes.py
project_id = request.user.project_id
result = api.neutron.port_list_with_trunk_types(request,
project_id=project_id,
**request.GET.dict())
params = request.GET.dict()
params.setdefault("project_id", request.user.project_id)
result = api.neutron.port_list_with_trunk_types(request, **params)
return {'items': [n.to_dict() for n in result]}