From 921361b3ae538b8f4a9a4725623ccc5bb7a0d48d Mon Sep 17 00:00:00 2001 From: Steve Martinelli Date: Fri, 10 Jul 2015 18:01:55 +0000 Subject: [PATCH] Make trustee/trustor/project searchable by ID In the previous implementation, we were always including the domain argument, which caused a lookup by name for trustee/trustor and project. By excluding it when not necessary, we do a search by ID in find_resources. Change-Id: Id756aeab522b5dccb2dc6b31d137a28514b0fdf6 Closes-Bug: 1473298 --- openstackclient/identity/v3/trust.py | 31 +++++++--------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/openstackclient/identity/v3/trust.py b/openstackclient/identity/v3/trust.py index c8e5c4c729..2f0f804a6a 100644 --- a/openstackclient/identity/v3/trust.py +++ b/openstackclient/identity/v3/trust.py @@ -88,35 +88,20 @@ class CreateTrust(show.ShowOne): self.log.debug('take_action(%s)' % parsed_args) identity_client = self.app.client_manager.identity - project_domain = None - if parsed_args.project_domain: - project_domain = common.find_domain(identity_client, - parsed_args.project_domain).id - - trustor_domain = None - if parsed_args.trustor_domain: - trustor_domain = common.find_domain(identity_client, - parsed_args.trustor_domain).id - - trustee_domain = None - if parsed_args.trustee_domain: - trustee_domain = common.find_domain(identity_client, - parsed_args.trustee_domain).id - # NOTE(stevemar): Find the two users, project and roles that # are necessary for making a trust usable, the API dictates that # trustee, project and role are optional, but that makes the trust # pointless, and trusts are immutable, so let's enforce it at the # client level. - trustor_id = utils.find_resource(identity_client.users, - parsed_args.trustor, - domain_id=trustor_domain).id - trustee_id = utils.find_resource(identity_client.users, - parsed_args.trustee, - domain_id=trustee_domain).id - project_id = utils.find_resource(identity_client.projects, + trustor_id = common.find_user(identity_client, + parsed_args.trustor, + parsed_args.trustor_domain).id + trustee_id = common.find_user(identity_client, + parsed_args.trustee, + parsed_args.trustee_domain).id + project_id = common.find_project(identity_client, parsed_args.project, - domain_id=project_domain).id + parsed_args.project_domain).id role_names = [] for role in parsed_args.role: