diff --git a/README.rst b/README.rst index 68317566..b5e6d3ce 100644 --- a/README.rst +++ b/README.rst @@ -109,7 +109,7 @@ The command line client is self-documenting. Use the --help flag to access the u --no-auth, -N Do not use authentication. --os-identity-api-version Specify Identity API version to use. Defaults to - env[OS_IDENTITY_API_VERSION] or 3.0. + env[OS_IDENTITY_API_VERSION] or 3. --os-auth-url , -A Defaults to env[OS_AUTH_URL]. @@ -180,4 +180,4 @@ The command line client is self-documenting. Use the --help flag to access the u * Bugs: http://bugs.launchpad.net/python-barbicanclient .. [1] Documentation in this link is currently incomplete. Please use the -`devstack setup. `__ \ No newline at end of file +`devstack setup. `__ diff --git a/barbicanclient/barbican.py b/barbicanclient/barbican.py index e7f4d5f5..fc0b1e5b 100644 --- a/barbicanclient/barbican.py +++ b/barbicanclient/barbican.py @@ -34,7 +34,9 @@ from barbicanclient import client from barbicanclient import version -_DEFAULT_IDENTITY_API_VERSION = '3.0' +_DEFAULT_IDENTITY_API_VERSION = '3' +_IDENTITY_API_VERSION_2 = ['2', '2.0'] +_IDENTITY_API_VERSION_3 = ['3'] class Barbican(app.App): @@ -125,10 +127,19 @@ class Barbican(app.App): kwargs = self.build_kwargs_based_on_version(args, api_version) kwargs.update(kwargs_dict) - if not api_version or api_version == _DEFAULT_IDENTITY_API_VERSION: - method = v3.Token if auth_type == 'token' else v3.Password - else: + if api_version in _IDENTITY_API_VERSION_2: method = v2.Token if auth_type == 'token' else v2.Password + else: + if not api_version or api_version not in _IDENTITY_API_VERSION_3: + self.stderr.write( + "WARNING: The identity version <{0}> is not in supported " + "versions <{1}>, falling back to <{2}>.".format( + api_version, + _IDENTITY_API_VERSION_2 + _IDENTITY_API_VERSION_3, + _DEFAULT_IDENTITY_API_VERSION + ) + ) + method = v3.Token if auth_type == 'token' else v3.Password auth = method(**kwargs) @@ -217,7 +228,7 @@ class Barbican(app.App): default=client.env('OS_IDENTITY_API_VERSION'), help='Specify Identity API version to use. ' 'Defaults to env[OS_IDENTITY_API_VERSION]' - ' or 3.0.') + ' or 3.') parser.add_argument('--os-auth-url', '-A', metavar='', default=client.env('OS_AUTH_URL'), diff --git a/barbicanclient/tests/keystone_client_fixtures.py b/barbicanclient/tests/keystone_client_fixtures.py index bf6e22a4..eb3de381 100644 --- a/barbicanclient/tests/keystone_client_fixtures.py +++ b/barbicanclient/tests/keystone_client_fixtures.py @@ -47,7 +47,7 @@ V3_MEDIA_TYPES = [{'base': 'application/json', {'base': 'application/xml', 'type': 'application/vnd.openstack.identity-v3+xml'}] -V3_VERSION = {'id': 'v3.0', +V3_VERSION = {'id': 'v3', 'links': [{'href': V3_URL, 'rel': 'self'}], 'media-types': V3_MEDIA_TYPES, 'status': 'stable', diff --git a/functionaltests/cli/v1/behaviors/base_behaviors.py b/functionaltests/cli/v1/behaviors/base_behaviors.py index a4e75fad..5ebdd7e1 100644 --- a/functionaltests/cli/v1/behaviors/base_behaviors.py +++ b/functionaltests/cli/v1/behaviors/base_behaviors.py @@ -57,7 +57,7 @@ class BaseBehaviors(object): arg_list.extend( ['--os-project-domain-name', CONF.keymanager.project_domain_name]) - arg_list.extend(['--os-identity-api-version', '3.0']) + arg_list.extend(['--os-identity-api-version', '3']) else: arg_list.extend(['--os-auth-url', CONF.identity.uri]) arg_list.extend(['--os-tenant-name', CONF.keymanager.project_name])