Use plain routes list for os-networks instead of stevedore

This patch adds os-networks 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: I49a424979394d0de7d8eae564468e29ee94b8bfa
This commit is contained in:
ghanshyam
2017-06-19 16:46:27 +01:00
committed by He Jie Xu
parent 408fcfd604
commit 53393ca27e
4 changed files with 21 additions and 43 deletions

View File

@@ -31,8 +31,6 @@ from nova.objects import base as base_obj
from nova.objects import fields as obj_fields
from nova.policies import networks as net_policies
ALIAS = 'os-networks'
def network_dict(context, network):
fields = ('id', 'cidr', 'netmask', 'gateway', 'broadcast', 'dns1', 'dns2',
@@ -182,23 +180,3 @@ class NetworkController(wsgi.Controller):
except (exception.NoMoreNetworks,
exception.NetworkNotFoundForUUID) as e:
raise exc.HTTPBadRequest(explanation=e.format_message())
class Networks(extensions.V21APIExtensionBase):
"""Admin-only Network Management Extension."""
name = "Networks"
alias = ALIAS
version = 1
def get_resources(self):
member_actions = {'action': 'POST'}
collection_actions = {'add': 'POST'}
res = extensions.ResourceExtension(
ALIAS, NetworkController(),
member_actions=member_actions,
collection_actions=collection_actions)
return [res]
def get_controller_extensions(self):
return []

View File

@@ -24,8 +24,6 @@ from nova.i18n import _
from nova import network
from nova.policies import networks_associate as na_policies
ALIAS = "os-networks-associate"
class NetworkAssociateActionController(wsgi.Controller):
"""Network Association API Controller."""
@@ -80,20 +78,3 @@ class NetworkAssociateActionController(wsgi.Controller):
raise exc.HTTPNotFound(explanation=msg)
except NotImplementedError:
common.raise_feature_not_supported()
class NetworksAssociate(extensions.V21APIExtensionBase):
"""Network association support."""
name = "NetworkAssociationSupport"
alias = ALIAS
version = 1
def get_controller_extensions(self):
extension = extensions.ControllerExtension(
self, 'os-networks', NetworkAssociateActionController())
return [extension]
def get_resources(self):
return []

View File

@@ -62,6 +62,8 @@ from nova.api.openstack.compute import lock_server
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 networks
from nova.api.openstack.compute import networks_associate
from nova.api.openstack.compute import pause_server
from nova.api.openstack.compute import quota_classes
from nova.api.openstack.compute import quota_sets
@@ -221,6 +223,11 @@ migrations_controller = functools.partial(_create_controller,
migrations.MigrationsController, [], [])
networks_controller = functools.partial(_create_controller,
networks.NetworkController, [],
[networks_associate.NetworkAssociateActionController])
quota_classes_controller = functools.partial(_create_controller,
quota_classes.QuotaClassSetsController, [], [])
@@ -539,6 +546,20 @@ ROUTE_LIST = (
('/os-migrations', {
'GET': [migrations_controller, 'index']
}),
('/os-networks', {
'GET': [networks_controller, 'index'],
'POST': [networks_controller, 'create']
}),
('/os-networks/add', {
'POST': [networks_controller, 'add']
}),
('/os-networks/{id}', {
'GET': [networks_controller, 'show'],
'DELETE': [networks_controller, 'delete']
}),
('/os-networks/{id}/action', {
'POST': [networks_controller, 'action'],
}),
('/os-quota-class-sets/{id}', {
'GET': [quota_classes_controller, 'show'],
'PUT': [quota_classes_controller, 'update']

View File

@@ -77,8 +77,6 @@ nova.api.v21.extensions =
images = nova.api.openstack.compute.images:Images
image_metadata = nova.api.openstack.compute.image_metadata:ImageMetadata
image_size = nova.api.openstack.compute.image_size:ImageSize
networks = nova.api.openstack.compute.networks:Networks
networks_associate = nova.api.openstack.compute.networks_associate:NetworksAssociate
security_group_default_rules = nova.api.openstack.compute.security_group_default_rules:SecurityGroupDefaultRules
security_groups = nova.api.openstack.compute.security_groups:SecurityGroups
versions = nova.api.openstack.compute.versionsV21:Versions