From 572e73ef135106e8b1dd4378db183c565db2cfc9 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Tue, 21 Feb 2023 17:05:54 +0900 Subject: cinder: Disable cinder stores if cinderclient is not installed Change Iec6ac7020f66f9f9728d6cf4452127b8d55a8b2d made cinderclient optional but it did not add proper validation while initializing a cinder store. This can cause ugly errors in case users tries to enable cinder stores without installing cinderclient. This ensures glance_store checks whether cinderclient is available and disables all cinder stores in case cinderclient is not available. Change-Id: Idb8abfdab9639b5b70ddddc3a76b1f1d24dd035d --- glance_store/_drivers/cinder/store.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/glance_store/_drivers/cinder/store.py b/glance_store/_drivers/cinder/store.py index 17fb96b..b587c7e 100644 --- a/glance_store/_drivers/cinder/store.py +++ b/glance_store/_drivers/cinder/store.py @@ -514,6 +514,12 @@ class Store(glance_store.driver.Store): Check to verify if the volume types configured for the cinder store exist in deployment and if not, log a warning. """ + if cinderclient is None: + reason = _("cinderclient is not available.") + LOG.error(reason) + raise exceptions.BadStoreConfiguration(store_name="cinder", + reason=reason) + cinder_volume_type = self.store_conf.cinder_volume_type if cinder_volume_type: # NOTE: `cinder_volume_type` is configured, check -- cgit v1.2.1