From d0093c5cc3a4f08b0f2cd418a69f0fb7ecbf66b3 Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Wed, 28 Jun 2017 20:56:09 +0800 Subject: [PATCH] Use plain routes list for images instead of stevedore This patch adds images related routes by a plain list, instead of using stevedore. After all the Nova API endpoints moves to the plain routes list, the usage of stevedore for API loading will be removed from Nova. Partial-implement-blueprint api-no-more-extensions-pike Change-Id: I884dbfef8032a34d155a7022037f5690d86ef532 --- nova/api/openstack/compute/image_size.py | 19 ------------------- nova/api/openstack/compute/images.py | 21 --------------------- nova/api/openstack/compute/routes.py | 17 +++++++++++++++++ setup.cfg | 2 -- 4 files changed, 17 insertions(+), 42 deletions(-) diff --git a/nova/api/openstack/compute/image_size.py b/nova/api/openstack/compute/image_size.py index 371db5d9d3..8ed4ae6135 100644 --- a/nova/api/openstack/compute/image_size.py +++ b/nova/api/openstack/compute/image_size.py @@ -13,12 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. -from nova.api.openstack import extensions from nova.api.openstack import wsgi from nova.policies import image_size as is_policies -ALIAS = "image-size" - class ImageSizeController(wsgi.Controller): @@ -49,19 +46,3 @@ class ImageSizeController(wsgi.Controller): for image in images_resp: image_cached = req.get_db_item('images', image['id']) self._extend_image(image, image_cached) - - -class ImageSize(extensions.V21APIExtensionBase): - """Adds image size to image listings.""" - - name = "ImageSize" - alias = ALIAS - version = 1 - - def get_controller_extensions(self): - controller = ImageSizeController() - extension = extensions.ControllerExtension(self, 'images', controller) - return [extension] - - def get_resources(self): - return [] diff --git a/nova/api/openstack/compute/images.py b/nova/api/openstack/compute/images.py index 060bd46278..44c5e0c5fc 100644 --- a/nova/api/openstack/compute/images.py +++ b/nova/api/openstack/compute/images.py @@ -27,8 +27,6 @@ import nova.image import nova.utils -ALIAS = 'images' - SUPPORTED_FILTERS = { 'name': 'name', 'status': 'status', @@ -154,22 +152,3 @@ class ImagesController(wsgi.Controller): req.cache_db_items('images', images, 'id') return self._view_builder.detail(req, images) - - -class Images(extensions.V21APIExtensionBase): - """Proxying API for Images.""" - - name = "Images" - alias = ALIAS - version = 1 - - def get_resources(self): - coll_actions = {'detail': 'GET'} - resource = extensions.ResourceExtension(ALIAS, - ImagesController(), - collection_actions=coll_actions) - - return [resource] - - def get_controller_extensions(self): - return [] diff --git a/nova/api/openstack/compute/routes.py b/nova/api/openstack/compute/routes.py index debd43e9c5..6619046243 100644 --- a/nova/api/openstack/compute/routes.py +++ b/nova/api/openstack/compute/routes.py @@ -53,6 +53,8 @@ from nova.api.openstack.compute import fping from nova.api.openstack.compute import hide_server_addresses from nova.api.openstack.compute import hosts from nova.api.openstack.compute import hypervisors +from nova.api.openstack.compute import image_size +from nova.api.openstack.compute import images from nova.api.openstack.compute import instance_actions from nova.api.openstack.compute import instance_usage_audit_log from nova.api.openstack.compute import ips @@ -195,6 +197,11 @@ hypervisors_controller = functools.partial( _create_controller, hypervisors.HypervisorsController, [], []) +images_controller = functools.partial( + _create_controller, images.ImagesController, + [image_size.ImageSizeController], []) + + instance_actions_controller = functools.partial(_create_controller, instance_actions.InstanceActionsController, [], []) @@ -374,6 +381,16 @@ ROUTE_LIST = ( ('/flavors/{flavor_id}/os-flavor-access', { 'GET': [flavor_access_controller, 'index'] }), + ('/images', { + 'GET': [images_controller, 'index'] + }), + ('/images/detail', { + 'GET': [images_controller, 'detail'], + }), + ('/images/{id}', { + 'GET': [images_controller, 'show'], + 'DELETE': [images_controller, 'delete'] + }), ('/limits', { 'GET': [limits_controller, 'index'] }), diff --git a/setup.cfg b/setup.cfg index 69efe1498c..6c02201d5a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -74,9 +74,7 @@ wsgi_scripts = nova.api.v21.extensions = baremetal_nodes = nova.api.openstack.compute.baremetal_nodes:BareMetalNodes extension_info = nova.api.openstack.compute.extension_info:ExtensionInfo - images = nova.api.openstack.compute.images:Images image_metadata = nova.api.openstack.compute.image_metadata:ImageMetadata - image_size = nova.api.openstack.compute.image_size:ImageSize security_group_default_rules = nova.api.openstack.compute.security_group_default_rules:SecurityGroupDefaultRules security_groups = nova.api.openstack.compute.security_groups:SecurityGroups versions = nova.api.openstack.compute.versionsV21:Versions