Use plain routes list for hosts endpoint instead of stevedore

This patch adds hosts 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: I1a205faab6f34158744436e79ae2ed9f80132b58
This commit is contained in:
jichenjc
2017-03-28 23:54:16 +08:00
committed by He Jie Xu
parent b9a055971e
commit 1f7f4fceef
3 changed files with 21 additions and 20 deletions
-19
View File
@@ -31,7 +31,6 @@ from nova import objects
from nova.policies import hosts as hosts_policies
LOG = logging.getLogger(__name__)
ALIAS = 'os-hosts'
class HostController(wsgi.Controller):
@@ -289,21 +288,3 @@ class HostController(wsgi.Controller):
for resource in six.itervalues(by_proj_resources):
resources.append({'resource': resource})
return {'host': resources}
class Hosts(extensions.V21APIExtensionBase):
"""Admin-only host administration."""
name = "Hosts"
alias = ALIAS
version = 1
def get_resources(self):
resources = [extensions.ResourceExtension(ALIAS,
HostController(),
member_actions={"startup": "GET", "shutdown": "GET",
"reboot": "GET"})]
return resources
def get_controller_extensions(self):
return []
+21
View File
@@ -47,6 +47,7 @@ from nova.api.openstack.compute import floating_ips
from nova.api.openstack.compute import floating_ips_bulk
from nova.api.openstack.compute import fping
from nova.api.openstack.compute import hide_server_addresses
from nova.api.openstack.compute import hosts
from nova.api.openstack.compute import instance_actions
from nova.api.openstack.compute import instance_usage_audit_log
from nova.api.openstack.compute import ips
@@ -166,6 +167,10 @@ fping_controller = functools.partial(_create_controller,
fping.FpingController, [], [])
hosts_controller = functools.partial(
_create_controller, hosts.HostController, [], [])
instance_actions_controller = functools.partial(_create_controller,
instance_actions.InstanceActionsController, [], [])
@@ -392,6 +397,22 @@ ROUTE_LIST = (
('/os-fping/{id}', {
'GET': [fping_controller, 'show']
}),
('/os-hosts', {
'GET': [hosts_controller, 'index']
}),
('/os-hosts/{id}', {
'GET': [hosts_controller, 'show'],
'PUT': [hosts_controller, 'update']
}),
('/os-hosts/{id}/reboot', {
'GET': [hosts_controller, 'reboot']
}),
('/os-hosts/{id}/shutdown', {
'GET': [hosts_controller, 'shutdown']
}),
('/os-hosts/{id}/startup', {
'GET': [hosts_controller, 'startup']
}),
('/os-instance_usage_audit_log', {
'GET': [instance_usage_audit_log_controller, 'index']
}),
-1
View File
@@ -79,7 +79,6 @@ nova.api.v21.extensions =
console_auth_tokens = nova.api.openstack.compute.console_auth_tokens:ConsoleAuthTokens
consoles = nova.api.openstack.compute.consoles:Consoles
extension_info = nova.api.openstack.compute.extension_info:ExtensionInfo
hosts = nova.api.openstack.compute.hosts:Hosts
hypervisors = nova.api.openstack.compute.hypervisors:Hypervisors
images = nova.api.openstack.compute.images:Images
image_metadata = nova.api.openstack.compute.image_metadata:ImageMetadata