summaryrefslogtreecommitdiff
path: root/swiftclient/client.py
diff options
context:
space:
mode:
authorClay Gerrard <clay.gerrard@gmail.com>2017-06-13 11:14:52 -0700
committerLuigi Toscano <ltoscano@redhat.com>2018-06-20 13:25:46 +0000
commit11908250549fed549169519d411394296fb4a57b (patch)
tree85c7cc62d16324dc8d48ba406ad502adc1817fb8 /swiftclient/client.py
parent2312182241d36c716e624a23acd51f2b0252e4aa (diff)
downloadpython-swiftclient-11908250549fed549169519d411394296fb4a57b.tar.gz
Make OS_AUTH_URL work in DevStack by default
An earlier change added support for versionless authurls, but the huristic to detect them didn't work for some configurations I've encountered. Now we use a little bit tighter pattern matching and support auth_url values with more than one path component. Change-Id: I5a99c7b4e957ee7c8a5b5470477db49ab2ddba4b Related-Change-Id: If7ecb67776cb77828f93ad8278cc5040015216b7
Diffstat (limited to 'swiftclient/client.py')
-rw-r--r--swiftclient/client.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/swiftclient/client.py b/swiftclient/client.py
index 4518808..cc2a124 100644
--- a/swiftclient/client.py
+++ b/swiftclient/client.py
@@ -17,6 +17,7 @@
OpenStack Swift client library used internally
"""
import socket
+import re
import requests
import logging
import warnings
@@ -38,6 +39,7 @@ from swiftclient.utils import (
# Default is 100, increase to 256
http_client._MAXHEADERS = 256
+VERSIONFUL_AUTH_PATH = re.compile('v[2-3](?:\.0)?$')
AUTH_VERSIONS_V1 = ('1.0', '1', 1)
AUTH_VERSIONS_V2 = ('2.0', '2', 2)
AUTH_VERSIONS_V3 = ('3.0', '3', 3)
@@ -555,7 +557,10 @@ def get_auth_keystone(auth_url, user, key, os_options, **kwargs):
# 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 not VERSIONFUL_AUTH_PATH.match(
+ urlparse(auth_url).path.rstrip('/').rsplit('/', 1)[-1]):
+ # Normalize auth_url to end in a slash because urljoin
+ auth_url = auth_url.rstrip('/') + '/'
if auth_version and auth_version in AUTH_VERSIONS_V2:
auth_url = urljoin(auth_url, "v2.0")
else: