summaryrefslogtreecommitdiff
path: root/glanceclient/shell.py
diff options
context:
space:
mode:
authorFlavio Percoco <flaper87@gmail.com>2015-09-25 10:54:29 +0200
committerFlavio Percoco <flaper87@gmail.com>2015-09-25 10:59:54 +0200
commitc31c1365573d10bd09afad47ca1974af3e50b5eb (patch)
tree65083846e30244c7f6adc56e6bf457b0fb383176 /glanceclient/shell.py
parent586d40131d0637f50ba214ef0d85ed9ddafca4f6 (diff)
downloadpython-glanceclient-c31c1365573d10bd09afad47ca1974af3e50b5eb.tar.gz
No auth when token and endpoint are passed
The latest change to the auth_required logic introduced a bug were even when the token and endpoint were passed, authentication was being required. This patch fixes that issue and makes sure that authentication is not required when these 2 arguements are present. Closes-bug: #1499540 Change-Id: I4c9c15ba526378970da5461511ed922d42c5a9f9
Diffstat (limited to 'glanceclient/shell.py')
-rwxr-xr-xglanceclient/shell.py17
1 files changed, 6 insertions, 11 deletions
diff --git a/glanceclient/shell.py b/glanceclient/shell.py
index faa014c..b00e6f7 100755
--- a/glanceclient/shell.py
+++ b/glanceclient/shell.py
@@ -443,18 +443,13 @@ class OpenStackImagesShell(object):
return ks_session
def _get_endpoint_and_token(self, args):
- image_url = self._get_image_url(args)
+ endpoint = self._get_image_url(args)
auth_token = args.os_auth_token
- auth_reqd = (not (auth_token and image_url) or
- (hasattr(args, 'func') and
- utils.is_authentication_required(args.func)))
-
- if not auth_reqd:
- endpoint = image_url
- token = args.os_auth_token
- else:
+ auth_req = (hasattr(args, 'func') and
+ utils.is_authentication_required(args.func))
+ if auth_req and not (endpoint and auth_token):
if not args.os_username:
raise exc.CommandError(
_("You must provide a username via"
@@ -527,7 +522,7 @@ class OpenStackImagesShell(object):
'key': args.os_key
}
ks_session = self._get_keystone_session(**kwargs)
- token = args.os_auth_token or ks_session.get_token()
+ auth_token = args.os_auth_token or ks_session.get_token()
endpoint_type = args.os_endpoint_type or 'public'
service_type = args.os_service_type or 'image'
@@ -536,7 +531,7 @@ class OpenStackImagesShell(object):
interface=endpoint_type,
region_name=args.os_region_name)
- return endpoint, token
+ return endpoint, auth_token
def _get_versioned_client(self, api_version, args):
endpoint, token = self._get_endpoint_and_token(args)