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
This commit is contained in:
ghanshyam 2017-05-01 20:31:17 +03:00
parent 58676763b9
commit 891fe89fb5
4 changed files with 17 additions and 23 deletions

View File

@ -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 []

View File

@ -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.'

View File

@ -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']

View File

@ -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