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.
The easiest way to demonstrate how an API extension is written, is by studying an existing API extension and explaining the different layers.
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:
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.