# neutron_lib.api.extensions module

class neutron_lib.api.extensions.APIExtensionDescriptor

  Bases: `ExtensionDescriptor`

  Base class that defines the contract for extensions.

  Concrete implementations of API extensions should first provide an API definition in neutron_lib.api.definitions. The API definition module (object reference) can then be specified as a class level attribute on the concrete extension.

  For example:

      from neutron_lib.api.definitions import provider_net
      from neutron_lib.api import extensions

      class Providernet(extensions.APIExtensionDescriptor):
          api_definition = provider_net
          # nothing else needed if default behavior is acceptable

  If extension implementations need to override the default behavior of this class they can override the respective method directly.

  api_definition: Sentinel | object = <neutron_lib.constants.Sentinel object>
  classmethod get_alias()

    The alias for the API definition.

  classmethod get_description()

    Friendly description for the API definition.

  classmethod get_extended_resources(version)

    Retrieve the extended resource map for the API definition.

    Parameters:

      version – The API version to retrieve the resource attribute map for.

    Returns:

      The extended resource map for the underlying API definition if the version is 2.0. The extended resource map returned includes both the API definition’s RESOURCE_ATTRIBUTE_MAP and SUB_RESOURCE_ATTRIBUTE_MAP where applicable. If the version is not 2.0, an empty dict is returned.

  classmethod get_name()

    The name of the API definition.

  classmethod get_optional_extensions()

    Returns the API definition’s optional extensions.

  classmethod get_required_extensions()

    Returns the API definition’s required extensions.

  classmethod get_updated()

    The timestamp when the API definition was last updated.

  classmethod update_attributes_map(extended_attributes, extension_attrs_map=None)

    Update attributes map for this extension.

    Behaves like ExtensionDescriptor.update_attributes_map(), but if extension_attrs_map is not given the dict returned from self.get_extended_resources(‘2.0’) is used.

class neutron_lib.api.extensions.ExtensionDescriptor

  Bases: `object`

  Base class that defines the contract for extensions.

  get_actions()

    List of extensions.ActionExtension extension objects.

    Actions are verbs callable from the API.

  abstractmethod get_alias()

    The alias for the extension.

    e.g. ‘FOXNSOX’

  abstractmethod get_description()

    Friendly description for the extension.

    e.g. ‘The Fox In Socks Extension’

  get_extended_resources(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.

  abstractmethod get_name()

    The name of the extension.

    e.g. ‘Fox In Socks’

  get_optional_extensions()

    Returns a list of optionally required extensions.

    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.

  get_pecan_resources()

    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.

  get_plugin_interface()

    Returns an abstract class which defines contract for the plugin.

    The abstract class should inherit from neutron_lib.services.base.ServicePluginBase. Methods in this abstract class should be decorated as abstractmethod

  get_request_extensions()

    List of extensions.RequestExtension extension objects.

    Request extensions are used to handle custom request data.

  get_required_extensions()

    Return list of extensions required for processing this descriptor.

    Without these extensions present in a neutron deployment, the introduced extension cannot load or function properly.

  get_resources()

    List of extensions.ResourceExtension extension objects.

    Resources define new nouns, and are accessible through URLs.

  abstractmethod get_updated()

    The timestamp when the extension was last updated.

    e.g. ‘2011-01-22T13:25:27-06:00’

  classmethod update_attributes_map(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.

neutron_lib.api.extensions.is_extension_supported(plugin, alias)

  Validate that the extension is supported.

  Parameters:

    - plugin – The plugin class.

    - alias – The alias to check.

  Returns:

    True if the alias is supported else False.

this page last updated: 2026-03-26 12:58:28

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.

found an error? report a bug