1 This upstream patch addresses Launchpad bug 1178740. Although it's been |
|
2 addressed in Icehouse 2014.1, the patch below is still not yet released |
|
3 for Havana. |
|
4 |
|
5 commit 4f800bbe7f5ba07895a4cb32c14007e2f1818bd7 |
|
6 Author: Lei Zhang <[email protected]> |
|
7 Date: Tue Oct 8 17:40:37 2013 +0800 |
|
8 |
|
9 remove the nova dependency in the ec2_token middleware |
|
10 |
|
11 Change-Id: I34812522b55e38d3ea030638bbae75d65f507c90 |
|
12 Closes-Bug: #1178740 |
|
13 |
|
14 diff --git a/keystone/middleware/ec2_token.py b/keystone/middleware/ec2_token.py |
|
15 index 0cd5841..4e58eac 100644 |
|
16 --- a/keystone/middleware/ec2_token.py |
|
17 +++ b/keystone/middleware/ec2_token.py |
|
18 @@ -25,18 +25,22 @@ Starting point for routing EC2 requests. |
|
19 import urlparse |
|
20 |
|
21 from eventlet.green import httplib |
|
22 +from oslo.config import cfg |
|
23 import webob.dec |
|
24 import webob.exc |
|
25 |
|
26 -from nova import flags |
|
27 -from nova import utils |
|
28 -from nova import wsgi |
|
29 +from keystone.common import config |
|
30 +from keystone.common import wsgi |
|
31 +from keystone.openstack.common import jsonutils |
|
32 |
|
33 +keystone_ec2_opts = [ |
|
34 + cfg.StrOpt('keystone_ec2_url', |
|
35 + default='http://localhost:5000/v2.0/ec2tokens', |
|
36 + help='URL to get token from ec2 request.'), |
|
37 +] |
|
38 |
|
39 -FLAGS = flags.FLAGS |
|
40 -flags.DEFINE_string('keystone_ec2_url', |
|
41 - 'http://localhost:5000/v2.0/ec2tokens', |
|
42 - 'URL to get token from ec2 request.') |
|
43 +CONF = config.CONF |
|
44 +CONF.register_opts(keystone_ec2_opts) |
|
45 |
|
46 |
|
47 class EC2Token(wsgi.Middleware): |
|
48 @@ -67,13 +71,13 @@ class EC2Token(wsgi.Middleware): |
|
49 'params': auth_params, |
|
50 } |
|
51 } |
|
52 - creds_json = utils.dumps(creds) |
|
53 + creds_json = jsonutils.dumps(creds) |
|
54 headers = {'Content-Type': 'application/json'} |
|
55 |
|
56 # Disable 'has no x member' pylint error |
|
57 # for httplib and urlparse |
|
58 # pylint: disable-msg=E1101 |
|
59 - o = urlparse.urlparse(FLAGS.keystone_ec2_url) |
|
60 + o = urlparse.urlparse(CONF.keystone_ec2_url) |
|
61 if o.scheme == 'http': |
|
62 conn = httplib.HTTPConnection(o.netloc) |
|
63 else: |
|
64 @@ -86,7 +90,7 @@ class EC2Token(wsgi.Middleware): |
|
65 # having keystone return token, tenant, |
|
66 # user, and roles from this call. |
|
67 |
|
68 - result = utils.loads(response) |
|
69 + result = jsonutils.loads(response) |
|
70 try: |
|
71 token_id = result['access']['token']['id'] |
|
72 except (AttributeError, KeyError): |
|