Files
neutron/doc/source/contributor/internals/api_extensions.rst
Brian Haley 7d139a013b Add RST linting to neutron
Start running the doc8 RST linter in the pep8 job. This
will catch obvious errors like line too long, etc. Tried
to fix most of the errors (there were a lot!), but added
some ignore directives so we can address some files later.

Did have to move a couple of files around as a double
include was causing some issues, but content is unchanged.

Change-Id: I336a9ee7729045da095be22ea0f58ee596967174
2024-10-01 11:18:46 -04:00

3.1 KiB

API Extensions

API extensions is the standard way of introducing new functionality to the Neutron project, it allows plugins to determine if they wish to support the functionality or not.

Examples

The easiest way to demonstrate how an API extension is written, is by studying an existing API extension and explaining the different layers.

security_group_api

Extensions for Resources with standard attributes

Resources that inherit from the HasStandardAttributes DB class can automatically have the extensions written for standard attributes (e.g. timestamps, revision number, etc) extend their resources by defining the 'api_collections' on their model. These are used by extensions for standard attr resources to generate the extended resources map.

Any new addition of a resource to the standard attributes collection must be accompanied with a new extension to ensure that it is discoverable via the API. If it's a completely new resource, the extension describing that resource will suffice. If it's an existing resource that was released in a previous cycle having the standard attributes added for the first time, then a dummy extension needs to be added indicating that the resource now has standard attributes. This ensures that an API caller can always discover if an attribute will be available.

For example, if Flavors were migrated to include standard attributes, we need a new 'flavor-standardattr' extension. Then as an API caller, I will know that flavors will have timestamps by checking for 'flavor-standardattr' and 'timestamps'.

Current API resources extended by standard attr extensions:

  • subnets: neutron.db.models_v2.Subnet
  • trunks: neutron.services.trunk.models.Trunk
  • routers: neutron.db.l3_db.Router
  • segments: neutron.db.segments_db.NetworkSegment
  • security_group_rules: neutron.db.models.securitygroup.SecurityGroupRule
  • networks: neutron.db.models_v2.Network
  • policies: neutron.db.qos.models.QosPolicy
  • subnetpools: neutron.db.models_v2.SubnetPool
  • ports: neutron.db.models_v2.Port
  • security_groups: neutron.db.models.securitygroup.SecurityGroup
  • floatingips: neutron.db.l3_db.FloatingIP
  • network_segment_ranges: neutron.db.models.network_segment_range.NetworkSegmentRange