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
This commit is contained in:
He Jie Xu
2017-04-14 11:25:04 +03:00
parent 45011b4f72
commit c20d52d1af
4 changed files with 16 additions and 24 deletions

View File

@@ -197,7 +197,10 @@ hardcoded_extensions = [
'alias': 'os-flavor-extra-specs'}, 'alias': 'os-flavor-extra-specs'},
{'name': 'FlavorAccess', {'name': 'FlavorAccess',
'description': 'Flavor access support.', 'description': 'Flavor access support.',
'alias': 'os-flavor-access'} 'alias': 'os-flavor-access'},
{'name': 'Keypairs',
'description': 'Keypair Support.',
'alias': 'os-keypairs'}
] ]

View File

@@ -32,9 +32,6 @@ from nova.objects import keypair as keypair_obj
from nova.policies import keypairs as kp_policies from nova.policies import keypairs as kp_policies
ALIAS = 'os-keypairs'
class KeypairController(wsgi.Controller): class KeypairController(wsgi.Controller):
"""Keypair API controller for the OpenStack API.""" """Keypair API controller for the OpenStack API."""
@@ -323,25 +320,6 @@ class Controller(wsgi.Controller):
self._add_key_name(req, servers) 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 # use nova.api.extensions.server.extensions entry point to modify
# server create kwargs # server create kwargs
# NOTE(gmann): This function is not supposed to use 'body_deprecated_param' # NOTE(gmann): This function is not supposed to use 'body_deprecated_param'

View File

@@ -71,6 +71,10 @@ def _create_controller(main_controller, controller_list,
return controller return controller
keypairs_controller = functools.partial(
_create_controller, keypairs.KeypairController, [], [])
flavor_controller = functools.partial(_create_controller, flavor_controller = functools.partial(_create_controller,
flavors.FlavorsController, flavors.FlavorsController,
[ [
@@ -170,6 +174,14 @@ ROUTE_LIST = (
('/flavors/{flavor_id}/os-flavor-access', { ('/flavors/{flavor_id}/os-flavor-access', {
'GET': [flavor_access_controller, 'index'] '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', { ('/os-volumes_boot', {
'GET': [server_controller, 'index'], 'GET': [server_controller, 'index'],
'POST': [server_controller, 'create'] 'POST': [server_controller, 'create']

View File

@@ -98,7 +98,6 @@ nova.api.v21.extensions =
instance_actions = nova.api.openstack.compute.instance_actions:InstanceActions instance_actions = nova.api.openstack.compute.instance_actions:InstanceActions
instance_usage_audit_log = nova.api.openstack.compute.instance_usage_audit_log:InstanceUsageAuditLog instance_usage_audit_log = nova.api.openstack.compute.instance_usage_audit_log:InstanceUsageAuditLog
ips = nova.api.openstack.compute.ips:IPs ips = nova.api.openstack.compute.ips:IPs
keypairs = nova.api.openstack.compute.keypairs:Keypairs
limits = nova.api.openstack.compute.limits:Limits limits = nova.api.openstack.compute.limits:Limits
migrations = nova.api.openstack.compute.migrations:Migrations migrations = nova.api.openstack.compute.migrations:Migrations
multiple_create = nova.api.openstack.compute.multiple_create:MultipleCreate multiple_create = nova.api.openstack.compute.multiple_create:MultipleCreate