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
This commit is contained in:
Takashi Kajinami 2023-02-21 17:05:54 +09:00
parent 64e25979a9
commit 572e73ef13
1 changed files with 6 additions and 0 deletions

View File

@ -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