From d6ef83021e2d8ea4ff7efc5acf7e40f7227a8a26 Mon Sep 17 00:00:00 2001 From: Alistair Coles Date: Wed, 3 Feb 2016 13:44:53 +0000 Subject: Support --os-identity-api-version option Add support for the auth-version to be specified using --os-identity-api-version or OS_IDENTITY_API_VERSION for compatibility with other openstack client command line options. The auth version used will be selected as follows: - if either --auth-version or --os-identity-api-version is set, use that value - otherwise use the value of ST_AUTH_VERSION, if set - otherwise use the value of OS_AUTH_VERSION, if set - otherwise (new behaviour) use the value of OS_IDENTITY_API_VERSION, if set - otherwise default to 1.0 Note that before this change the auth version might have defaulted to 1.0 despite OS_IDENTITY_API_VERSION being set, but with this change OS_IDENTITY_API_VERSION is preferred. Change-Id: Ifba4c4e43560ede3013337b8cdbc77dc2de6e8ff Closes-Bug: #1541273 --- swiftclient/shell.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'swiftclient/shell.py') diff --git a/swiftclient/shell.py b/swiftclient/shell.py index e427a89..4cad574 100755 --- a/swiftclient/shell.py +++ b/swiftclient/shell.py @@ -1193,7 +1193,9 @@ def main(arguments=None): usage=''' usage: %prog [--version] [--help] [--os-help] [--snet] [--verbose] [--debug] [--info] [--quiet] [--auth ] - [--auth-version ] [--user ] + [--auth-version | + --os-identity-api-version ] + [--user ] [--key ] [--retries ] [--os-username ] [--os-password ] [--os-user-id ] @@ -1254,6 +1256,15 @@ Examples: %prog list --lh '''.strip('\n')) + + default_auth_version = '1.0' + for k in ('ST_AUTH_VERSION', 'OS_AUTH_VERSION', 'OS_IDENTITY_API_VERSION'): + try: + default_auth_version = environ[k] + break + except KeyError: + pass + parser.add_option('--os-help', action='store_true', dest='os_help', help='Show OpenStack authentication options.') parser.add_option('--os_help', action='store_true', help=SUPPRESS_HELP) @@ -1272,14 +1283,14 @@ Examples: parser.add_option('-A', '--auth', dest='auth', default=environ.get('ST_AUTH'), help='URL for obtaining an auth token.') - parser.add_option('-V', '--auth-version', + parser.add_option('-V', '--auth-version', '--os-identity-api-version', dest='auth_version', - default=environ.get('ST_AUTH_VERSION', - (environ.get('OS_AUTH_VERSION', - '1.0'))), + default=default_auth_version, type=str, help='Specify a version for authentication. ' - 'Defaults to 1.0.') + 'Defaults to env[ST_AUTH_VERSION], ' + 'env[OS_AUTH_VERSION], env[OS_IDENTITY_API_VERSION]' + ' or 1.0.') parser.add_option('-U', '--user', dest='user', default=environ.get('ST_USER'), help='User name for obtaining an auth token.') -- cgit v1.2.1