Switch Keystone token retrieval to API v2.0 to fix API for 9.1 #56
This commit is contained in:
parent
2c6a518fc4
commit
a942874a26
@ -16,7 +16,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
project_name = 'timmy'
|
project_name = 'timmy'
|
||||||
version = '1.16.0'
|
version = '1.16.1'
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
|
@ -684,35 +684,46 @@ class NodeManager(object):
|
|||||||
node.release))
|
node.release))
|
||||||
|
|
||||||
def auth_token(self):
|
def auth_token(self):
|
||||||
'''Get keystone token to access Nailgun API. Requires Fuel 7.0+'''
|
'''Get keystone token to access Nailgun API. Requires Fuel 5+'''
|
||||||
if self.token:
|
if self.token:
|
||||||
return True
|
return True
|
||||||
req_data = ('{ "auth": {'
|
v2_body = ('{"auth": {"tenantName": "%s", "passwordCredentials": {'
|
||||||
' "scope": {'
|
'"username": "%s", "password": "%s"}}}')
|
||||||
' "project": {'
|
# v3 not fully implemented yet
|
||||||
' "name": "%s",'
|
v3_body = ('{ "auth": {'
|
||||||
' "domain": { "id": "default" }'
|
' "scope": {'
|
||||||
' }'
|
' "project": {'
|
||||||
' },'
|
' "name": "%s",'
|
||||||
' "identity": {'
|
' "domain": { "id": "default" }'
|
||||||
' "methods": ["password"],'
|
' }'
|
||||||
' "password": {'
|
' },'
|
||||||
' "user": {'
|
' "identity": {'
|
||||||
' "name": "%s",'
|
' "methods": ["password"],'
|
||||||
' "domain": { "id": "default" },'
|
' "password": {'
|
||||||
' "password": "%s"'
|
' "user": {'
|
||||||
' }'
|
' "name": "%s",'
|
||||||
' }'
|
' "domain": { "id": "default" },'
|
||||||
' }'
|
' "password": "%s"'
|
||||||
'}}' % (self.conf['fuel_tenant'],
|
' }'
|
||||||
self.conf['fuel_user'],
|
' }'
|
||||||
self.conf['fuel_pass']))
|
' }'
|
||||||
req = urllib2.Request("http://%s:%s/v3/auth/tokens" %
|
'}}')
|
||||||
|
# Sticking to v2 API for now because Fuel 9.1 has a custom
|
||||||
|
# domain_id defined in keystone.conf which we do not know.
|
||||||
|
req_data = v2_body % (self.conf['fuel_tenant'],
|
||||||
|
self.conf['fuel_user'],
|
||||||
|
self.conf['fuel_pass'])
|
||||||
|
req = urllib2.Request("http://%s:%s/v2.0/tokens" %
|
||||||
(self.conf['fuel_ip'],
|
(self.conf['fuel_ip'],
|
||||||
self.conf['fuel_keystone_port']), req_data,
|
self.conf['fuel_keystone_port']), req_data,
|
||||||
{'Content-Type': 'application/json'})
|
{'Content-Type': 'application/json'})
|
||||||
try:
|
try:
|
||||||
token = urllib2.urlopen(req).info().getheader('X-Subject-Token')
|
### Disabling v3 token retrieval for now
|
||||||
|
# token = urllib2.urlopen(req).info().getheader('X-Subject-Token')
|
||||||
|
result = urllib2.urlopen(req)
|
||||||
|
resp_body = result.read()
|
||||||
|
resp_json = json.loads(resp_body)
|
||||||
|
token = resp_json['access']['token']['id']
|
||||||
self.token = token
|
self.token = token
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user