Merge "Always resolve domain id"

This commit is contained in:
Zuul 2024-10-03 11:59:16 +00:00 committed by Gerrit Code Review
commit 8979c00150
2 changed files with 27 additions and 3 deletions

View File

@ -204,6 +204,7 @@ def find_group(identity_client, name_or_id, domain_name_or_id=None):
identity_client.groups, name_or_id, groups.Group identity_client.groups, name_or_id, groups.Group
) )
else: else:
domain_id = find_domain(identity_client, domain_id).id
return _find_identity_resource( return _find_identity_resource(
identity_client.groups, identity_client.groups,
name_or_id, name_or_id,
@ -219,6 +220,7 @@ def find_project(identity_client, name_or_id, domain_name_or_id=None):
identity_client.projects, name_or_id, projects.Project identity_client.projects, name_or_id, projects.Project
) )
else: else:
domain_id = find_domain(identity_client, domain_id).id
return _find_identity_resource( return _find_identity_resource(
identity_client.projects, identity_client.projects,
name_or_id, name_or_id,
@ -234,6 +236,7 @@ def find_user(identity_client, name_or_id, domain_name_or_id=None):
identity_client.users, name_or_id, users.User identity_client.users, name_or_id, users.User
) )
else: else:
domain_id = find_domain(identity_client, domain_id).id
return _find_identity_resource( return _find_identity_resource(
identity_client.users, name_or_id, users.User, domain_id=domain_id identity_client.users, name_or_id, users.User, domain_id=domain_id
) )

View File

@ -146,12 +146,19 @@ class ListRoleAssignment(command.Lister):
domain_id=role_domain_id, domain_id=role_domain_id,
) )
user_domain_id = None
if parsed_args.user_domain:
project_domain_id = _find_sdk_id(
identity_client.find_domain,
name_or_id=parsed_args.user_domain,
)
user_id = None user_id = None
if parsed_args.user: if parsed_args.user:
user_id = _find_sdk_id( user_id = _find_sdk_id(
identity_client.find_user, identity_client.find_user,
name_or_id=parsed_args.user, name_or_id=parsed_args.user,
domain_id=parsed_args.user_domain, domain_id=user_domain_id,
) )
elif parsed_args.authuser: elif parsed_args.authuser:
if auth_ref: if auth_ref:
@ -171,6 +178,13 @@ class ListRoleAssignment(command.Lister):
name_or_id=parsed_args.domain, name_or_id=parsed_args.domain,
) )
project_domain_id = None
if parsed_args.project_domain:
project_domain_id = _find_sdk_id(
identity_client.find_domain,
name_or_id=parsed_args.project_domain,
)
project_id = None project_id = None
if parsed_args.project: if parsed_args.project:
project_id = _find_sdk_id( project_id = _find_sdk_id(
@ -178,7 +192,7 @@ class ListRoleAssignment(command.Lister):
name_or_id=common._get_token_resource( name_or_id=common._get_token_resource(
identity_client, 'project', parsed_args.project identity_client, 'project', parsed_args.project
), ),
domain_id=parsed_args.project_domain, domain_id=project_domain_id,
) )
elif parsed_args.authproject: elif parsed_args.authproject:
if auth_ref: if auth_ref:
@ -187,12 +201,19 @@ class ListRoleAssignment(command.Lister):
name_or_id=auth_ref.project_id, name_or_id=auth_ref.project_id,
) )
group_domain_id = None
if parsed_args.group_domain:
group_domain_id = _find_sdk_id(
identity_client.find_domain,
name_or_id=parsed_args.group_domain,
)
group_id = None group_id = None
if parsed_args.group: if parsed_args.group:
group_id = _find_sdk_id( group_id = _find_sdk_id(
identity_client.find_group, identity_client.find_group,
name_or_id=parsed_args.group, name_or_id=parsed_args.group,
domain_id=parsed_args.group_domain, domain_id=group_domain_id,
) )
include_names = True if parsed_args.names else None include_names = True if parsed_args.names else None