From b8232dd25f91c78396badd35e757404e0b56c450 Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Sat, 1 Jul 2017 21:07:58 +0800 Subject: [PATCH] Use plain routes list for os-volumes instead of stevedore This patch adds os-volumes 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: Ie76ef6c78cf1d97629cdfa3ffc314a21cd4ddb69 --- nova/api/openstack/compute/routes.py | 16 ++++++++++++++++ nova/api/openstack/compute/volumes.py | 4 ---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/nova/api/openstack/compute/routes.py b/nova/api/openstack/compute/routes.py index 0853467574c8..3b45823b7905 100644 --- a/nova/api/openstack/compute/routes.py +++ b/nova/api/openstack/compute/routes.py @@ -91,6 +91,7 @@ from nova.api.openstack.compute import suspend_server from nova.api.openstack.compute import tenant_networks from nova.api.openstack.compute import used_limits from nova.api.openstack.compute import virtual_interfaces +from nova.api.openstack.compute import volumes from nova.api.openstack import wsgi import nova.conf @@ -365,6 +366,10 @@ virtual_interfaces_controller = functools.partial(_create_controller, virtual_interfaces.ServerVirtualInterfaceController, [], []) +volumes_controller = functools.partial(_create_controller, + volumes.VolumeController, [], []) + + # NOTE(alex_xu): This is structure of this route list as below: # ( # ('Route path': { @@ -696,6 +701,17 @@ ROUTE_LIST = ( 'GET': [tenant_networks_controller, 'show'], 'DELETE': [tenant_networks_controller, 'delete'] }), + ('/os-volumes', { + 'GET': [volumes_controller, 'index'], + 'POST': [volumes_controller, 'create'], + }), + ('/os-volumes/detail', { + 'GET': [volumes_controller, 'detail'], + }), + ('/os-volumes/{id}', { + 'GET': [volumes_controller, 'show'], + 'DELETE': [volumes_controller, 'delete'] + }), ('/os-volumes_boot', { 'GET': [server_controller, 'index'], 'POST': [server_controller, 'create'] diff --git a/nova/api/openstack/compute/volumes.py b/nova/api/openstack/compute/volumes.py index ca16b3750fc1..107b9e634ec5 100644 --- a/nova/api/openstack/compute/volumes.py +++ b/nova/api/openstack/compute/volumes.py @@ -602,10 +602,6 @@ class Volumes(extensions.V21APIExtensionBase): def get_resources(self): resources = [] - res = extensions.ResourceExtension( - ALIAS, VolumeController(), collection_actions={'detail': 'GET'}) - resources.append(res) - res = extensions.ResourceExtension('os-volume_attachments', VolumeAttachmentController(), parent=dict(