From 01e3fa92467ba5978b5c0719268ce54d926bd7e1 Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Wed, 26 Apr 2017 15:52:22 +0800 Subject: [PATCH] Use plain routes list for os-interface endpoint instead of stevedore This patch adds os-interface 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: I4afbc20e60bb8d324027903879d60f808595dac1 --- .../openstack/compute/attach_interfaces.py | 25 ------------------- nova/api/openstack/compute/routes.py | 13 ++++++++++ setup.cfg | 1 - 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/nova/api/openstack/compute/attach_interfaces.py b/nova/api/openstack/compute/attach_interfaces.py index 68e072c895..1da9ccbe92 100644 --- a/nova/api/openstack/compute/attach_interfaces.py +++ b/nova/api/openstack/compute/attach_interfaces.py @@ -30,9 +30,6 @@ from nova import network from nova.policies import attach_interfaces as ai_policies -ALIAS = 'os-attach-interfaces' - - def _translate_interface_attachment_view(port_info): """Maps keys for interface attachment details view.""" return { @@ -177,25 +174,3 @@ class InterfaceAttachmentController(wsgi.Controller): except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'detach_interface', server_id) - - -class AttachInterfaces(extensions.V21APIExtensionBase): - """Attach interface support.""" - - name = "AttachInterfaces" - alias = ALIAS - version = 1 - - def get_resources(self): - res = [extensions.ResourceExtension('os-interface', - InterfaceAttachmentController(), - parent=dict( - member_name='server', - collection_name='servers'))] - return res - - def get_controller_extensions(self): - """It's an abstract function V21APIExtensionBase and the extension - will not be loaded without it. - """ - return [] diff --git a/nova/api/openstack/compute/routes.py b/nova/api/openstack/compute/routes.py index 7b53cc12fe..0e3a4acf26 100644 --- a/nova/api/openstack/compute/routes.py +++ b/nova/api/openstack/compute/routes.py @@ -22,6 +22,7 @@ from nova.api.openstack.compute import admin_password from nova.api.openstack.compute import agents from nova.api.openstack.compute import aggregates from nova.api.openstack.compute import assisted_volume_snapshots +from nova.api.openstack.compute import attach_interfaces from nova.api.openstack.compute import availability_zone from nova.api.openstack.compute import certificates from nova.api.openstack.compute import config_drive @@ -216,6 +217,10 @@ server_metadata_controller = functools.partial(_create_controller, server_metadata.ServerMetadataController, [], []) +server_os_interface_controller = functools.partial(_create_controller, + attach_interfaces.InterfaceAttachmentController, [], []) + + server_password_controller = functools.partial(_create_controller, server_password.ServerPasswordController, [], []) @@ -420,6 +425,14 @@ ROUTE_LIST = ( 'PUT': [server_metadata_controller, 'update'], 'DELETE': [server_metadata_controller, 'delete'], }), + ('/servers/{server_id}/os-interface', { + 'GET': [server_os_interface_controller, 'index'], + 'POST': [server_os_interface_controller, 'create'] + }), + ('/servers/{server_id}/os-interface/{id}', { + 'GET': [server_os_interface_controller, 'show'], + 'DELETE': [server_os_interface_controller, 'delete'] + }), ('/servers/{server_id}/os-server-password', { 'GET': [server_password_controller, 'index'], 'DELETE': [server_password_controller, 'clear'] diff --git a/setup.cfg b/setup.cfg index 3faab7c92c..71ef2f8c37 100644 --- a/setup.cfg +++ b/setup.cfg @@ -72,7 +72,6 @@ wsgi_scripts = nova-metadata-wsgi = nova.api.metadata.wsgi:init_application nova.api.v21.extensions = - attach_interfaces = nova.api.openstack.compute.attach_interfaces:AttachInterfaces baremetal_nodes = nova.api.openstack.compute.baremetal_nodes:BareMetalNodes block_device_mapping = nova.api.openstack.compute.block_device_mapping:BlockDeviceMapping cells = nova.api.openstack.compute.cells:Cells