Use plain routes list for os-quota-classes endpoint instead of stevedore

This patch adds os-quota-classes 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.

Because of os-server-group-quotas is never loaded, we can safely removed
the logic check for server-group data and possibily return it though a
microversion update if needed.

Partial-implement-blueprint api-no-more-extensions-pike

Change-Id: I34c776bedc0bc5fc0ef4d29dd3b8f84e914d83e2
This commit is contained in:
jichenjc 2017-04-28 21:57:48 +08:00 committed by Stephen Finucane
parent bc4c91e7be
commit ceed63ff7d
3 changed files with 12 additions and 24 deletions

View File

@ -28,7 +28,6 @@ from nova import utils
QUOTAS = quota.QUOTAS
ALIAS = "os-quota-class-sets"
# Quotas that are only enabled by specific extensions
EXTENDED_QUOTAS = {'server_groups': 'os-server-group-quotas',
@ -41,10 +40,10 @@ class QuotaClassSetsController(wsgi.Controller):
def __init__(self, **kwargs):
self.supported_quotas = QUOTAS.resources
extension_info = kwargs.pop('extension_info').get_extensions()
# TODO(jichenjc): need fix v2 and v2.1 API difference here see bug
# 1693168 for more info
for resource, extension in EXTENDED_QUOTAS.items():
if extension not in extension_info:
self.supported_quotas.remove(resource)
self.supported_quotas.remove(resource)
def _format_quota_set(self, quota_class, quota_set):
"""Convert the quota object to a result dict."""
@ -89,22 +88,3 @@ class QuotaClassSetsController(wsgi.Controller):
values = QUOTAS.get_class_quotas(context, quota_class)
return self._format_quota_set(None, values)
class QuotaClasses(extensions.V21APIExtensionBase):
"""Quota classes management support."""
name = "QuotaClasses"
alias = ALIAS
version = 1
def get_resources(self):
resources = []
res = extensions.ResourceExtension(
ALIAS,
QuotaClassSetsController(extension_info=self.extension_info))
resources.append(res)
return resources
def get_controller_extensions(self):
return []

View File

@ -61,6 +61,7 @@ from nova.api.openstack.compute import migrate_server
from nova.api.openstack.compute import migrations
from nova.api.openstack.compute import multinic
from nova.api.openstack.compute import pause_server
from nova.api.openstack.compute import quota_classes
from nova.api.openstack.compute import quota_sets
from nova.api.openstack.compute import remote_consoles
from nova.api.openstack.compute import rescue
@ -209,6 +210,10 @@ migrations_controller = functools.partial(_create_controller,
migrations.MigrationsController, [], [])
quota_classes_controller = functools.partial(_create_controller,
quota_classes.QuotaClassSetsController, [], [])
quota_set_controller = functools.partial(_create_controller,
quota_sets.QuotaSetsController, [], [])
@ -484,6 +489,10 @@ ROUTE_LIST = (
('/os-migrations', {
'GET': [migrations_controller, 'index']
}),
('/os-quota-class-sets/{id}', {
'GET': [quota_classes_controller, 'show'],
'PUT': [quota_classes_controller, 'update']
}),
('/os-quota-sets/{id}', {
'GET': [quota_set_controller, 'show'],
'PUT': [quota_set_controller, 'update'],

View File

@ -82,7 +82,6 @@ nova.api.v21.extensions =
multiple_create = nova.api.openstack.compute.multiple_create:MultipleCreate
networks = nova.api.openstack.compute.networks:Networks
networks_associate = nova.api.openstack.compute.networks_associate:NetworksAssociate
quota_classes = nova.api.openstack.compute.quota_classes:QuotaClasses
remote_consoles = nova.api.openstack.compute.remote_consoles:RemoteConsoles
security_group_default_rules = nova.api.openstack.compute.security_group_default_rules:SecurityGroupDefaultRules
security_groups = nova.api.openstack.compute.security_groups:SecurityGroups