From c20d52d1afbc4bae9090fb3367ec1c2760f9c678 Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Fri, 14 Apr 2017 11:25:04 +0300 Subject: [PATCH] Use plain routes list for '/os-keypairs' endpoint instead of stevedore This patch adds '/os-keypairs' 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. Also note that the original 'ProjectMapper' use the 'routes.Mapper.resource' to create a set of routes for a resource which comform to the Atom publishing protocol. It includes some of URL mappings we didn't document before. This patch will remove those URL mappings. For the detail, please reference: http://lists.openstack.org/pipermail/openstack-dev/2017-March/114736.html Partial-implement-blueprint api-no-more-extensions-pike Change-Id: I9b18e7acce37ba935f4302cc89c3aeccc4f50915 --- nova/api/openstack/compute/extension_info.py | 5 ++++- nova/api/openstack/compute/keypairs.py | 22 -------------------- nova/api/openstack/compute/routes.py | 12 +++++++++++ setup.cfg | 1 - 4 files changed, 16 insertions(+), 24 deletions(-) diff --git a/nova/api/openstack/compute/extension_info.py b/nova/api/openstack/compute/extension_info.py index 5402c9052443..0387bcaf9fd8 100644 --- a/nova/api/openstack/compute/extension_info.py +++ b/nova/api/openstack/compute/extension_info.py @@ -197,7 +197,10 @@ hardcoded_extensions = [ 'alias': 'os-flavor-extra-specs'}, {'name': 'FlavorAccess', 'description': 'Flavor access support.', - 'alias': 'os-flavor-access'} + 'alias': 'os-flavor-access'}, + {'name': 'Keypairs', + 'description': 'Keypair Support.', + 'alias': 'os-keypairs'} ] diff --git a/nova/api/openstack/compute/keypairs.py b/nova/api/openstack/compute/keypairs.py index c9f6f733c249..585854c6ba60 100644 --- a/nova/api/openstack/compute/keypairs.py +++ b/nova/api/openstack/compute/keypairs.py @@ -32,9 +32,6 @@ from nova.objects import keypair as keypair_obj from nova.policies import keypairs as kp_policies -ALIAS = 'os-keypairs' - - class KeypairController(wsgi.Controller): """Keypair API controller for the OpenStack API.""" @@ -323,25 +320,6 @@ class Controller(wsgi.Controller): self._add_key_name(req, servers) -class Keypairs(extensions.V21APIExtensionBase): - """Keypair Support.""" - - name = "Keypairs" - alias = ALIAS - version = 1 - - def get_resources(self): - resources = [ - extensions.ResourceExtension(ALIAS, - KeypairController())] - return resources - - def get_controller_extensions(self): - controller = Controller() - extension = extensions.ControllerExtension(self, 'servers', controller) - return [extension] - - # use nova.api.extensions.server.extensions entry point to modify # server create kwargs # NOTE(gmann): This function is not supposed to use 'body_deprecated_param' diff --git a/nova/api/openstack/compute/routes.py b/nova/api/openstack/compute/routes.py index 0b6ac4e625de..262ae2f8b7af 100644 --- a/nova/api/openstack/compute/routes.py +++ b/nova/api/openstack/compute/routes.py @@ -71,6 +71,10 @@ def _create_controller(main_controller, controller_list, return controller +keypairs_controller = functools.partial( + _create_controller, keypairs.KeypairController, [], []) + + flavor_controller = functools.partial(_create_controller, flavors.FlavorsController, [ @@ -170,6 +174,14 @@ ROUTE_LIST = ( ('/flavors/{flavor_id}/os-flavor-access', { 'GET': [flavor_access_controller, 'index'] }), + ('/os-keypairs', { + 'GET': [keypairs_controller, 'index'], + 'POST': [keypairs_controller, 'create'] + }), + ('/os-keypairs/{id}', { + 'GET': [keypairs_controller, 'show'], + 'DELETE': [keypairs_controller, 'delete'] + }), ('/os-volumes_boot', { 'GET': [server_controller, 'index'], 'POST': [server_controller, 'create'] diff --git a/setup.cfg b/setup.cfg index 7c16c605ce58..db81eeab4236 100644 --- a/setup.cfg +++ b/setup.cfg @@ -98,7 +98,6 @@ nova.api.v21.extensions = instance_actions = nova.api.openstack.compute.instance_actions:InstanceActions instance_usage_audit_log = nova.api.openstack.compute.instance_usage_audit_log:InstanceUsageAuditLog ips = nova.api.openstack.compute.ips:IPs - keypairs = nova.api.openstack.compute.keypairs:Keypairs limits = nova.api.openstack.compute.limits:Limits migrations = nova.api.openstack.compute.migrations:Migrations multiple_create = nova.api.openstack.compute.multiple_create:MultipleCreate