diff options
| author | Matt Riedemann <mriedem@us.ibm.com> | 2014-10-17 07:53:05 -0700 |
|---|---|---|
| committer | Qin Zhao <chaochin@gmail.com> | 2014-10-30 18:07:50 +0800 |
| commit | 8c159a2eb4d61f2b9691fbfa1288bcda2156f3f1 (patch) | |
| tree | fac8585f8a599ed1c019bbe8405dece8885183cc /glanceclient/common/http.py | |
| parent | cfe06235207d50d6d36b3d8b3e87608412038c80 (diff) | |
| download | python-glanceclient-8c159a2eb4d61f2b9691fbfa1288bcda2156f3f1.tar.gz | |
Don't set X-Auth-Token key in http session header if no token provided
Commit f980fc549247fa2deb87dfacebc6d8d13ccd45d1 changed how the
X-Auth-Token header was scrubbed when logging the request, but
effectively made the value required which can lead to an AttributeError
if the value for the header is None.
The value can be None if you're using Nova but don't have Nova
configured with auth_strategy='keystone' (see
nova.image.glance._create_glance_client for details).
This patch simply checks if the auth_token is set in the http client
object and if not, it doesn't set the X-Auth-Token key in the session
header.
Closes-Bug: #1381295
Change-Id: Ie285d5253df28a9f0f964147a53c99ceaa919c5c
Diffstat (limited to 'glanceclient/common/http.py')
| -rw-r--r-- | glanceclient/common/http.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/glanceclient/common/http.py b/glanceclient/common/http.py index ad9da20..8609ef3 100644 --- a/glanceclient/common/http.py +++ b/glanceclient/common/http.py @@ -62,7 +62,9 @@ class HTTPClient(object): self.session = requests.Session() self.session.headers["User-Agent"] = USER_AGENT - self.session.headers["X-Auth-Token"] = self.auth_token + + if self.auth_token: + self.session.headers["X-Auth-Token"] = self.auth_token self.timeout = float(kwargs.get('timeout', 600)) |
