Merge lp:~eday/nova/api-port into lp:~hudson-openstack/nova/trunk

Proposed by Eric Day
Status: Merged
Approved by: Eric Day
Approved revision: 249
Merged at revision: 248
Proposed branch: lp:~eday/nova/api-port
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 348 lines (+157/-65)
10 files modified
bin/nova-api-new (+4/-4)
nova/api/__init__.py (+13/-26)
nova/api/ec2/__init__.py (+28/-8)
nova/api/rackspace/__init__.py (+10/-12)
nova/api/rackspace/base.py (+24/-3)
nova/api/rackspace/flavors.py (+18/-1)
nova/api/rackspace/images.py (+18/-1)
nova/api/rackspace/servers.py (+24/-4)
nova/api/rackspace/sharedipgroups.py (+18/-1)
nova/endpoint/rackspace/controllers/__init__.py (+0/-5)
To merge this branch: bzr merge lp:~eday/nova/api-port
Reviewer Review Type Date Requested Status
Matt Dietz (community) Approve
Michael Gundlach (community) Approve
Review via email: mp+32940@code.launchpad.net

Commit message

First in a series of patches to port the API from Tornado to WSGI. Also includes a few small style fixes in the new API code.

Description of the change

First in a series of patches to port the API from Tornado to WSGI. Also includes a few small style fixes in the new API code.

To post a comment you must log in.
Revision history for this message
Michael Gundlach (gundlach) wrote :

Approve, except:

line 318: s/instanmces/instances/

