From 41f60f97fd2b99f81dd78a25b3fee040b99ae0d3 Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Tue, 2 May 2017 13:53:24 +0800 Subject: [PATCH] Use plain routes list for server-tags instead of stevedore This patch adds server-tags 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: Iee90d82d73db849b453830d2a5e6acd5c7afb1aa --- nova/api/openstack/compute/routes.py | 15 ++++++++++++++ nova/api/openstack/compute/server_tags.py | 25 ----------------------- setup.cfg | 1 - 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/nova/api/openstack/compute/routes.py b/nova/api/openstack/compute/routes.py index 0e3a4acf26..0ca1388617 100644 --- a/nova/api/openstack/compute/routes.py +++ b/nova/api/openstack/compute/routes.py @@ -60,6 +60,7 @@ 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_tags from nova.api.openstack.compute import server_usage from nova.api.openstack.compute import servers from nova.api.openstack.compute import shelve @@ -225,6 +226,10 @@ server_password_controller = functools.partial(_create_controller, server_password.ServerPasswordController, [], []) +server_tags_controller = functools.partial(_create_controller, + server_tags.ServerTagsController, [], []) + + simple_tenant_usage_controller = functools.partial(_create_controller, simple_tenant_usage.SimpleTenantUsageController, [], []) @@ -437,6 +442,16 @@ ROUTE_LIST = ( 'GET': [server_password_controller, 'index'], 'DELETE': [server_password_controller, 'clear'] }), + ('/servers/{server_id}/tags', { + 'GET': [server_tags_controller, 'index'], + 'PUT': [server_tags_controller, 'update_all'], + 'DELETE': [server_tags_controller, 'delete_all'], + }), + ('/servers/{server_id}/tags/{id}', { + 'GET': [server_tags_controller, 'show'], + 'PUT': [server_tags_controller, 'update'], + 'DELETE': [server_tags_controller, 'delete'] + }), ) diff --git a/nova/api/openstack/compute/server_tags.py b/nova/api/openstack/compute/server_tags.py index 4444a67cd4..5ee6a780fc 100644 --- a/nova/api/openstack/compute/server_tags.py +++ b/nova/api/openstack/compute/server_tags.py @@ -29,9 +29,6 @@ from nova import objects from nova.policies import server_tags as st_policies -ALIAS = "os-server-tags" - - def _get_tags_names(tags): return [t.tag for t in tags] @@ -203,25 +200,3 @@ class ServerTagsController(wsgi.Controller): objects.TagList.destroy(cctxt, server_id) except exception.InstanceNotFound as e: raise webob.exc.HTTPNotFound(explanation=e.format_message()) - - -class ServerTags(extensions.V21APIExtensionBase): - """Server tags support.""" - - name = "ServerTags" - alias = ALIAS - version = 1 - - def get_controller_extensions(self): - return [] - - def get_resources(self): - res = extensions.ResourceExtension('tags', - ServerTagsController(), - parent=dict( - member_name='server', - collection_name='servers'), - collection_actions={ - 'delete_all': 'DELETE', - 'update_all': 'PUT'}) - return [res] diff --git a/setup.cfg b/setup.cfg index 71ef2f8c37..5b2f6a04e5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -97,7 +97,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_tags = nova.api.openstack.compute.server_tags:ServerTags 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