From 10462fc74462b08f53432b8feb8cafab4a603c9d Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Thu, 1 Jun 2017 11:48:34 +0100 Subject: [PATCH] Use plain routes list for server ips endpoint This patch adds server ips 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: I4c0a023ab295cdb0c71ff4800f288946215745ce --- nova/api/openstack/compute/ips.py | 22 ---------------------- nova/api/openstack/compute/routes.py | 11 +++++++++++ setup.cfg | 1 - 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/nova/api/openstack/compute/ips.py b/nova/api/openstack/compute/ips.py index 61fc3aee6f..73f0f3d4f6 100644 --- a/nova/api/openstack/compute/ips.py +++ b/nova/api/openstack/compute/ips.py @@ -23,8 +23,6 @@ from nova.api.openstack import wsgi from nova.i18n import _ from nova.policies import ips as ips_policies -ALIAS = 'ips' - class IPsController(wsgi.Controller): """The servers addresses API controller for the OpenStack API.""" @@ -57,23 +55,3 @@ class IPsController(wsgi.Controller): raise exc.HTTPNotFound(explanation=msg) return self._view_builder.show(networks[id], id) - - -class IPs(extensions.V21APIExtensionBase): - """Server addresses.""" - - name = "Ips" - alias = ALIAS - version = 1 - - def get_resources(self): - parent = {'member_name': 'server', - 'collection_name': 'servers'} - resources = [ - extensions.ResourceExtension( - ALIAS, IPsController(), parent=parent, member_name='ip')] - - return resources - - def get_controller_extensions(self): - return [] diff --git a/nova/api/openstack/compute/routes.py b/nova/api/openstack/compute/routes.py index a9da011782..4779a6899f 100644 --- a/nova/api/openstack/compute/routes.py +++ b/nova/api/openstack/compute/routes.py @@ -47,6 +47,7 @@ from nova.api.openstack.compute import floating_ips from nova.api.openstack.compute import floating_ips_bulk from nova.api.openstack.compute import hide_server_addresses from nova.api.openstack.compute import instance_usage_audit_log +from nova.api.openstack.compute import ips from nova.api.openstack.compute import keypairs from nova.api.openstack.compute import limits from nova.api.openstack.compute import lock_server @@ -163,6 +164,10 @@ instance_usage_audit_log_controller = functools.partial(_create_controller, instance_usage_audit_log.InstanceUsageAuditLogController, [], []) +ips_controller = functools.partial(_create_controller, + ips.IPsController, [], []) + + keypairs_controller = functools.partial( _create_controller, keypairs.KeypairController, [], []) @@ -441,6 +446,12 @@ ROUTE_LIST = ( ('/servers/{server_id}/diagnostics', { 'GET': [server_diagnostics_controller, 'index'] }), + ('/servers/{server_id}/ips', { + 'GET': [ips_controller, 'index'] + }), + ('/servers/{server_id}/ips/{id}', { + 'GET': [ips_controller, 'show'] + }), ('/servers/{server_id}/metadata', { 'GET': [server_metadata_controller, 'index'], 'POST': [server_metadata_controller, 'create'], diff --git a/setup.cfg b/setup.cfg index 495dd9ca68..9bd88c09b8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -86,7 +86,6 @@ nova.api.v21.extensions = image_metadata = nova.api.openstack.compute.image_metadata:ImageMetadata image_size = nova.api.openstack.compute.image_size:ImageSize instance_actions = nova.api.openstack.compute.instance_actions:InstanceActions - ips = nova.api.openstack.compute.ips:IPs multiple_create = nova.api.openstack.compute.multiple_create:MultipleCreate networks = nova.api.openstack.compute.networks:Networks networks_associate = nova.api.openstack.compute.networks_associate:NetworksAssociate