Support versionless catalog URLs

Change-Id: I37bec66c801e6d04eb89b235a94e8b54ecc50d5a
This commit is contained in:
Kiall Mac Innes 2014-02-18 12:48:59 +00:00
parent a8d2752433
commit c255e57da7
2 changed files with 13 additions and 3 deletions
designateclient

@ -80,7 +80,12 @@ class KeystoneAuth(AuthBase):
endpoints = self.get_endpoints(service_type, endpoint_type,
region_name)
return endpoints[service_type][0][endpoint_type].rstrip('/')
url = endpoints[service_type][0][endpoint_type]
# NOTE(kiall): The Version 1 API is the only API that has ever included
# the version number in the endpoint. Thus, it's safe to
# simply remove it if present.
return url.rstrip('/').rstrip('v1').rstrip('/')
def refresh_auth(self):
ks = self.get_ksclient()

@ -45,15 +45,20 @@ class Client(object):
tenant_name, token, service_type,
endpoint_type, region_name, sudo_tenant_id)
if endpoint:
self.endpoint = endpoint
self.endpoint = endpoint.rstrip('/')
else:
self.endpoint = auth.get_url()
elif endpoint:
auth = None
self.endpoint = endpoint
self.endpoint = endpoint.rstrip('/')
else:
raise ValueError('Either an endpoint or auth_url must be supplied')
# NOTE(kiall): As we're in the Version 1 client, we ensure we're
# pointing at the version 1 API.
if not self.endpoint.endswith('v1'):
self.endpoint = "%s/v1" % self.endpoint
self.insecure = insecure
headers = {'Content-Type': 'application/json'}