remove the nova dependency in the ec2_token middleware

Change-Id: I34812522b55e38d3ea030638bbae75d65f507c90
Closes-Bug: #1178740
This commit is contained in:
Lei Zhang 2013-10-08 17:40:37 +08:00
parent 5b8a6fffcc
commit 4f800bbe7f
1 changed files with 14 additions and 10 deletions

View File

@ -25,18 +25,22 @@ Starting point for routing EC2 requests.
import urlparse
from eventlet.green import httplib
from oslo.config import cfg
import webob.dec
import webob.exc
from nova import flags
from nova import utils
from nova import wsgi
from keystone.common import config
from keystone.common import wsgi
from keystone.openstack.common import jsonutils
keystone_ec2_opts = [
cfg.StrOpt('keystone_ec2_url',
default='http://localhost:5000/v2.0/ec2tokens',
help='URL to get token from ec2 request.'),
]
FLAGS = flags.FLAGS
flags.DEFINE_string('keystone_ec2_url',
'http://localhost:5000/v2.0/ec2tokens',
'URL to get token from ec2 request.')
CONF = config.CONF
CONF.register_opts(keystone_ec2_opts)
class EC2Token(wsgi.Middleware):
@ -67,13 +71,13 @@ class EC2Token(wsgi.Middleware):
'params': auth_params,
}
}
creds_json = utils.dumps(creds)
creds_json = jsonutils.dumps(creds)
headers = {'Content-Type': 'application/json'}
# Disable 'has no x member' pylint error
# for httplib and urlparse
# pylint: disable-msg=E1101
o = urlparse.urlparse(FLAGS.keystone_ec2_url)
o = urlparse.urlparse(CONF.keystone_ec2_url)
if o.scheme == 'http':
conn = httplib.HTTPConnection(o.netloc)
else:
@ -86,7 +90,7 @@ class EC2Token(wsgi.Middleware):
# having keystone return token, tenant,
# user, and roles from this call.
result = utils.loads(response)
result = jsonutils.loads(response)
try:
token_id = result['access']['token']['id']
except (AttributeError, KeyError):