From 408fcfd6045dfa60422d0f602989a69163f5f74c Mon Sep 17 00:00:00 2001 From: jichenjc Date: Sun, 28 May 2017 11:39:27 +0800 Subject: [PATCH] Use plain routes list for os-cells endpoint instead of stevedore This patch adds os-cells 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: Iec6e720b4e225251ce06ddfecb316569f9260913 --- nova/api/openstack/compute/cells.py | 31 ---------------------------- nova/api/openstack/compute/routes.py | 29 ++++++++++++++++++++++++++ setup.cfg | 1 - 3 files changed, 29 insertions(+), 32 deletions(-) diff --git a/nova/api/openstack/compute/cells.py b/nova/api/openstack/compute/cells.py index 6e8eb653889..1e85e37140f 100644 --- a/nova/api/openstack/compute/cells.py +++ b/nova/api/openstack/compute/cells.py @@ -36,8 +36,6 @@ CONF = nova.conf.CONF -ALIAS = "os-cells" - def _filter_keys(item, keys): """Filters all model attributes except for keys @@ -303,32 +301,3 @@ def sync_instances(self, req, body): deleted = strutils.bool_from_string(deleted, strict=True) self.cells_rpcapi.sync_instances(context, project_id=project_id, updated_since=updated_since, deleted=deleted) - - -class Cells(extensions.V21APIExtensionBase): - """Enables cells-related functionality such as adding neighbor cells, - listing neighbor cells, and getting the capabilities of the local cell. - """ - - name = "Cells" - alias = ALIAS - version = 1 - - def get_resources(self): - coll_actions = { - 'detail': 'GET', - 'info': 'GET', - 'sync_instances': 'POST', - 'capacities': 'GET', - } - memb_actions = { - 'capacities': 'GET', - } - - res = extensions.ResourceExtension(ALIAS, CellsController(), - collection_actions=coll_actions, - member_actions=memb_actions) - return [res] - - def get_controller_extensions(self): - return [] diff --git a/nova/api/openstack/compute/routes.py b/nova/api/openstack/compute/routes.py index f094a9128c2..925c27d0641 100644 --- a/nova/api/openstack/compute/routes.py +++ b/nova/api/openstack/compute/routes.py @@ -24,6 +24,7 @@ from nova.api.openstack.compute import assisted_volume_snapshots from nova.api.openstack.compute import attach_interfaces from nova.api.openstack.compute import availability_zone +from nova.api.openstack.compute import cells from nova.api.openstack.compute import certificates from nova.api.openstack.compute import cloudpipe from nova.api.openstack.compute import config_drive @@ -123,6 +124,10 @@ def _create_controller(main_controller, controller_list, _create_controller, availability_zone.AvailabilityZoneController, [], []) +cells_controller = functools.partial( + _create_controller, cells.CellsController, [], []) + + certificates_controller = functools.partial( _create_controller, certificates.CertificatesController, [], []) @@ -397,6 +402,30 @@ def _create_controller(main_controller, controller_list, ('/os-availability-zone/detail', { 'GET': [availability_zone_controller, 'detail'], }), + ('/os-cells', { + 'POST': [cells_controller, 'create'], + 'GET': [cells_controller, 'index'], + }), + ('/os-cells/capacities', { + 'GET': [cells_controller, 'capacities'] + }), + ('/os-cells/detail', { + 'GET': [cells_controller, 'detail'] + }), + ('/os-cells/info', { + 'GET': [cells_controller, 'info'] + }), + ('/os-cells/sync_instances', { + 'POST': [cells_controller, 'sync_instances'] + }), + ('/os-cells/{id}', { + 'GET': [cells_controller, 'show'], + 'PUT': [cells_controller, 'update'], + 'DELETE': [cells_controller, 'delete'] + }), + ('/os-cells/{id}/capacities', { + 'GET': [cells_controller, 'capacities'] + }), ('/os-certificates', { 'POST': [certificates_controller, 'create'] }), diff --git a/setup.cfg b/setup.cfg index dacce26d2d2..d16b8100d27 100644 --- a/setup.cfg +++ b/setup.cfg @@ -73,7 +73,6 @@ wsgi_scripts = nova.api.v21.extensions = baremetal_nodes = nova.api.openstack.compute.baremetal_nodes:BareMetalNodes - cells = nova.api.openstack.compute.cells:Cells extension_info = nova.api.openstack.compute.extension_info:ExtensionInfo images = nova.api.openstack.compute.images:Images image_metadata = nova.api.openstack.compute.image_metadata:ImageMetadata