summaryrefslogtreecommitdiff
path: root/swiftclient/shell.py
diff options
context:
space:
mode:
authorAlistair Coles <alistair.coles@hpe.com>2016-02-03 13:44:53 +0000
committerAlistair Coles <alistair.coles@hpe.com>2016-02-05 11:13:08 +0000
commitd6ef83021e2d8ea4ff7efc5acf7e40f7227a8a26 (patch)
tree82b0617ee375162a929715f678c0e37fd68b0eab /swiftclient/shell.py
parentda27ad11ccb72664bd8a13c166ab8965438a9cdc (diff)
downloadpython-swiftclient-d6ef83021e2d8ea4ff7efc5acf7e40f7227a8a26.tar.gz
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
Diffstat (limited to 'swiftclient/shell.py')
-rwxr-xr-xswiftclient/shell.py23
1 files changed, 17 insertions, 6 deletions
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_url>]
- [--auth-version <auth_version>] [--user <username>]
+ [--auth-version <auth_version> |
+ --os-identity-api-version <auth_version> ]
+ [--user <username>]
[--key <api_key>] [--retries <num_retries>]
[--os-username <auth-user-name>] [--os-password <auth-password>]
[--os-user-id <auth-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.')