Fix issues in the ec2 middleware

Change-Id: I3ea371b70f6acc2d06175367cb20b217376ec0d2
This commit is contained in:
Anthony Young 2011-10-18 12:41:37 -07:00
parent 63c1818601
commit 2bb474331d
1 changed files with 7 additions and 4 deletions

View File

@ -68,7 +68,7 @@ class EC2Token(wsgi.Middleware):
# Disable "has no x member" pylint error
# for httplib and urlparse
# pylint: disable-msg=E1101
o = urlparse(FLAGS.keystone_ec1_url)
o = urlparse(FLAGS.keystone_ec2_url)
if o.scheme == "http":
conn = httplib.HTTPConnection(o.netloc)
else:
@ -80,10 +80,13 @@ class EC2Token(wsgi.Middleware):
# NOTE(vish): We could save a call to keystone by
# having keystone return token, tenant,
# user, and roles from this call.
result = utils.loads(response)
# TODO(vish): check for errors
token_id = result['auth']['token']['id']
result = utils.loads(response)
try:
token_id = result['access']['token']['id']
except (AttributeError, KeyError):
raise webob.exc.HTTPBadRequest()
# Authenticated!
req.headers['X-Auth-Token'] = token_id
return self.application