From 02c99b18674880c72917d99a78e0b68a1b8a0a00 Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk Date: Mon, 11 Dec 2017 08:51:27 +0100 Subject: [PATCH] Check required Gnocchi version is installed Change-Id: I301511279c1d49736027e51274c8740935e154b0 --- ceilometer/gnocchi_client.py | 12 ++++++++++++ setup.cfg | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ceilometer/gnocchi_client.py b/ceilometer/gnocchi_client.py index 4f6e806224..2472c4db1f 100644 --- a/ceilometer/gnocchi_client.py +++ b/ceilometer/gnocchi_client.py @@ -11,6 +11,8 @@ # License for the specific language governing permissions and limitations # under the License. +from distutils import version + from gnocchiclient import client from gnocchiclient import exceptions as gnocchi_exc import keystoneauth1.session @@ -184,9 +186,19 @@ resources_update_operations = [ }]}, ] +# NOTE(sileht): We use LooseVersion because pbr can generate invalid +# StrictVersion like 9.0.1.dev226 +REQUIRED_VERSION = version.LooseVersion("4.0.0") + def upgrade_resource_types(conf): gnocchi = get_gnocchiclient(conf) + + gnocchi_version = version.LooseVersion(gnocchi.build.get()) + if gnocchi_version < REQUIRED_VERSION: + raise Exception("required gnocchi version is %s, got %s", + REQUIRED_VERSION, gnocchi_version) + for name, attributes in resources_initial.items(): try: gnocchi.resource_type.get(name=name) diff --git a/setup.cfg b/setup.cfg index 16f70abbbf..2b00f5bf96 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,7 +33,7 @@ data_files = [extras] gnocchi = oslo.cache>=1.5.0 # Apache-2.0 - gnocchiclient>=4.0.0 # Apache-2.0 + gnocchiclient>=7.0.0 # Apache-2.0 zaqar = python-zaqarclient>=1.0.0 # Apache-2.0