From 375964f270e125b8887e0ca4ee1cbe15d5eddf04 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Sun, 21 Jan 2018 20:02:02 +0100 Subject: Add CRUD support for application credentials Add support for creating, retrieving, and deleting application credentials. Application credentials do not support updates. In order to provide a positive user experience for the `--role` option, this patch also includes an improvement to the `identity.common._get_token_resource()` function that allows it to introspect the roles list within a token. This way there is no need to make a request to keystone to retrieve a role object, which would fail most of the time anyway due to keystone's default policy prohibiting unprivileged users from retrieving roles. bp application-credentials Change-Id: I29e03b72acd931305cbdac5a9ff666854d05c6d7 --- openstackclient/identity/common.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'openstackclient/identity/common.py') diff --git a/openstackclient/identity/common.py b/openstackclient/identity/common.py index e119f660..f36f5f73 100644 --- a/openstackclient/identity/common.py +++ b/openstackclient/identity/common.py @@ -101,6 +101,13 @@ def _get_token_resource(client, resource, parsed_name, parsed_domain=None): # user/project under different domain may has a same name if parsed_domain and parsed_domain not in obj['domain'].values(): return parsed_name + if isinstance(obj, list): + for item in obj: + if item['name'] == parsed_name: + return item['id'] + if item['id'] == parsed_name: + return parsed_name + return parsed_name return obj['id'] if obj['name'] == parsed_name else parsed_name # diaper defense in case parsing the token fails except Exception: # noqa -- cgit v1.2.1