From 891fe89fb5d7fb417973cc3814d41b86cc35b57d Mon Sep 17 00:00:00 2001 From: ghanshyam Date: Mon, 1 May 2017 20:31:17 +0300 Subject: [PATCH] Use plain routes list for os-agents endpoint instead of stevedore This patch adds os-agents 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: Ie34c861cdcab5ae7ea73e8c00e9c190ae6a32a94 --- nova/api/openstack/compute/agents.py | 22 -------------------- nova/api/openstack/compute/extension_info.py | 4 ++++ nova/api/openstack/compute/routes.py | 13 ++++++++++++ setup.cfg | 1 - 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/nova/api/openstack/compute/agents.py b/nova/api/openstack/compute/agents.py index b1450fc681..489c85a920 100644 --- a/nova/api/openstack/compute/agents.py +++ b/nova/api/openstack/compute/agents.py @@ -25,9 +25,6 @@ from nova.policies import agents as agents_policies from nova import utils -ALIAS = "os-agents" - - class AgentController(wsgi.Controller): """The agent is talking about guest agent.The host can use this for things like accessing files on the disk, configuring networking, @@ -166,22 +163,3 @@ class AgentController(wsgi.Controller): except exception.AgentBuildExists as ex: raise webob.exc.HTTPConflict(explanation=ex.format_message()) return {'agent': agent} - - -class Agents(extensions.V21APIExtensionBase): - """Agents support.""" - - name = "Agents" - alias = ALIAS - version = 1 - - def get_resources(self): - resource = [extensions.ResourceExtension(ALIAS, - AgentController())] - return resource - - 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 6492941c15..de6384ac59 100644 --- a/nova/api/openstack/compute/extension_info.py +++ b/nova/api/openstack/compute/extension_info.py @@ -169,6 +169,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': 'Agents', + 'alias': 'os-agents', + 'description': 'Agents support.' + }, {'name': 'Aggregates', 'alias': 'os-aggregates', 'description': 'Admin-only aggregate administration.' diff --git a/nova/api/openstack/compute/routes.py b/nova/api/openstack/compute/routes.py index 0077117167..129843bab8 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 agents from nova.api.openstack.compute import aggregates from nova.api.openstack.compute import config_drive from nova.api.openstack.compute import console_output @@ -75,6 +76,10 @@ def _create_controller(main_controller, controller_list, return controller +agents_controller = functools.partial( + _create_controller, agents.AgentController, [], []) + + aggregates_controller = functools.partial( _create_controller, aggregates.AggregateController, [], []) @@ -202,6 +207,14 @@ ROUTE_LIST = ( ('/flavors/{flavor_id}/os-flavor-access', { 'GET': [flavor_access_controller, 'index'] }), + ('/os-agents', { + 'GET': [agents_controller, 'index'], + 'POST': [agents_controller, 'create'] + }), + ('/os-agents/{id}', { + 'PUT': [agents_controller, 'update'], + 'DELETE': [agents_controller, 'delete'] + }), ('/os-aggregates', { 'GET': [aggregates_controller, 'index'], 'POST': [aggregates_controller, 'create'] diff --git a/setup.cfg b/setup.cfg index 8433c039bb..060a357baf 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 = - agents = nova.api.openstack.compute.agents:Agents 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