summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/api/openstack/__init__.py1
-rw-r--r--nova/api/openstack/images.py35
-rw-r--r--nova/api/openstack/servers.py1
-rw-r--r--nova/api/openstack/views/images.py4
4 files changed, 21 insertions, 20 deletions
diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py
index 1ec943f55..14cb6b331 100644
--- a/nova/api/openstack/__init__.py
+++ b/nova/api/openstack/__init__.py
@@ -146,7 +146,6 @@ class APIRouterV11(APIRouter):
collection={'detail': 'GET'})
-
class Versions(wsgi.Application):
@webob.dec.wsgify(RequestClass=wsgi.Request)
def __call__(self, req):
diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py
index a192883fc..4cd989054 100644
--- a/nova/api/openstack/images.py
+++ b/nova/api/openstack/images.py
@@ -56,17 +56,6 @@ class Controller(wsgi.Controller):
self.__compute = compute_service or compute.API()
self.__image = image_service or _default_service
- def get_builder(self, request):
- """
- Property to get the ViewBuilder class we need to use.
- """
- version = common.get_api_version(request)
- base_url = request.application_url
- try:
- return self._builder_dispatch[version](base_url)
- except KeyError:
- raise exc.HTTPNotFound()
-
def index(self, req):
"""
Return an index listing of images available to the request.
@@ -76,7 +65,7 @@ class Controller(wsgi.Controller):
context = req.environ['nova.context']
images = self.__image.index(context)
build = self.get_builder(req).build
- return dict(images=[build(req, image, False) for image in images])
+ return dict(images=[build(image, False) for image in images])
def detail(self, req):
"""
@@ -87,7 +76,7 @@ class Controller(wsgi.Controller):
context = req.environ['nova.context']
images = self.__image.detail(context)
build = self.get_builder(req).build
- return dict(images=[build(req, image, True) for image in images])
+ return dict(images=[build(image, True) for image in images])
def show(self, req, image_id):
"""
@@ -98,7 +87,7 @@ class Controller(wsgi.Controller):
"""
context = req.environ['nova.context']
image = self.__image.show(context, image_id)
- return self.get_builder(req).build(req, image, True)
+ return self.get_builder().build(req, image, True)
def delete(self, req, image_id):
"""
@@ -132,18 +121,30 @@ class Controller(wsgi.Controller):
raise exc.HTTPBadRequest()
image = self.__compute.snapshot(context, server_id, image_name)
- return self.get_builder(req).build(req, image, True)
+ return self.get_builder(req).build(image, True)
class ControllerV10(Controller):
"""
Version 1.0 specific controller logic.
"""
- pass
+
+ def get_builder(self, request):
+ """
+ Property to get the ViewBuilder class we need to use.
+ """
+ base_url = request.application_url
+ return images_view.ViewBuilderV10(base_url)
class ControllerV11(Controller):
"""
Version 1.1 specific controller logic.
"""
- pass
+
+ def get_builder(self, request):
+ """
+ Property to get the ViewBuilder class we need to use.
+ """
+ base_url = request.application_url
+ return images_view.ViewBuilderV11(base_url)
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index 5f6fbd96c..73843f63e 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/servers.py
@@ -516,6 +516,7 @@ class Controller(wsgi.Controller):
return kernel_id, ramdisk_id
+
class ControllerV10(Controller):
def _image_id_from_req_data(self, data):
return data['server']['imageId']
diff --git a/nova/api/openstack/views/images.py b/nova/api/openstack/views/images.py
index 313ba2eba..7daa6fe26 100644
--- a/nova/api/openstack/views/images.py
+++ b/nova/api/openstack/views/images.py
@@ -66,8 +66,8 @@ class ViewBuilderV11(ViewBuilder):
"""
Return a standardized image structure for display by the API.
"""
- image = ViewBuilder.build(self, request, image_obj, detail)
- href = self.generate_url(image_obj["id"])
+ image = ViewBuilder.build(self, image_obj, detail)
+ href = self.generate_href(image_obj["id"])
image["links"] = [{
"rel": "self",