Merge "cinder: Catch missing dependencies"

This commit is contained in:
Zuul 2023-12-13 07:02:02 +00:00 committed by Gerrit Code Review
commit 6f5011d1f0
1 changed files with 12 additions and 6 deletions

View File

@ -50,8 +50,10 @@ try:
from os_brick.initiator import connector from os_brick.initiator import connector
from oslo_privsep import priv_context from oslo_privsep import priv_context
except ImportError: except ImportError:
api_versions = None
cinder_exception = None cinder_exception = None
cinderclient = None cinderclient = None
os_brick = None
connector = None connector = None
priv_context = None priv_context = None
@ -495,7 +497,8 @@ class Store(glance_store.driver.Store):
else: else:
self.store_conf = self.conf.glance_store self.store_conf = self.conf.glance_store
self.volume_api = cinder_utils.API() self.volume_api = cinder_utils.API()
getattr(os_brick, 'setup', lambda x: None)(CONF) if os_brick:
os_brick.setup(CONF)
# The purpose of this map is to store the connector object for a # The purpose of this map is to store the connector object for a
# particular volume as we will need to call os-brick extend_volume # particular volume as we will need to call os-brick extend_volume
# method for the kernel to realize the new size change after cinder # method for the kernel to realize the new size change after cinder
@ -514,11 +517,14 @@ class Store(glance_store.driver.Store):
Check to verify if the volume types configured for the cinder store Check to verify if the volume types configured for the cinder store
exist in deployment and if not, log a warning. exist in deployment and if not, log a warning.
""" """
if cinderclient is None: for module_name, module in [('cinderclient', cinderclient),
reason = _("cinderclient is not available.") ('os-brick', os_brick),
LOG.error(reason) ('oslo-privsep', priv_context)]:
raise exceptions.BadStoreConfiguration(store_name="cinder", if module is None:
reason=reason) reason = _("%s is not available." % module_name)
LOG.error(reason)
raise exceptions.BadStoreConfiguration(store_name="cinder",
reason=reason)
cinder_volume_type = self.store_conf.cinder_volume_type cinder_volume_type = self.store_conf.cinder_volume_type
if cinder_volume_type: if cinder_volume_type: