Respect region name when processing domain URL

When deprecating the use of management_url from service_catalog we
updated the management_url setter for the project scoped token, however
we missed the domain scoped token case.

There is actually nothing we can do here to test this scenario as the
backwards compatibility code that was installed handles this for us and
there is no problem, however we should not be internally relying on
deprecated code.

Change-Id: I59bac4d9d74f2eb8bc6edd40518c7cd5a4fe1343
This commit is contained in:
Jamie Lennox
2014-01-10 16:38:55 +10:00
parent 0c595f96f3
commit 06d93cb0d8
2 changed files with 11 additions and 10 deletions

View File

@@ -455,6 +455,15 @@ class HTTPClient(object):
except Exception as e:
_logger.warning("Failed to store token into keyring %s" % (e))
def _process_management_url(self, region_name):
try:
self._management_url = self.auth_ref.service_catalog.url_for(
service_type='identity',
endpoint_type='admin',
region_name=region_name)
except exceptions.EndpointNotFound:
_logger.warning("Failed to retrieve management_url from token")
def process_token(self, region_name=None):
"""Extract and process information from the new auth_ref.
@@ -467,14 +476,7 @@ class HTTPClient(object):
if not self.auth_ref.tenant_id:
raise exceptions.AuthorizationFailure(
"Token didn't provide tenant_id")
try:
self._management_url = self.auth_ref.service_catalog.url_for(
service_type='identity',
endpoint_type='admin',
region_name=region_name or self.region_name)
except exceptions.EndpointNotFound:
_logger.warning("Failed to retrieve management_url from token")
self._process_management_url(region_name)
self.project_name = self.auth_ref.tenant_name
self.project_id = self.auth_ref.tenant_id

View File

@@ -117,8 +117,7 @@ class Client(httpclient.HTTPClient):
if not self.auth_ref.domain_id:
raise exceptions.AuthorizationFailure(
"Token didn't provide domain_id")
if self.auth_ref.management_url:
self._management_url = self.auth_ref.management_url[0]
self._process_management_url(kwargs.get('region_name'))
self.domain_name = self.auth_ref.domain_name
self.domain_id = self.auth_ref.domain_id