In the beginning, there were no guidelines. And it was good. But that didn’t last long. As more and more people added more and more code, we realized that we needed a set of coding standards to make sure that the openstacksdk API at least attempted to display some form of consistency.
Thus, these coding standards/guidelines were developed. Note that not all of openstacksdk adheres to these standards just yet. Some older code has not been updated because we need to maintain backward compatibility. Some of it just hasn’t been changed yet. But be clear, all new code must adhere to these guidelines.
Below are the patterns that we expect openstacksdk developers to follow.
openstacksdk uses reno for managing its release notes. A new release note should be added to your contribution anytime you add new API calls, fix significant bugs, add new functionality or parameters to existing API calls, or make any other significant changes to the code base that we should draw attention to for the user base.
It is not necessary to add release notes for minor fixes, such as correction of documentation typos, minor code cleanup or reorganization, or any other change that a user would not notice through normal usage.
Exceptions should NEVER be wrapped and re-raised inside of a new exception. This removes important debug information from the user. All of the exceptions should be raised correctly the first time.
The openstack.cloud layer has some specific rules:
Complex objects returned to the caller must be a munch.Munch type. The openstack._adapter.ShadeAdapter class makes resources into munch.Munch.
All objects should be normalized. It is shade’s purpose in life to make OpenStack consistent for end users, and this means not trusting the clouds to return consistent objects. There should be a normalize function in openstack/cloud/_normalize.py that is applied to objects before returning them to the user. See Data Model for further details on object model requirements.
Fields should not be in the normalization contract if we cannot commit to providing them to all users.
Fields should be renamed in normalization to be consistent with the rest of openstack.cloud. For instance, nothing in openstack.cloud exposes the legacy OpenStack concept of “tenant” to a user, but instead uses “project” even if the cloud in question uses tenant.
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.