diff --git a/designateclient/auth.py b/designateclient/auth.py index 2d49c6bb..8f1e1e20 100644 --- a/designateclient/auth.py +++ b/designateclient/auth.py @@ -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() diff --git a/designateclient/v1/__init__.py b/designateclient/v1/__init__.py index 6a3ee6bf..5459f5ae 100644 --- a/designateclient/v1/__init__.py +++ b/designateclient/v1/__init__.py @@ -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'}