Using request() methods on session objects with Token plugins break
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
keystoneauth |
Invalid
|
Undecided
|
Unassigned |
Bug Description
If you instantiate a Session object with an existing token using the Token authentication plugin, requests invoked via the session object fail.
For example:
auth = keystoneauth1.
#auth = glance_
return ks_session.
Will result in the following when you try to call session.post(..):
mo] Caught error: 'TokenMethod' object has no attribute 'get_headers': AttributeError: 'TokenMethod' object has no attribute 'get_headers'
Jan 08 17:35:57 guaranine <email address hidden>[174194]: ERROR glance.common.wsgi Traceback (most recent call last):
Jan 08 17:35:57 guaranine <email address hidden>[174194]: ERROR glance.common.wsgi File "/opt/stack/
Jan 08 17:35:57 guaranine <email address hidden>[174194]: ERROR glance.common.wsgi action_result = self.dispatch(
Jan 08 17:35:57 guaranine <email address hidden>[174194]: ERROR glance.common.wsgi File "/opt/stack/
Jan 08 17:35:57 guaranine <email address hidden>[174194]: ERROR glance.common.wsgi return method(*args, **kwargs)
Jan 08 17:35:57 guaranine <email address hidden>[174194]: ERROR glance.common.wsgi File "/opt/stack/
Jan 08 17:35:57 guaranine <email address hidden>[174194]: ERROR glance.common.wsgi return func(self, req, *args, **kwargs)
Jan 08 17:35:57 guaranine <email address hidden>[174194]: ERROR glance.common.wsgi File "/opt/stack/
Jan 08 17:35:57 guaranine <email address hidden>[174194]: ERROR glance.common.wsgi return self._proxy_
Jan 08 17:35:57 guaranine <email address hidden>[174194]: ERROR glance.common.wsgi File "/opt/stack/
Jan 08 17:35:57 guaranine <email address hidden>[174194]: ERROR glance.common.wsgi r = client.post(url, json=body)
Jan 08 17:35:57 guaranine <email address hidden>[174194]: ERROR glance.common.wsgi File "/usr/local/
Jan 08 17:35:57 guaranine <email address hidden>[174194]: ERROR glance.common.wsgi return self.request(url, 'POST', **kwargs)
Jan 08 17:35:57 guaranine <email address hidden>[174194]: ERROR glance.common.wsgi File "/usr/local/
Jan 08 17:35:57 guaranine <email address hidden>[174194]: ERROR glance.common.wsgi auth_headers = self.get_
Jan 08 17:35:57 guaranine <email address hidden>[174194]: ERROR glance.common.wsgi File "/usr/local/
Jan 08 17:35:57 guaranine <email address hidden>[174194]: ERROR glance.common.wsgi return auth.get_
Jan 08 17:35:57 guaranine <email address hidden>[174194]: ERROR glance.common.wsgi AttributeError: 'TokenMethod' object has no attribute 'get_headers'
Jan 08 17:35:57 guaranine <email address hidden>[174194]: ERROR glance.common.wsgi
I can recreate this using the following code:
╭─ubuntu@ubuntu20 ~
╰─➤ $ cat ksa.py 1 ↵
import os
import sys
from keystoneauth1 import session identity import v3
from keystoneauth1.
token = os.environ. get('TOKEN' )
if not token:
print('No token provided.')
sys.exit(1)
a = v3.TokenMethod( token=token) Session( auth=a)
s = session.
print(s.get('http:// 192.168. 1.150/identity/ v3/'))
╭─ubuntu@ubuntu20 ~ 192.168. 1.150/identity/ v3/')) ubuntu/ keystoneauth/ keystoneauth1/ session. py", line 1131, in get ubuntu/ keystoneauth/ keystoneauth1/ session. py", line 780, in request auth_headers( auth) ubuntu/ keystoneauth/ keystoneauth1/ session. py", line 1191, in get_auth_headers headers( self, **kwargs)
╰─➤ $ python3 ksa.py
Traceback (most recent call last):
File "ksa.py", line 15, in <module>
print(s.get('http://
File "/home/
return self.request(url, 'GET', **kwargs)
File "/home/
auth_headers = self.get_
File "/home/
return auth.get_
AttributeError: 'TokenMethod' object has no attribute 'get_headers'
I'm using keystoneauth1 version 4.3.0