From a72a36c0f6d5c5bd58bf1d0089f3cc60814a9b06 Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Fri, 14 Apr 2017 11:36:32 +0300 Subject: [PATCH] Use plain routes list for '/os-aggregates' endpoint instead of stevedore This patch adds '/os-aggregates' 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. Also note that the original 'ProjectMapper' use the 'routes.Mapper.resource' to create a set of routes for a resource which comform to the Atom publishing protocol. It includes some of URL mappings we didn't document before. This patch will remove those URL mappings. For the detail, please reference: http://lists.openstack.org/pipermail/openstack-dev/2017-March/114736.html Partial-implement-blueprint api-no-more-extensions-pike Change-Id: Ia41c096a579eb1a7c5b99bd6e9267ab4b7f81776 --- nova/api/openstack/compute/aggregates.py | 20 -------------------- nova/api/openstack/compute/extension_info.py | 4 ++++ nova/api/openstack/compute/routes.py | 17 +++++++++++++++++ setup.cfg | 1 - 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/nova/api/openstack/compute/aggregates.py b/nova/api/openstack/compute/aggregates.py index 344207c2ec..3bcd759349 100644 --- a/nova/api/openstack/compute/aggregates.py +++ b/nova/api/openstack/compute/aggregates.py @@ -30,8 +30,6 @@ from nova import exception from nova.i18n import _ from nova.policies import aggregates as aggr_policies -ALIAS = "os-aggregates" - def _get_context(req): return req.environ['nova.context'] @@ -224,21 +222,3 @@ class AggregateController(wsgi.Controller): or key in aggregate.obj_extra_fields) and (show_uuid or key != 'uuid')): yield key, getattr(aggregate, key) - - -class Aggregates(extensions.V21APIExtensionBase): - """Admin-only aggregate administration.""" - - name = "Aggregates" - alias = ALIAS - version = 1 - - def get_resources(self): - resources = [extensions.ResourceExtension( - ALIAS, - AggregateController(), - member_actions={'action': 'POST'})] - return resources - - def get_controller_extensions(self): - return [] diff --git a/nova/api/openstack/compute/extension_info.py b/nova/api/openstack/compute/extension_info.py index 0387bcaf9f..dcfc6b92e3 100644 --- a/nova/api/openstack/compute/extension_info.py +++ b/nova/api/openstack/compute/extension_info.py @@ -170,6 +170,10 @@ v21_to_v2_alias_mapping = { # completely from the code we're going to have a static list here to # keep the surface metadata the same. hardcoded_extensions = [ + {'name': 'Aggregates', + 'alias': 'os-aggregates', + 'description': 'Admin-only aggregate administration.' + }, {'name': 'DiskConfig', 'alias': 'os-disk-config', 'description': 'Disk Management Extension.'}, diff --git a/nova/api/openstack/compute/routes.py b/nova/api/openstack/compute/routes.py index 262ae2f8b7..75b2241cf4 100644 --- a/nova/api/openstack/compute/routes.py +++ b/nova/api/openstack/compute/routes.py @@ -19,6 +19,7 @@ import functools import nova.api.openstack from nova.api.openstack.compute import admin_actions from nova.api.openstack.compute import admin_password +from nova.api.openstack.compute import aggregates from nova.api.openstack.compute import config_drive from nova.api.openstack.compute import console_output from nova.api.openstack.compute import create_backup @@ -71,6 +72,10 @@ def _create_controller(main_controller, controller_list, return controller +aggregates_controller = functools.partial( + _create_controller, aggregates.AggregateController, [], []) + + keypairs_controller = functools.partial( _create_controller, keypairs.KeypairController, [], []) @@ -174,6 +179,18 @@ ROUTE_LIST = ( ('/flavors/{flavor_id}/os-flavor-access', { 'GET': [flavor_access_controller, 'index'] }), + ('/os-aggregates', { + 'GET': [aggregates_controller, 'index'], + 'POST': [aggregates_controller, 'create'] + }), + ('/os-aggregates/{id}', { + 'GET': [aggregates_controller, 'show'], + 'PUT': [aggregates_controller, 'update'], + 'DELETE': [aggregates_controller, 'delete'] + }), + ('/os-aggregates/{id}/action', { + 'POST': [aggregates_controller, 'action'], + }), ('/os-keypairs', { 'GET': [keypairs_controller, 'index'], 'POST': [keypairs_controller, 'create'] diff --git a/setup.cfg b/setup.cfg index db81eeab42..369bc8a5d7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -72,7 +72,6 @@ wsgi_scripts = nova.api.v21.extensions = agents = nova.api.openstack.compute.agents:Agents - aggregates = nova.api.openstack.compute.aggregates:Aggregates assisted_volume_snapshots = nova.api.openstack.compute.assisted_volume_snapshots:AssistedVolumeSnapshots attach_interfaces = nova.api.openstack.compute.attach_interfaces:AttachInterfaces availability_zone = nova.api.openstack.compute.availability_zone:AvailabilityZone