self.driver = driver.StorPoolDriver(execute=mock_exec,
configuration=self.cfg)
+ self.driver.check_for_setup_error()
def test_initialized(self):
- self.driver.check_for_setup_error()
self.driver.validate_connector(None)
self.driver.validate_connector(5)
c = self.driver.initialize_connection(None, None)
from __future__ import absolute_import
from oslo.config import cfg
+from oslo.utils import importutils
from oslo.utils import units
import six
from cinder import exception
-from cinder.i18n import _LE
+from cinder.i18n import _, _LE
from cinder.openstack.common import log as logging
from cinder.volume import driver
from cinder.volume import volume_types
LOG = logging.getLogger(__name__)
-from storpool import spapi
-from storpool import spopenstack
-from storpool import sptypes
+storpool = importutils.try_import('storpool')
+if storpool:
+ from storpool import spapi
+ from storpool import spopenstack
+ from storpool import sptypes
storpool_opts = [
help='The default StorPool chain replication value. '
'Used when creating a volume with no specified type if '
'storpool_template is not set. Also used for calculating '
- 'the apparent free space reported in the stats.')
+ 'the apparent free space reported in the stats.'),
]
+CONF = cfg.CONF
+CONF.register_opts(storpool_opts)
+
class StorPoolDriver(driver.VolumeDriver):
"""The StorPool block device driver using the StorPool API"""
self._sp_config = None
self._ourId = None
self._ourIdInt = None
- self._attach = spopenstack.AttachDB(log=LOG)
+ self._attach = None
def _backendException(self, e):
return exception.VolumeBackendAPIException(data=six.text_type(e))
raise self._backendException(e)
def check_for_setup_error(self):
+ if storpool is None:
+ msg = _('storpool libraries not found')
+ raise exception.VolumeBackendAPIException(data=msg)
+
+ self._attach = spopenstack.AttachDB(log=LOG)
try:
self._attach.api()
except Exception as e: