Add __version__ and __version_tuple__ properties

These properties should simplify integration with other plugins

Change-Id: Ia0246114a51f9e4a4ad6c998a50ad13483be9f51
This commit is contained in:
Andrey Kurilin 2018-04-27 14:08:25 +03:00
parent 8bd19021e4
commit 77e207e90d
2 changed files with 14 additions and 3 deletions

View File

@ -27,6 +27,11 @@ Added
* [scenario plugin] GnocchiMetric.create_delete_metric
* [scenario plugin] GnocchiResource.create_resource
* [scenario plugin] GnocchiResource.create_delete_resource
* Introduce *__version__*, *__version_tuple__* at *rally_openstack* module.
As like other python packages each release of *rally-openstack* package can
introduce new things, deprecate or even remove other ones. To simplify
integration with other plugins which depends on *rally-openstack*, the new
properties can be used with proper checks.
Changed
~~~~~~~

View File

@ -12,11 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from rally.common import version as _rally_version
import pbr.version
from rally.common import version as __rally_version__
_version_tuple = _rally_version.version_info.semantic_version().version_tuple()
__rally_version__ = __rally_version__.version_info.semantic_version()
__rally_version__ = __rally_version__.version_tuple()
if _version_tuple < (0, 12):
if __rally_version__ < (0, 12):
# NOTE(andreykurilin): Rally < 0.12 doesn't care about loading options from
# external packages, so we need to handle it manually.
@ -27,3 +29,7 @@ if _version_tuple < (0, 12):
# ensure that rally options are registered.
global_opts.register()
global_opts.register_opts(opts.list_opts().items())
__version_info__ = pbr.version.VersionInfo("rally-openstack")
__version__ = __version_info__.version_string()
__version_tuple__ = __version_info__.semantic_version().version_tuple()