From 5bef8ec79c041e1a9742501d29c6f1aec637d7a5 Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Tue, 2 May 2017 14:00:47 +0800 Subject: [PATCH] Use plain routes list for server-migrations endpoint instead of stevedore This patch adds server-migrations 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: Idd8bd0b500db85826ee730e91f9f7e3e5667044e --- nova/api/openstack/compute/routes.py | 15 +++++++++++++ .../openstack/compute/server_migrations.py | 22 ------------------- setup.cfg | 1 - 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/nova/api/openstack/compute/routes.py b/nova/api/openstack/compute/routes.py index 0ca1388617..9b776d318a 100644 --- a/nova/api/openstack/compute/routes.py +++ b/nova/api/openstack/compute/routes.py @@ -59,6 +59,7 @@ from nova.api.openstack.compute import remote_consoles from nova.api.openstack.compute import rescue from nova.api.openstack.compute import security_groups from nova.api.openstack.compute import server_metadata +from nova.api.openstack.compute import server_migrations from nova.api.openstack.compute import server_password from nova.api.openstack.compute import server_tags from nova.api.openstack.compute import server_usage @@ -218,6 +219,10 @@ server_metadata_controller = functools.partial(_create_controller, server_metadata.ServerMetadataController, [], []) +server_migrations_controller = functools.partial(_create_controller, + server_migrations.ServerMigrationsController, [], []) + + server_os_interface_controller = functools.partial(_create_controller, attach_interfaces.InterfaceAttachmentController, [], []) @@ -430,6 +435,16 @@ ROUTE_LIST = ( 'PUT': [server_metadata_controller, 'update'], 'DELETE': [server_metadata_controller, 'delete'], }), + ('/servers/{server_id}/migrations', { + 'GET': [server_migrations_controller, 'index'] + }), + ('/servers/{server_id}/migrations/{id}', { + 'GET': [server_migrations_controller, 'show'], + 'DELETE': [server_migrations_controller, 'delete'] + }), + ('/servers/{server_id}/migrations/{id}/action', { + 'POST': [server_migrations_controller, 'action'] + }), ('/servers/{server_id}/os-interface', { 'GET': [server_os_interface_controller, 'index'], 'POST': [server_os_interface_controller, 'create'] diff --git a/nova/api/openstack/compute/server_migrations.py b/nova/api/openstack/compute/server_migrations.py index a39082860e..c0fd4c38b5 100644 --- a/nova/api/openstack/compute/server_migrations.py +++ b/nova/api/openstack/compute/server_migrations.py @@ -26,9 +26,6 @@ from nova.i18n import _ from nova.policies import servers_migrations as sm_policies -ALIAS = 'servers:migrations' - - def output(migration): """Returns the desired output of the API from an object. @@ -153,22 +150,3 @@ class ServerMigrationsController(wsgi.Controller): raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InvalidMigrationState as e: raise exc.HTTPBadRequest(explanation=e.format_message()) - - -class ServerMigrations(extensions.V21APIExtensionBase): - """Server Migrations API.""" - name = "ServerMigrations" - alias = 'server-migrations' - version = 1 - - def get_resources(self): - parent = {'member_name': 'server', - 'collection_name': 'servers'} - member_actions = {'action': 'POST'} - resources = [extensions.ResourceExtension( - 'migrations', ServerMigrationsController(), - parent=parent, member_actions=member_actions)] - return resources - - def get_controller_extensions(self): - return [] diff --git a/setup.cfg b/setup.cfg index 5b2f6a04e5..cdb83c62a0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -96,7 +96,6 @@ nova.api.v21.extensions = security_groups = nova.api.openstack.compute.security_groups:SecurityGroups server_diagnostics = nova.api.openstack.compute.server_diagnostics:ServerDiagnostics server_external_events = nova.api.openstack.compute.server_external_events:ServerExternalEvents - server_migrations = nova.api.openstack.compute.server_migrations:ServerMigrations server_groups = nova.api.openstack.compute.server_groups:ServerGroups services = nova.api.openstack.compute.services:Services tenant_networks = nova.api.openstack.compute.tenant_networks:TenantNetworks