(though I might not bother cleaning up servers.py; it's in progress by Dietz.)

Thanks for taking care of style issues!

review: Approve
Revision history for this message
Eric Day (eday) wrote :

Ok, fixed the typo (looking forward to having tests to catch these :). I tried to keep controller fixing to a minimum since I know others are working on them, but I wanted to get a few things standardized (like imports and class names). Also pushed up another rev that removes the 'controllers' naming redundancy for the full class names.

Revision history for this message
Michael Gundlach (gundlach) wrote :

ja wohl

review: Approve
Revision history for this message
Matt Dietz (cerberus) wrote :

Looks good to me. Everything fits within what we've been talking about so far.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== renamed file 'bin/nova-rsapi' => 'bin/nova-api-new'
2--- bin/nova-rsapi 2010-08-17 17:23:20 +0000
3+++ bin/nova-api-new 2010-08-18 15:57:42 +0000
4@@ -18,17 +18,17 @@
5 # See the License for the specific language governing permissions and
6 # limitations under the License.
7 """
8- Daemon for the Rackspace API endpoint.
9+Nova API daemon.
10 """
11
12+from nova import api
13 from nova import flags
14 from nova import utils
15 from nova import wsgi
16-from nova.endpoint import newapi
17
18 FLAGS = flags.FLAGS
19-flags.DEFINE_integer('cc_port', 8773, 'cloud controller port')
20+flags.DEFINE_integer('api_port', 8773, 'API port')
21
22 if __name__ == '__main__':
23 utils.default_flagfile()
24- wsgi.run_server(newapi.APIVersionRouter(), FLAGS.cc_port)
25+ wsgi.run_server(api.API(), FLAGS.api_port)
26
27=== added directory 'nova/api'
28=== renamed file 'nova/endpoint/newapi.py' => 'nova/api/__init__.py'
29--- nova/endpoint/newapi.py 2010-08-17 17:23:20 +0000
30+++ nova/api/__init__.py 2010-08-18 15:57:42 +0000
31@@ -17,35 +17,22 @@
32 # under the License.
33
34 """
35-:mod:`nova.endpoint` -- Main NOVA Api endpoints
36-=====================================================
37-
38-.. automodule:: nova.endpoint
39- :platform: Unix
40- :synopsis: REST APIs for all nova functions
41-.. moduleauthor:: Jesse Andrews <jesse@ansolabs.com>
42-.. moduleauthor:: Devin Carlen <devin.carlen@gmail.com>
43-.. moduleauthor:: Vishvananda Ishaya <vishvananda@yahoo.com>
44-.. moduleauthor:: Joshua McKenty <joshua@cognition.ca>
45-.. moduleauthor:: Manish Singh <yosh@gimp.org>
46-.. moduleauthor:: Andy Smith <andy@anarkystic.com>
47+Root WSGI middleware for all API controllers.
48 """
49
50+import routes
51+
52 from nova import wsgi
53-import routes
54-from nova.endpoint import rackspace
55-from nova.endpoint import aws
56-
57-class APIVersionRouter(wsgi.Router):
58- """Routes top-level requests to the appropriate API."""
59+from nova.api import ec2
60+from nova.api import rackspace
61+
62+
63+class API(wsgi.Router):
64+ """Routes top-level requests to the appropriate controller."""
65
66 def __init__(self):
67 mapper = routes.Mapper()
68-
69- rsapi = rackspace.API()
70- mapper.connect(None, "/v1.0/{path_info:.*}", controller=rsapi)
71-
72- mapper.connect(None, "/ec2/{path_info:.*}", controller=aws.API())
73-
74- super(APIVersionRouter, self).__init__(mapper)
75-
76+ mapper.connect(None, "/v1.0/{path_info:.*}",
77+ controller=rackspace.API())
78+ mapper.connect(None, "/ec2/{path_info:.*}", controller=ec2.API())
79+ super(API, self).__init__(mapper)
80
81=== renamed directory 'nova/endpoint/aws' => 'nova/api/ec2'
82=== modified file 'nova/api/ec2/__init__.py'
83--- nova/endpoint/aws/__init__.py 2010-08-16 17:22:41 +0000
84+++ nova/api/ec2/__init__.py 2010-08-18 15:57:42 +0000
85@@ -1,22 +1,42 @@
86+# vim: tabstop=4 shiftwidth=4 softtabstop=4
87+
88+# Copyright 2010 OpenStack LLC.
89+# All Rights Reserved.
90+#
91+# Licensed under the Apache License, Version 2.0 (the "License"); you may
92+# not use this file except in compliance with the License. You may obtain
93+# a copy of the License at
94+#
95+# http://www.apache.org/licenses/LICENSE-2.0
96+#
97+# Unless required by applicable law or agreed to in writing, software
98+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
99+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
100+# License for the specific language governing permissions and limitations
101+# under the License.
102+
103+"""
104+WSGI middleware for EC2 API controllers.
105+"""
106+
107 import routes
108 import webob.dec
109
110 from nova import wsgi
111
112-# TODO(gundlach): temp
113+
114 class API(wsgi.Router):
115- """WSGI entry point for all AWS API requests."""
116+ """Routes EC2 requests to the appropriate controller."""
117
118 def __init__(self):
119 mapper = routes.Mapper()
120-
121 mapper.connect(None, "{all:.*}", controller=self.dummy)
122-
123 super(API, self).__init__(mapper)
124
125+ @staticmethod
126 @webob.dec.wsgify
127- def dummy(self, req):
128- #TODO(gundlach)
129+ def dummy(req):
130+ """Temporary dummy controller."""
131 msg = "dummy response -- please hook up __init__() to cloud.py instead"
132- return repr({ 'dummy': msg,
133- 'kwargs': repr(req.environ['wsgiorg.routing_args'][1]) })
134+ return repr({'dummy': msg,
135+ 'kwargs': repr(req.environ['wsgiorg.routing_args'][1])})
136
137=== renamed directory 'nova/endpoint/rackspace' => 'nova/api/rackspace'
138=== modified file 'nova/api/rackspace/__init__.py'
139--- nova/endpoint/rackspace/__init__.py 2010-08-17 17:03:38 +0000
140+++ nova/api/rackspace/__init__.py 2010-08-18 15:57:42 +0000
141@@ -17,20 +17,23 @@
142 # under the License.
143
144 """
145-Rackspace API Endpoint
146+WSGI middleware for Rackspace API controllers.
147 """
148
149 import json
150 import time
151
152+import routes
153 import webob.dec
154 import webob.exc
155-import routes
156
157 from nova import flags
158 from nova import wsgi
159+from nova.api.rackspace import flavors
160+from nova.api.rackspace import images
161+from nova.api.rackspace import servers
162+from nova.api.rackspace import sharedipgroups
163 from nova.auth import manager
164-from nova.endpoint.rackspace import controllers
165
166
167 class API(wsgi.Middleware):
168@@ -70,14 +73,9 @@
169
170 def __init__(self):
171 mapper = routes.Mapper()
172-
173- mapper.resource("server", "servers",
174- controller=controllers.ServersController())
175- mapper.resource("image", "images",
176- controller=controllers.ImagesController())
177- mapper.resource("flavor", "flavors",
178- controller=controllers.FlavorsController())
179+ mapper.resource("server", "servers", controller=servers.Controller())
180+ mapper.resource("image", "images", controller=images.Controller())
181+ mapper.resource("flavor", "flavors", controller=flavors.Controller())
182 mapper.resource("sharedipgroup", "sharedipgroups",
183- controller=controllers.SharedIpGroupsController())
184-
185+ controller=sharedipgroups.Controller())
186 super(APIRouter, self).__init__(mapper)
187
188=== renamed file 'nova/endpoint/rackspace/controllers/base.py' => 'nova/api/rackspace/base.py'
189--- nova/endpoint/rackspace/controllers/base.py 2010-08-16 14:57:42 +0000
190+++ nova/api/rackspace/base.py 2010-08-18 15:57:42 +0000
191@@ -1,9 +1,30 @@
192+# vim: tabstop=4 shiftwidth=4 softtabstop=4
193+
194+# Copyright 2010 OpenStack LLC.
195+# All Rights Reserved.
196+#
197+# Licensed under the Apache License, Version 2.0 (the "License"); you may
198+# not use this file except in compliance with the License. You may obtain
199+# a copy of the License at
200+#
201+# http://www.apache.org/licenses/LICENSE-2.0
202+#
203+# Unless required by applicable law or agreed to in writing, software
204+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
205+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
206+# License for the specific language governing permissions and limitations
207+# under the License.
208+
209 from nova import wsgi
210
211-class BaseController(wsgi.Controller):
212+
213+class Controller(wsgi.Controller):
214+ """TODO(eday): Base controller for all rackspace controllers. What is this
215+ for? Is this just Rackspace specific? """
216+
217 @classmethod
218 def render(cls, instance):
219 if isinstance(instance, list):
220- return { cls.entity_name : cls.render(instance) }
221+ return {cls.entity_name: cls.render(instance)}
222 else:
223- return { "TODO": "TODO" }
224+ return {"TODO": "TODO"}
225
226=== renamed file 'nova/endpoint/rackspace/controllers/flavors.py' => 'nova/api/rackspace/flavors.py'
227--- nova/endpoint/rackspace/controllers/flavors.py 2010-08-12 22:19:33 +0000
228+++ nova/api/rackspace/flavors.py 2010-08-18 15:57:42 +0000
229@@ -1,1 +1,18 @@
230-class FlavorsController(object): pass
231+# vim: tabstop=4 shiftwidth=4 softtabstop=4
232+
233+# Copyright 2010 OpenStack LLC.
234+# All Rights Reserved.
235+#
236+# Licensed under the Apache License, Version 2.0 (the "License"); you may
237+# not use this file except in compliance with the License. You may obtain
238+# a copy of the License at
239+#
240+# http://www.apache.org/licenses/LICENSE-2.0
241+#
242+# Unless required by applicable law or agreed to in writing, software
243+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
244+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
245+# License for the specific language governing permissions and limitations
246+# under the License.
247+
248+class Controller(object): pass
249
250=== renamed file 'nova/endpoint/rackspace/controllers/images.py' => 'nova/api/rackspace/images.py'
251--- nova/endpoint/rackspace/controllers/images.py 2010-08-12 22:19:33 +0000
252+++ nova/api/rackspace/images.py 2010-08-18 15:57:42 +0000
253@@ -1,1 +1,18 @@
254-class ImagesController(object): pass
255+# vim: tabstop=4 shiftwidth=4 softtabstop=4
256+
257+# Copyright 2010 OpenStack LLC.
258+# All Rights Reserved.
259+#
260+# Licensed under the Apache License, Version 2.0 (the "License"); you may
261+# not use this file except in compliance with the License. You may obtain
262+# a copy of the License at
263+#
264+# http://www.apache.org/licenses/LICENSE-2.0
265+#
266+# Unless required by applicable law or agreed to in writing, software
267+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
268+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
269+# License for the specific language governing permissions and limitations
270+# under the License.
271+
272+class Controller(object): pass
273
274=== renamed file 'nova/endpoint/rackspace/controllers/servers.py' => 'nova/api/rackspace/servers.py'
275--- nova/endpoint/rackspace/controllers/servers.py 2010-08-16 17:22:41 +0000
276+++ nova/api/rackspace/servers.py 2010-08-18 15:57:42 +0000
277@@ -1,12 +1,32 @@
278+# vim: tabstop=4 shiftwidth=4 softtabstop=4
279+
280+# Copyright 2010 OpenStack LLC.
281+# All Rights Reserved.
282+#
283+# Licensed under the Apache License, Version 2.0 (the "License"); you may
284+# not use this file except in compliance with the License. You may obtain
285+# a copy of the License at
286+#
287+# http://www.apache.org/licenses/LICENSE-2.0
288+#
289+# Unless required by applicable law or agreed to in writing, software
290+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
291+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
292+# License for the specific language governing permissions and limitations
293+# under the License.
294+
295 from nova import rpc
296 from nova.compute import model as compute
297-from nova.endpoint.rackspace.controllers.base import BaseController
298-
299-class ServersController(BaseController):
300+from nova.api.rackspace import base
301+
302+
303+class Controller(base.Controller):
304 entity_name = 'servers'
305
306 def index(self, **kwargs):
307- return [instance_details(inst) for inst in compute.InstanceDirectory().all]
308+ instances = []
309+ for inst in compute.InstanceDirectory().all:
310+ instances.append(instance_details(inst))
311
312 def show(self, **kwargs):
313 instance_id = kwargs['id']
314
315=== renamed file 'nova/endpoint/rackspace/controllers/sharedipgroups.py' => 'nova/api/rackspace/sharedipgroups.py'
316--- nova/endpoint/rackspace/controllers/sharedipgroups.py 2010-08-12 22:19:33 +0000
317+++ nova/api/rackspace/sharedipgroups.py 2010-08-18 15:57:42 +0000
318@@ -1,1 +1,18 @@
319-class SharedIpGroupsController(object): pass
320+# vim: tabstop=4 shiftwidth=4 softtabstop=4
321+
322+# Copyright 2010 OpenStack LLC.
323+# All Rights Reserved.
324+#
325+# Licensed under the Apache License, Version 2.0 (the "License"); you may
326+# not use this file except in compliance with the License. You may obtain
327+# a copy of the License at
328+#
329+# http://www.apache.org/licenses/LICENSE-2.0
330+#
331+# Unless required by applicable law or agreed to in writing, software
332+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
333+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
334+# License for the specific language governing permissions and limitations
335+# under the License.
336+
337+class Controller(object): pass
338
339=== removed directory 'nova/endpoint/rackspace/controllers'
340=== removed file 'nova/endpoint/rackspace/controllers/__init__.py'
341--- nova/endpoint/rackspace/controllers/__init__.py 2010-08-12 22:19:33 +0000
342+++ nova/endpoint/rackspace/controllers/__init__.py 1970-01-01 00:00:00 +0000
343@@ -1,5 +0,0 @@
344-from nova.endpoint.rackspace.controllers.images import ImagesController
345-from nova.endpoint.rackspace.controllers.flavors import FlavorsController
346-from nova.endpoint.rackspace.controllers.servers import ServersController
347-from nova.endpoint.rackspace.controllers.sharedipgroups import \
348- SharedIpGroupsController