diff options
author | Alistair Coles <alistair.coles@hp.com> | 2014-09-22 11:52:44 +0100 |
---|---|---|
committer | Alistair Coles <alistair.coles@hp.com> | 2014-09-24 18:19:12 +0100 |
commit | f90d7f28e504be045e59b395aee0abc057417f8f (patch) | |
tree | 0c6e81ec791dcc5e9f80070717fcfbe78854c449 /swiftclient/service.py | |
parent | 8f1b394325804c23ac18e7f9da6cb56a3b95eed2 (diff) | |
download | python-swiftclient-f90d7f28e504be045e59b395aee0abc057417f8f.tar.gz |
Fix bug with some OS options not being passed to client
Fixes a regression that is preventing swiftclient from
authenticating using keystone v3 options.
swiftclient/shell.py processes the dict of command
line options to set up a child dict ('os_options')
of keystone auth specific options (line 960). The
processing includes stripping --os- prefixes from
the command line options before adding keys to
os_options.
A recent patch https://review.openstack.org/#/c/85453/
introduced a duplication of this option processing
in service.py (line 79) which replaces the os_options
created in shell.py, but omits keystone v3 related
options. Consequently the keystone v3 options are
not being passed to the client get_auth() method.
This patch adds the keystone v3 related options to
the option processing in service.py.
For pragmatic reasons (i.e. fixing the bug quickly)
the option processing code has not been removed from
parse_args in shell.py. It is likely that the code in
parse_args is now redundant, but all code paths between
parse_args and process_options should be inspected and
test coverage added before removing that code.
Unit tests have been added in test_shell.py to verify
that command line options are correctly passed to the
client get_auth method.
The MockHttpTest class is re-used in test_shell.py,
so it is moved from test_swiftclient.py
to tests/unit/utils.py
Closes-bug: #1372465
Change-Id: I4fed013cdb8936509609d06093337cc147ade0d6
Diffstat (limited to 'swiftclient/service.py')
-rw-r--r-- | swiftclient/service.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/swiftclient/service.py b/swiftclient/service.py index fa39ecc..365485a 100644 --- a/swiftclient/service.py +++ b/swiftclient/service.py @@ -77,8 +77,10 @@ class SwiftError(Exception): def process_options(options): - if not (options['auth'] and options['user'] and options['key']): - # Use 2.0 auth if none of the old args are present + 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' # Use new-style args if old ones not present @@ -91,8 +93,15 @@ def process_options(options): # Specific OpenStack options options['os_options'] = { + 'user_id': options['os_user_id'], + 'user_domain_id': options['os_user_domain_id'], + 'user_domain_name': options['os_user_domain_name'], 'tenant_id': options['os_tenant_id'], 'tenant_name': options['os_tenant_name'], + 'project_id': options['os_project_id'], + 'project_name': options['os_project_name'], + 'project_domain_id': options['os_project_domain_id'], + 'project_domain_name': options['os_project_domain_name'], 'service_type': options['os_service_type'], 'endpoint_type': options['os_endpoint_type'], 'auth_token': options['os_auth_token'], @@ -111,9 +120,16 @@ _default_global_options = { "key": environ.get('ST_KEY'), "retries": 5, "os_username": environ.get('OS_USERNAME'), + "os_user_id": environ.get('OS_USER_ID'), + "os_user_domain_name": environ.get('OS_USER_DOMAIN_NAME'), + "os_user_domain_id": environ.get('OS_USER_DOMAIN_ID'), "os_password": environ.get('OS_PASSWORD'), "os_tenant_id": environ.get('OS_TENANT_ID'), "os_tenant_name": environ.get('OS_TENANT_NAME'), + "os_project_name": environ.get('OS_PROJECT_NAME'), + "os_project_id": environ.get('OS_PROJECT_ID'), + "os_project_domain_name": environ.get('OS_PROJECT_DOMAIN_NAME'), + "os_project_domain_id": environ.get('OS_PROJECT_DOMAIN_ID'), "os_auth_url": environ.get('OS_AUTH_URL'), "os_auth_token": environ.get('OS_AUTH_TOKEN'), "os_storage_url": environ.get('OS_STORAGE_URL'), |