use plain routes list for os-virtual-interfaces

This patch adds os-virtual-interfaces 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: I47ccef43e41da0a85bff3da71655c33b6fea4fe4
This commit is contained in:
Stephen Finucane 2017-06-06 15:48:39 +01:00 committed by He Jie Xu
parent f4e3a8c4f9
commit 50e825c861
3 changed files with 8 additions and 26 deletions

View File

@ -75,6 +75,7 @@ from nova.api.openstack.compute import shelve
from nova.api.openstack.compute import simple_tenant_usage from nova.api.openstack.compute import simple_tenant_usage
from nova.api.openstack.compute import suspend_server from nova.api.openstack.compute import suspend_server
from nova.api.openstack.compute import used_limits from nova.api.openstack.compute import used_limits
from nova.api.openstack.compute import virtual_interfaces
from nova.api.openstack import wsgi from nova.api.openstack import wsgi
import nova.conf import nova.conf
@ -274,6 +275,10 @@ simple_tenant_usage_controller = functools.partial(_create_controller,
simple_tenant_usage.SimpleTenantUsageController, [], []) simple_tenant_usage.SimpleTenantUsageController, [], [])
virtual_interfaces_controller = functools.partial(_create_controller,
virtual_interfaces.ServerVirtualInterfaceController, [], [])
# NOTE(alex_xu): This is structure of this route list as below: # NOTE(alex_xu): This is structure of this route list as below:
# ( # (
# ('Route path': { # ('Route path': {
@ -553,6 +558,9 @@ 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}/os-virtual-interfaces', {
'GET': [virtual_interfaces_controller, 'index']
}),
('/servers/{server_id}/tags', { ('/servers/{server_id}/tags', {
'GET': [server_tags_controller, 'index'], 'GET': [server_tags_controller, 'index'],
'PUT': [server_tags_controller, 'update_all'], 'PUT': [server_tags_controller, 'update_all'],

View File

@ -27,9 +27,6 @@ from nova import network
from nova.policies import virtual_interfaces as vif_policies from nova.policies import virtual_interfaces as vif_policies
ALIAS = 'os-virtual-interfaces'
def _translate_vif_summary_view(req, vif): def _translate_vif_summary_view(req, vif):
"""Maps keys for VIF summary view.""" """Maps keys for VIF summary view."""
d = {} d = {}
@ -77,25 +74,3 @@ class ServerVirtualInterfaceController(wsgi.Controller):
"""Returns the list of VIFs for a given instance.""" """Returns the list of VIFs for a given instance."""
return self._items(req, server_id, return self._items(req, server_id,
entity_maker=_translate_vif_summary_view) entity_maker=_translate_vif_summary_view)
class VirtualInterfaces(extensions.V21APIExtensionBase):
"""Virtual interface support."""
name = "VirtualInterfaces"
alias = ALIAS
version = 1
def get_resources(self):
resources = []
res = extensions.ResourceExtension(
ALIAS,
controller=ServerVirtualInterfaceController(),
parent=dict(member_name='server', collection_name='servers'))
resources.append(res)
return resources
def get_controller_extensions(self):
return []

View File

@ -94,7 +94,6 @@ nova.api.v21.extensions =
tenant_networks = nova.api.openstack.compute.tenant_networks:TenantNetworks tenant_networks = nova.api.openstack.compute.tenant_networks:TenantNetworks
user_data = nova.api.openstack.compute.user_data:UserData user_data = nova.api.openstack.compute.user_data:UserData
versions = nova.api.openstack.compute.versionsV21:Versions versions = nova.api.openstack.compute.versionsV21:Versions
virtual_interfaces = nova.api.openstack.compute.virtual_interfaces:VirtualInterfaces
volumes = nova.api.openstack.compute.volumes:Volumes volumes = nova.api.openstack.compute.volumes:Volumes
nova.api.v21.test_extensions = nova.api.v21.test_extensions =