summaryrefslogtreecommitdiff
path: root/swiftclient
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-08-29 02:15:28 +0000
committerGerrit Code Review <review@openstack.org>2017-08-29 02:15:28 +0000
commitc50823ebf1fc3d691e1589321fb03a6464604530 (patch)
tree30347b876eaecab3e5a37159d737843bc570aa7e /swiftclient
parentf323bb4824d98e74fdd5e357526ce678d0f7d45a (diff)
parent2ff3102cf779a507af8fa39296154a17a60f540a (diff)
downloadpython-swiftclient-c50823ebf1fc3d691e1589321fb03a6464604530.tar.gz
Merge "Add support for versionless endpoints"
Diffstat (limited to 'swiftclient')
-rw-r--r--swiftclient/client.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/swiftclient/client.py b/swiftclient/client.py
index 80bc4a3..7db75f0 100644
--- a/swiftclient/client.py
+++ b/swiftclient/client.py
@@ -25,7 +25,7 @@ from distutils.version import StrictVersion
from requests.exceptions import RequestException, SSLError
from six.moves import http_client
from six.moves.urllib.parse import quote as _quote, unquote
-from six.moves.urllib.parse import urlparse, urlunparse
+from six.moves.urllib.parse import urljoin, urlparse, urlunparse
from time import sleep, time
import six
@@ -550,9 +550,22 @@ def get_auth_keystone(auth_url, user, key, os_options, **kwargs):
insecure = kwargs.get('insecure', False)
timeout = kwargs.get('timeout', None)
- auth_version = kwargs.get('auth_version', '2.0')
+ auth_version = kwargs.get('auth_version', None)
debug = logger.isEnabledFor(logging.DEBUG)
+ # Add the version suffix in case of versionless Keystone endpoints. If
+ # auth_version is also unset it is likely that it is v3
+ if len(urlparse(auth_url).path) <= 1:
+ if auth_version and auth_version in AUTH_VERSIONS_V2:
+ auth_url = urljoin(auth_url, "v2.0")
+ else:
+ auth_url = urljoin(auth_url, "v3")
+ auth_version = '3'
+ logger.debug("Versionless auth_url - using %s as endpoint" % auth_url)
+
+ # Legacy default if not set
+ if auth_version is None:
+ auth_version = 'v2.0'
ksclient, exceptions = _import_keystone_client(auth_version)
try: