Ensure keystoneclient.auth_token is re-evaluated
Fixes bug 1207441 Force the re-evaluation of the keystoneclient.auth_token property so as to avoid missing out on the in-built refresh logic when expiry is imminent. Change-Id: I8319e9e9a71e33e089fbe2fbc812d2b6c15da927
This commit is contained in:
@@ -73,7 +73,9 @@ def get_client(api_version, **kwargs):
|
|||||||
'insecure': kwargs.get('insecure'),
|
'insecure': kwargs.get('insecure'),
|
||||||
}
|
}
|
||||||
_ksclient = _get_ksclient(**ks_kwargs)
|
_ksclient = _get_ksclient(**ks_kwargs)
|
||||||
token = kwargs.get('os_auth_token') or _ksclient.auth_token
|
token = ((lambda: kwargs.get('os_auth_token'))
|
||||||
|
if 'os_auth_token' in kwargs
|
||||||
|
else (lambda: _ksclient.auth_token))
|
||||||
|
|
||||||
endpoint = kwargs.get('ceilometer_url') or \
|
endpoint = kwargs.get('ceilometer_url') or \
|
||||||
_get_endpoint(_ksclient, **ks_kwargs)
|
_get_endpoint(_ksclient, **ks_kwargs)
|
||||||
|
|||||||
@@ -133,8 +133,9 @@ class HTTPClient(object):
|
|||||||
# Copy the kwargs so we can reuse the original in case of redirects
|
# Copy the kwargs so we can reuse the original in case of redirects
|
||||||
kwargs['headers'] = copy.deepcopy(kwargs.get('headers', {}))
|
kwargs['headers'] = copy.deepcopy(kwargs.get('headers', {}))
|
||||||
kwargs['headers'].setdefault('User-Agent', USER_AGENT)
|
kwargs['headers'].setdefault('User-Agent', USER_AGENT)
|
||||||
if self.auth_token:
|
auth_token = self.auth_token()
|
||||||
kwargs['headers'].setdefault('X-Auth-Token', self.auth_token)
|
if auth_token:
|
||||||
|
kwargs['headers'].setdefault('X-Auth-Token', auth_token)
|
||||||
|
|
||||||
self.log_curl_request(method, url, kwargs)
|
self.log_curl_request(method, url, kwargs)
|
||||||
conn = self.get_connection()
|
conn = self.get_connection()
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class Client(http.HTTPClient):
|
|||||||
|
|
||||||
:param string endpoint: A user-supplied endpoint URL for the ceilometer
|
:param string endpoint: A user-supplied endpoint URL for the ceilometer
|
||||||
service.
|
service.
|
||||||
:param string token: Token for authentication.
|
:param function token: Provides token for authentication.
|
||||||
:param integer timeout: Allows customization of the timeout for client
|
:param integer timeout: Allows customization of the timeout for client
|
||||||
http requests. (optional)
|
http requests. (optional)
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class Client(http.HTTPClient):
|
|||||||
|
|
||||||
:param string endpoint: A user-supplied endpoint URL for the ceilometer
|
:param string endpoint: A user-supplied endpoint URL for the ceilometer
|
||||||
service.
|
service.
|
||||||
:param string token: Token for authentication.
|
:param function token: Provides token for authentication.
|
||||||
:param integer timeout: Allows customization of the timeout for client
|
:param integer timeout: Allows customization of the timeout for client
|
||||||
http requests. (optional)
|
http requests. (optional)
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user