Redirect ExtensionDescriptor to neutron-lib
Preliminary step in adopting ExtensionDescriptor from neutron-lib. This switches to using the ExtensionDescriptor class from neutron-lib. In this step we provide a redirector so that subprojects do not break. In follow-up patches, all subprojects will switch to using neutron-lib directly, and then the redirector will be removed from neutron core. Change-Id: I5a111e0033e518e39b3042f047ee9eebba77a0d5
This commit is contained in:
parent
bc852b379c
commit
8b0bdbea83
|
@ -18,6 +18,7 @@ import collections
|
|||
import imp
|
||||
import os
|
||||
|
||||
from neutron_lib.api import extensions as api_extensions
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
@ -84,135 +85,9 @@ class PluginInterface(object):
|
|||
return True
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class ExtensionDescriptor(object):
|
||||
"""Base class that defines the contract for extensions."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_name(self):
|
||||
"""The name of the extension.
|
||||
|
||||
e.g. 'Fox In Socks'
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_alias(self):
|
||||
"""The alias for the extension.
|
||||
|
||||
e.g. 'FOXNSOX'
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_description(self):
|
||||
"""Friendly description for the extension.
|
||||
|
||||
e.g. 'The Fox In Socks Extension'
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_updated(self):
|
||||
"""The timestamp when the extension was last updated.
|
||||
|
||||
e.g. '2011-01-22T13:25:27-06:00'
|
||||
"""
|
||||
# NOTE(justinsb): Not sure of the purpose of this is, vs the XML NS
|
||||
|
||||
def get_resources(self):
|
||||
"""List of extensions.ResourceExtension extension objects.
|
||||
|
||||
Resources define new nouns, and are accessible through URLs.
|
||||
"""
|
||||
resources = []
|
||||
return resources
|
||||
|
||||
def get_actions(self):
|
||||
"""List of extensions.ActionExtension extension objects.
|
||||
|
||||
Actions are verbs callable from the API.
|
||||
"""
|
||||
actions = []
|
||||
return actions
|
||||
|
||||
def get_request_extensions(self):
|
||||
"""List of extensions.RequestException extension objects.
|
||||
|
||||
Request extensions are used to handle custom request data.
|
||||
"""
|
||||
request_exts = []
|
||||
return request_exts
|
||||
|
||||
def get_extended_resources(self, version):
|
||||
"""Retrieve extended resources or attributes for core resources.
|
||||
|
||||
Extended attributes are implemented by a core plugin similarly
|
||||
to the attributes defined in the core, and can appear in
|
||||
request and response messages. Their names are scoped with the
|
||||
extension's prefix. The core API version is passed to this
|
||||
function, which must return a
|
||||
map[<resource_name>][<attribute_name>][<attribute_property>]
|
||||
specifying the extended resource attribute properties required
|
||||
by that API version.
|
||||
|
||||
Extension can add resources and their attr definitions too.
|
||||
The returned map can be integrated into RESOURCE_ATTRIBUTE_MAP.
|
||||
"""
|
||||
return {}
|
||||
|
||||
def get_plugin_interface(self):
|
||||
"""Returns an abstract class which defines contract for the plugin.
|
||||
|
||||
The abstract class should inherit from extensions.PluginInterface,
|
||||
Methods in this abstract class should be decorated as abstractmethod
|
||||
"""
|
||||
return None
|
||||
|
||||
def get_required_extensions(self):
|
||||
"""Returns a list of extensions to be processed before this one."""
|
||||
return []
|
||||
|
||||
def get_optional_extensions(self):
|
||||
"""Returns a list of extensions to be processed before this one.
|
||||
|
||||
Unlike get_required_extensions. This will not fail the loading of
|
||||
the extension if one of these extensions is not present. This is
|
||||
useful for an extension that extends multiple resources across
|
||||
other extensions that should still work for the remaining extensions
|
||||
when one is missing.
|
||||
"""
|
||||
return []
|
||||
|
||||
def update_attributes_map(self, extended_attributes,
|
||||
extension_attrs_map=None):
|
||||
"""Update attributes map for this extension.
|
||||
|
||||
This is default method for extending an extension's attributes map.
|
||||
An extension can use this method and supplying its own resource
|
||||
attribute map in extension_attrs_map argument to extend all its
|
||||
attributes that needs to be extended.
|
||||
|
||||
If an extension does not implement update_attributes_map, the method
|
||||
does nothing and just return.
|
||||
"""
|
||||
if not extension_attrs_map:
|
||||
return
|
||||
|
||||
for resource, attrs in six.iteritems(extension_attrs_map):
|
||||
extended_attrs = extended_attributes.get(resource)
|
||||
if extended_attrs:
|
||||
attrs.update(extended_attrs)
|
||||
|
||||
def get_pecan_resources(self):
|
||||
"""List of PecanResourceExtension extension objects.
|
||||
|
||||
Resources define new nouns, and are accessible through URLs.
|
||||
The controllers associated with each instance of
|
||||
extensions.ResourceExtension should be a subclass of
|
||||
neutron.pecan_wsgi.controllers.utils.NeutronPecanController.
|
||||
|
||||
If a resource is defined in both get_resources and get_pecan_resources,
|
||||
the resource defined in get_pecan_resources will take precedence.
|
||||
"""
|
||||
return []
|
||||
# Temporary redirector to prevent subprojects from breaking.
|
||||
# TODO(HenryG): Remove once all subprojects are patched.
|
||||
ExtensionDescriptor = api_extensions.ExtensionDescriptor
|
||||
|
||||
|
||||
class ActionExtensionController(wsgi.Controller):
|
||||
|
|
Loading…
Reference in New Issue