From 6501ba0eb46d875468fb54e2e7a26c62963f5e55 Mon Sep 17 00:00:00 2001 From: Kevin_Zheng Date: Wed, 3 May 2017 16:23:33 +0800 Subject: [PATCH] Use plain routes list for server-password endpoint instead of stevedore This patch adds server-password 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: Ic05b858fa5db711e0e755e6d7c2beaffbc9bc2b8 --- nova/api/openstack/compute/routes.py | 9 ++++++++ nova/api/openstack/compute/server_password.py | 22 ------------------- setup.cfg | 1 - 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/nova/api/openstack/compute/routes.py b/nova/api/openstack/compute/routes.py index d414f3970e..9930aa0eaa 100644 --- a/nova/api/openstack/compute/routes.py +++ b/nova/api/openstack/compute/routes.py @@ -54,6 +54,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_password from nova.api.openstack.compute import server_usage from nova.api.openstack.compute import servers from nova.api.openstack.compute import shelve @@ -190,6 +191,10 @@ server_metadata_controller = functools.partial(_create_controller, server_metadata.ServerMetadataController, [], []) +server_password_controller = functools.partial(_create_controller, + server_password.ServerPasswordController, [], []) + + simple_tenant_usage_controller = functools.partial(_create_controller, simple_tenant_usage.SimpleTenantUsageController, [], []) @@ -367,6 +372,10 @@ ROUTE_LIST = ( 'PUT': [server_metadata_controller, 'update'], 'DELETE': [server_metadata_controller, 'delete'], }), + ('/servers/{server_id}/os-server-password', { + 'GET': [server_password_controller, 'index'], + 'DELETE': [server_password_controller, 'clear'] + }), ) diff --git a/nova/api/openstack/compute/server_password.py b/nova/api/openstack/compute/server_password.py index c97c24bb15..4d9e25c649 100644 --- a/nova/api/openstack/compute/server_password.py +++ b/nova/api/openstack/compute/server_password.py @@ -23,9 +23,6 @@ from nova import compute from nova.policies import server_password as sp_policies -ALIAS = 'os-server-password' - - class ServerPasswordController(wsgi.Controller): """The Server Password API controller for the OpenStack API.""" def __init__(self): @@ -55,22 +52,3 @@ class ServerPasswordController(wsgi.Controller): meta = password.convert_password(context, None) instance.system_metadata.update(meta) instance.save() - - -class ServerPassword(extensions.V21APIExtensionBase): - """Server password support.""" - - name = "ServerPassword" - alias = ALIAS - version = 1 - - def get_resources(self): - resources = [ - extensions.ResourceExtension( - ALIAS, ServerPasswordController(), - collection_actions={'clear': 'DELETE'}, - parent=dict(member_name='server', collection_name='servers'))] - return resources - - def get_controller_extensions(self): - return [] diff --git a/setup.cfg b/setup.cfg index 99e68cd1c4..cd35a57951 100644 --- a/setup.cfg +++ b/setup.cfg @@ -102,7 +102,6 @@ nova.api.v21.extensions = 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_password = nova.api.openstack.compute.server_password:ServerPassword server_tags = nova.api.openstack.compute.server_tags:ServerTags server_groups = nova.api.openstack.compute.server_groups:ServerGroups services = nova.api.openstack.compute.services:Services