Skip to content

Commit a5e4d5f

Browse files
committed
identity: Fix filtering endpoints by project with domain
We were incorrectly passing domain_id as a positional argument, causing it to get picked up as the ignore_missing argument instead. Correct this, fixing another bug where the look of projects or domains could be forbidden by policy, in the process. The latter is unlikely to happen, given endpoint lookup is typically an admin-only operation, but it's better to be safe. Change-Id: Idd3300040967d781b7743accd62298cb24c62872 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
1 parent db2c1a5 commit a5e4d5f

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

openstackclient/identity/v3/endpoint.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,22 @@ def take_action(self, parsed_args):
231231
endpoint = None
232232
if parsed_args.endpoint:
233233
endpoint = identity_client.find_endpoint(parsed_args.endpoint)
234-
project = None
234+
235+
project_domain_id = None
236+
if parsed_args.project_domain:
237+
project_domain_id = common._find_sdk_id(
238+
identity_client.find_domain,
239+
name_or_id=parsed_args.project_domain,
240+
)
241+
242+
project_id = None
235243
if parsed_args.project:
236-
project = identity_client.find_project(
237-
parsed_args.project,
238-
parsed_args.project_domain,
244+
project_id = common._find_sdk_id(
245+
identity_client.find_project,
246+
name_or_id=common._get_token_resource(
247+
identity_client, 'project', parsed_args.project
248+
),
249+
domain_id=project_domain_id,
239250
)
240251

241252
if endpoint:
@@ -273,9 +284,9 @@ def take_action(self, parsed_args):
273284
region = identity_client.get_region(parsed_args.region)
274285
kwargs['region_id'] = region.id
275286

276-
if project:
287+
if project_id:
277288
data = list(
278-
identity_client.project_endpoints(project=project.id)
289+
identity_client.project_endpoints(project=project_id)
279290
)
280291
else:
281292
data = list(identity_client.endpoints(**kwargs))

0 commit comments

Comments
 (0)