diff options
author | Tim Burke <tim.burke@gmail.com> | 2016-04-27 16:45:15 -0500 |
---|---|---|
committer | Tim Burke <tim.burke@gmail.com> | 2016-05-03 14:41:07 -0700 |
commit | 67f629cdeb4e4c9fcb858167091f1c00c69c87f4 (patch) | |
tree | fede231e50ac5d65f99ef6fcaefa4a8084e02144 /swiftclient | |
parent | c3766319b93d60e30f55747f6cfc9ca915ff603c (diff) | |
download | python-swiftclient-67f629cdeb4e4c9fcb858167091f1c00c69c87f4.tar.gz |
Default to v3 auth if we find a (user|project)-domain-(name|id) option
Change-Id: I4616492752b620de0bf90672142f1071ec9bac83
Diffstat (limited to 'swiftclient')
-rw-r--r-- | swiftclient/service.py | 17 | ||||
-rwxr-xr-x | swiftclient/shell.py | 3 |
2 files changed, 13 insertions, 7 deletions
diff --git a/swiftclient/service.py b/swiftclient/service.py index dfe2018..081d624 100644 --- a/swiftclient/service.py +++ b/swiftclient/service.py @@ -92,11 +92,18 @@ def process_options(options): elif options.get('auth_version') == '2': options['auth_version'] = '2.0' - if (not (options.get('auth') and options.get('user') - and options.get('key')) - and options.get('auth_version') != '3'): - # Use keystone 2.0 auth if any of the old-style args are missing - options['auth_version'] = '2.0' + if options.get('auth_version') not in ('2.0', '3') and not all( + options.get(key) for key in ('auth', 'user', 'key')): + # Use keystone auth if any of the new-style args are present + if any(options.get(k) for k in ( + 'os_user_domain_id', + 'os_user_domain_name', + 'os_project_domain_id', + 'os_project_domain_name')): + # Use v3 if there's any reference to domains + options['auth_version'] = '3' + else: + options['auth_version'] = '2.0' # Use new-style args if old ones not present if not options['auth'] and options['os_auth_url']: diff --git a/swiftclient/shell.py b/swiftclient/shell.py index 34407f4..a422293 100755 --- a/swiftclient/shell.py +++ b/swiftclient/shell.py @@ -1197,8 +1197,7 @@ def parse_args(parser, args, enforce_requires=True): return options, args if (options['os_options']['object_storage_url'] and - options['os_options']['auth_token'] and - options['auth_version'] in ('2.0', '3')): + options['os_options']['auth_token']): return options, args if enforce_requires: |