From 564f14f4bc67463d1ef185909e12ab090f10495b Mon Sep 17 00:00:00 2001 From: ghanshyam Date: Mon, 1 May 2017 20:59:26 +0300 Subject: [PATCH] Use plain routes list for os-assisted-volume-snapshots endpoint This patch adds os-assisted-volume-snapshots 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: I1dabc1021e6899d5d5c293e3af3eccfba8d245e2 --- .../compute/assisted_volume_snapshots.py | 22 ------------------- nova/api/openstack/compute/extension_info.py | 4 ++++ nova/api/openstack/compute/routes.py | 12 ++++++++++ setup.cfg | 1 - 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/nova/api/openstack/compute/assisted_volume_snapshots.py b/nova/api/openstack/compute/assisted_volume_snapshots.py index 97052e346b7..b2f60933a4a 100644 --- a/nova/api/openstack/compute/assisted_volume_snapshots.py +++ b/nova/api/openstack/compute/assisted_volume_snapshots.py @@ -29,9 +29,6 @@ from nova.policies import assisted_volume_snapshots as avs_policies -ALIAS = 'os-assisted-volume-snapshots' - - class AssistedVolumeSnapshotsController(wsgi.Controller): """The Assisted volume snapshots API controller for the OpenStack API.""" @@ -96,22 +93,3 @@ def delete(self, req, id): # microversion, which we should just do in a single microversion # across all APIs when we fix status code wrinkles. raise exc.HTTPBadRequest(explanation=e.format_message()) - - -class AssistedVolumeSnapshots(extensions.V21APIExtensionBase): - """Assisted volume snapshots.""" - - name = "AssistedVolumeSnapshots" - alias = ALIAS - version = 1 - - def get_resources(self): - res = [extensions.ResourceExtension(ALIAS, - AssistedVolumeSnapshotsController())] - return res - - def get_controller_extensions(self): - """It's an abstract function V21APIExtensionBase and the extension - will not be loaded without it. - """ - return [] diff --git a/nova/api/openstack/compute/extension_info.py b/nova/api/openstack/compute/extension_info.py index de6384ac595..2fa678a3205 100644 --- a/nova/api/openstack/compute/extension_info.py +++ b/nova/api/openstack/compute/extension_info.py @@ -177,6 +177,10 @@ 'alias': 'os-aggregates', 'description': 'Admin-only aggregate administration.' }, + {'name': 'AssistedVolumeSnapshots', + 'alias': 'os-assisted-volume-snapshots', + 'description': 'Assisted volume snapshots.' + }, {'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 129843bab8c..bed453b6dc1 100644 --- a/nova/api/openstack/compute/routes.py +++ b/nova/api/openstack/compute/routes.py @@ -21,6 +21,7 @@ from nova.api.openstack.compute import admin_password from nova.api.openstack.compute import agents from nova.api.openstack.compute import aggregates +from nova.api.openstack.compute import assisted_volume_snapshots from nova.api.openstack.compute import config_drive from nova.api.openstack.compute import console_output from nova.api.openstack.compute import create_backup @@ -84,6 +85,11 @@ def _create_controller(main_controller, controller_list, _create_controller, aggregates.AggregateController, [], []) +assisted_volume_snapshots_controller = functools.partial( + _create_controller, + assisted_volume_snapshots.AssistedVolumeSnapshotsController, [], []) + + keypairs_controller = functools.partial( _create_controller, keypairs.KeypairController, [], []) @@ -227,6 +233,12 @@ def _create_controller(main_controller, controller_list, ('/os-aggregates/{id}/action', { 'POST': [aggregates_controller, 'action'], }), + ('/os-assisted-volume-snapshots', { + 'POST': [assisted_volume_snapshots_controller, 'create'] + }), + ('/os-assisted-volume-snapshots/{id}', { + 'DELETE': [assisted_volume_snapshots_controller, 'delete'] + }), ('/os-floating-ip-dns', { 'GET': [floating_ip_dns_controller, 'index'] }), diff --git a/setup.cfg b/setup.cfg index 060a357bafa..1cd7d7f4d7c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -72,7 +72,6 @@ wsgi_scripts = nova-api-wsgi = nova.api.openstack.compute.wsgi:init_application nova.api.v21.extensions = - 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 baremetal_nodes = nova.api.openstack.compute.baremetal_nodes:BareMetalNodes