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
=== renamed file 'bin/nova-rsapi' => 'bin/nova-api-new'
--- bin/nova-rsapi 2010-08-17 17:23:20 +0000
+++ bin/nova-api-new 2010-08-18 15:57:42 +0000
@@ -18,17 +18,17 @@
18# See the License for the specific language governing permissions and18# See the License for the specific language governing permissions and
19# limitations under the License.19# limitations under the License.
20"""20"""
21 Daemon for the Rackspace API endpoint.21Nova API daemon.
22"""22"""
2323
24from nova import api
24from nova import flags25from nova import flags
25from nova import utils26from nova import utils
26from nova import wsgi27from nova import wsgi
27from nova.endpoint import newapi
2828
29FLAGS = flags.FLAGS29FLAGS = flags.FLAGS
30flags.DEFINE_integer('cc_port', 8773, 'cloud controller port')30flags.DEFINE_integer('api_port', 8773, 'API port')
3131
32if __name__ == '__main__':32if __name__ == '__main__':
33 utils.default_flagfile()33 utils.default_flagfile()
34 wsgi.run_server(newapi.APIVersionRouter(), FLAGS.cc_port)34 wsgi.run_server(api.API(), FLAGS.api_port)
3535
=== added directory 'nova/api'
=== renamed file 'nova/endpoint/newapi.py' => 'nova/api/__init__.py'
--- nova/endpoint/newapi.py 2010-08-17 17:23:20 +0000
+++ nova/api/__init__.py 2010-08-18 15:57:42 +0000
@@ -17,35 +17,22 @@
17# under the License.17# under the License.
1818
19"""19"""
20:mod:`nova.endpoint` -- Main NOVA Api endpoints20Root WSGI middleware for all API controllers.
21=====================================================
22
23.. automodule:: nova.endpoint
24 :platform: Unix
25 :synopsis: REST APIs for all nova functions
26.. moduleauthor:: Jesse Andrews <jesse@ansolabs.com>
27.. moduleauthor:: Devin Carlen <devin.carlen@gmail.com>
28.. moduleauthor:: Vishvananda Ishaya <vishvananda@yahoo.com>
29.. moduleauthor:: Joshua McKenty <joshua@cognition.ca>
30.. moduleauthor:: Manish Singh <yosh@gimp.org>
31.. moduleauthor:: Andy Smith <andy@anarkystic.com>
32"""21"""
3322
23import routes
24
34from nova import wsgi25from nova import wsgi
35import routes26from nova.api import ec2
36from nova.endpoint import rackspace27from nova.api import rackspace
37from nova.endpoint import aws28
3829
39class APIVersionRouter(wsgi.Router):30class API(wsgi.Router):
40 """Routes top-level requests to the appropriate API."""31 """Routes top-level requests to the appropriate controller."""
4132
42 def __init__(self):33 def __init__(self):
43 mapper = routes.Mapper()34 mapper = routes.Mapper()
4435 mapper.connect(None, "/v1.0/{path_info:.*}",
45 rsapi = rackspace.API()36 controller=rackspace.API())
46 mapper.connect(None, "/v1.0/{path_info:.*}", controller=rsapi)37 mapper.connect(None, "/ec2/{path_info:.*}", controller=ec2.API())
4738 super(API, self).__init__(mapper)
48 mapper.connect(None, "/ec2/{path_info:.*}", controller=aws.API())
49
50 super(APIVersionRouter, self).__init__(mapper)
51
5239
=== renamed directory 'nova/endpoint/aws' => 'nova/api/ec2'
=== modified file 'nova/api/ec2/__init__.py'
--- nova/endpoint/aws/__init__.py 2010-08-16 17:22:41 +0000
+++ nova/api/ec2/__init__.py 2010-08-18 15:57:42 +0000
@@ -1,22 +1,42 @@
1# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2010 OpenStack LLC.
4# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17
18"""
19WSGI middleware for EC2 API controllers.
20"""
21
1import routes22import routes
2import webob.dec23import webob.dec
324
4from nova import wsgi25from nova import wsgi
526
6# TODO(gundlach): temp27
7class API(wsgi.Router):28class API(wsgi.Router):
8 """WSGI entry point for all AWS API requests."""29 """Routes EC2 requests to the appropriate controller."""
930
10 def __init__(self):31 def __init__(self):
11 mapper = routes.Mapper()32 mapper = routes.Mapper()
12
13 mapper.connect(None, "{all:.*}", controller=self.dummy)33 mapper.connect(None, "{all:.*}", controller=self.dummy)
14
15 super(API, self).__init__(mapper)34 super(API, self).__init__(mapper)
1635
36 @staticmethod
17 @webob.dec.wsgify37 @webob.dec.wsgify
18 def dummy(self, req):38 def dummy(req):
19 #TODO(gundlach)39 """Temporary dummy controller."""
20 msg = "dummy response -- please hook up __init__() to cloud.py instead"40 msg = "dummy response -- please hook up __init__() to cloud.py instead"
21 return repr({ 'dummy': msg, 41 return repr({'dummy': msg,
22 'kwargs': repr(req.environ['wsgiorg.routing_args'][1]) })42 'kwargs': repr(req.environ['wsgiorg.routing_args'][1])})
2343
=== renamed directory 'nova/endpoint/rackspace' => 'nova/api/rackspace'
=== modified file 'nova/api/rackspace/__init__.py'
--- nova/endpoint/rackspace/__init__.py 2010-08-17 17:03:38 +0000
+++ nova/api/rackspace/__init__.py 2010-08-18 15:57:42 +0000
@@ -17,20 +17,23 @@
17# under the License.17# under the License.
1818
19"""19"""
20Rackspace API Endpoint20WSGI middleware for Rackspace API controllers.
21"""21"""
2222
23import json23import json
24import time24import time
2525
26import routes
26import webob.dec27import webob.dec
27import webob.exc28import webob.exc
28import routes
2929
30from nova import flags30from nova import flags
31from nova import wsgi31from nova import wsgi
32from nova.api.rackspace import flavors
33from nova.api.rackspace import images
34from nova.api.rackspace import servers
35from nova.api.rackspace import sharedipgroups
32from nova.auth import manager36from nova.auth import manager
33from nova.endpoint.rackspace import controllers
3437
3538
36class API(wsgi.Middleware):39class API(wsgi.Middleware):
@@ -70,14 +73,9 @@
7073
71 def __init__(self):74 def __init__(self):
72 mapper = routes.Mapper()75 mapper = routes.Mapper()
7376 mapper.resource("server", "servers", controller=servers.Controller())
74 mapper.resource("server", "servers",77 mapper.resource("image", "images", controller=images.Controller())
75 controller=controllers.ServersController())78 mapper.resource("flavor", "flavors", controller=flavors.Controller())
76 mapper.resource("image", "images",
77 controller=controllers.ImagesController())
78 mapper.resource("flavor", "flavors",
79 controller=controllers.FlavorsController())
80 mapper.resource("sharedipgroup", "sharedipgroups",79 mapper.resource("sharedipgroup", "sharedipgroups",
81 controller=controllers.SharedIpGroupsController())80 controller=sharedipgroups.Controller())
82
83 super(APIRouter, self).__init__(mapper)81 super(APIRouter, self).__init__(mapper)
8482
=== renamed file 'nova/endpoint/rackspace/controllers/base.py' => 'nova/api/rackspace/base.py'
--- nova/endpoint/rackspace/controllers/base.py 2010-08-16 14:57:42 +0000
+++ nova/api/rackspace/base.py 2010-08-18 15:57:42 +0000
@@ -1,9 +1,30 @@
1# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2010 OpenStack LLC.
4# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17
1from nova import wsgi18from nova import wsgi
219
3class BaseController(wsgi.Controller):20
21class Controller(wsgi.Controller):
22 """TODO(eday): Base controller for all rackspace controllers. What is this
23 for? Is this just Rackspace specific? """
24
4 @classmethod25 @classmethod
5 def render(cls, instance):26 def render(cls, instance):
6 if isinstance(instance, list):27 if isinstance(instance, list):
7 return { cls.entity_name : cls.render(instance) }28 return {cls.entity_name: cls.render(instance)}
8 else:29 else:
9 return { "TODO": "TODO" }30 return {"TODO": "TODO"}
1031
=== renamed file 'nova/endpoint/rackspace/controllers/flavors.py' => 'nova/api/rackspace/flavors.py'
--- nova/endpoint/rackspace/controllers/flavors.py 2010-08-12 22:19:33 +0000
+++ nova/api/rackspace/flavors.py 2010-08-18 15:57:42 +0000
@@ -1,1 +1,18 @@
1class FlavorsController(object): pass1# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2010 OpenStack LLC.
4# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17
18class Controller(object): pass
219
=== renamed file 'nova/endpoint/rackspace/controllers/images.py' => 'nova/api/rackspace/images.py'
--- nova/endpoint/rackspace/controllers/images.py 2010-08-12 22:19:33 +0000
+++ nova/api/rackspace/images.py 2010-08-18 15:57:42 +0000
@@ -1,1 +1,18 @@
1class ImagesController(object): pass1# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2010 OpenStack LLC.
4# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17
18class Controller(object): pass
219
=== renamed file 'nova/endpoint/rackspace/controllers/servers.py' => 'nova/api/rackspace/servers.py'
--- nova/endpoint/rackspace/controllers/servers.py 2010-08-16 17:22:41 +0000
+++ nova/api/rackspace/servers.py 2010-08-18 15:57:42 +0000
@@ -1,12 +1,32 @@
1# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2010 OpenStack LLC.
4# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17
1from nova import rpc18from nova import rpc
2from nova.compute import model as compute19from nova.compute import model as compute
3from nova.endpoint.rackspace.controllers.base import BaseController20from nova.api.rackspace import base
421
5class ServersController(BaseController):22
23class Controller(base.Controller):
6 entity_name = 'servers'24 entity_name = 'servers'
725
8 def index(self, **kwargs):26 def index(self, **kwargs):
9 return [instance_details(inst) for inst in compute.InstanceDirectory().all]27 instances = []
28 for inst in compute.InstanceDirectory().all:
29 instances.append(instance_details(inst))
1030
11 def show(self, **kwargs):31 def show(self, **kwargs):
12 instance_id = kwargs['id']32 instance_id = kwargs['id']
1333
=== renamed file 'nova/endpoint/rackspace/controllers/sharedipgroups.py' => 'nova/api/rackspace/sharedipgroups.py'
--- nova/endpoint/rackspace/controllers/sharedipgroups.py 2010-08-12 22:19:33 +0000
+++ nova/api/rackspace/sharedipgroups.py 2010-08-18 15:57:42 +0000
@@ -1,1 +1,18 @@
1class SharedIpGroupsController(object): pass1# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2010 OpenStack LLC.
4# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17
18class Controller(object): pass
219
=== removed directory 'nova/endpoint/rackspace/controllers'
=== removed file 'nova/endpoint/rackspace/controllers/__init__.py'
--- nova/endpoint/rackspace/controllers/__init__.py 2010-08-12 22:19:33 +0000
+++ nova/endpoint/rackspace/controllers/__init__.py 1970-01-01 00:00:00 +0000
@@ -1,5 +0,0 @@
1from nova.endpoint.rackspace.controllers.images import ImagesController
2from nova.endpoint.rackspace.controllers.flavors import FlavorsController
3from nova.endpoint.rackspace.controllers.servers import ServersController
4from nova.endpoint.rackspace.controllers.sharedipgroups import \
5 SharedIpGroupsController