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
This commit is contained in:
He Jie Xu 2017-05-02 13:53:24 +08:00 committed by Stephen Finucane
parent 01e3fa9246
commit 41f60f97fd
3 changed files with 15 additions and 26 deletions

View File

@ -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 security_groups
from nova.api.openstack.compute import server_metadata from nova.api.openstack.compute import server_metadata
from nova.api.openstack.compute import server_password 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 server_usage
from nova.api.openstack.compute import servers from nova.api.openstack.compute import servers
from nova.api.openstack.compute import shelve from nova.api.openstack.compute import shelve
@ -225,6 +226,10 @@ server_password_controller = functools.partial(_create_controller,
server_password.ServerPasswordController, [], []) server_password.ServerPasswordController, [], [])
server_tags_controller = functools.partial(_create_controller,
server_tags.ServerTagsController, [], [])
simple_tenant_usage_controller = functools.partial(_create_controller, simple_tenant_usage_controller = functools.partial(_create_controller,
simple_tenant_usage.SimpleTenantUsageController, [], []) simple_tenant_usage.SimpleTenantUsageController, [], [])
@ -437,6 +442,16 @@ ROUTE_LIST = (
'GET': [server_password_controller, 'index'], 'GET': [server_password_controller, 'index'],
'DELETE': [server_password_controller, 'clear'] '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']
}),
) )

View File

@ -29,9 +29,6 @@ from nova import objects
from nova.policies import server_tags as st_policies from nova.policies import server_tags as st_policies
ALIAS = "os-server-tags"
def _get_tags_names(tags): def _get_tags_names(tags):
return [t.tag for t in tags] return [t.tag for t in tags]
@ -203,25 +200,3 @@ class ServerTagsController(wsgi.Controller):
objects.TagList.destroy(cctxt, server_id) objects.TagList.destroy(cctxt, server_id)
except exception.InstanceNotFound as e: except exception.InstanceNotFound as e:
raise webob.exc.HTTPNotFound(explanation=e.format_message()) 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]

View File

@ -97,7 +97,6 @@ nova.api.v21.extensions =
server_diagnostics = nova.api.openstack.compute.server_diagnostics:ServerDiagnostics server_diagnostics = nova.api.openstack.compute.server_diagnostics:ServerDiagnostics
server_external_events = nova.api.openstack.compute.server_external_events:ServerExternalEvents server_external_events = nova.api.openstack.compute.server_external_events:ServerExternalEvents
server_migrations = nova.api.openstack.compute.server_migrations:ServerMigrations 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 server_groups = nova.api.openstack.compute.server_groups:ServerGroups
services = nova.api.openstack.compute.services:Services services = nova.api.openstack.compute.services:Services
tenant_networks = nova.api.openstack.compute.tenant_networks:TenantNetworks tenant_networks = nova.api.openstack.compute.tenant_networks:TenantNetworks