from cinder.openstack.common import units
from cinder import test
from cinder import utils
+from cinder.volume import configuration as conf
from cinder.volume.drivers import scality
raise
def _configure_driver(self):
- scality.CONF.scality_sofs_config = self.TEST_CONFIG
- scality.CONF.scality_sofs_mount_point = self.TEST_MOUNT
- scality.CONF.scality_sofs_volume_dir = self.TEST_VOLDIR
- scality.CONF.volume_dd_blocksize = '1M'
+ self.configuration.scality_sofs_config = self.TEST_CONFIG
+ self.configuration.scality_sofs_mount_point = self.TEST_MOUNT
+ self.configuration.scality_sofs_volume_dir = self.TEST_VOLDIR
+ self.configuration.volume_dd_blocksize = '1M'
def _execute_wrapper(self, cmd, *args, **kwargs):
try:
self.stubs.Set(os, 'access', _access_wrapper)
def setUp(self):
- super(ScalityDriverTestCase, self).setUp()
-
self.tempdir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.tempdir)
self.TEST_VOLDIR,
self.TEST_CLONENAME)
- self._driver = scality.ScalityDriver()
- self._driver.set_execute(self._execute_wrapper)
self._mox = mox_lib.Mox()
+ self.configuration = mox_lib.MockObject(conf.Configuration)
+ self._configure_driver()
+ super(ScalityDriverTestCase, self).setUp()
+ self._driver = scality.ScalityDriver(configuration=self.configuration)
+ self._driver.set_execute(self._execute_wrapper)
self._create_fake_mount()
self._create_fake_config()
self.addCleanup(self._remove_fake_config)
- self._configure_driver()
-
def test_setup_no_config(self):
"""Missing SOFS configuration shall raise an error."""
- scality.CONF.scality_sofs_config = None
+ self.configuration.scality_sofs_config = None
self.assertRaises(exception.VolumeBackendAPIException,
self._driver.do_setup, None)
def test_setup_missing_config(self):
"""Non-existent SOFS configuration file shall raise an error."""
- scality.CONF.scality_sofs_config = 'nonexistent.conf'
+ self.configuration.scality_sofs_config = 'nonexistent.conf'
self.assertRaises(exception.VolumeBackendAPIException,
self._driver.do_setup, None)
VERSION = '1.0.0'
+ def __init__(self, *args, **kwargs):
+ super(ScalityDriver, self).__init__(*args, **kwargs)
+ self.configuration.append_config_values(volume_opts)
+
def _check_prerequisites(self):
"""Sanity checks before attempting to mount SOFS."""
# config is mandatory
- config = CONF.scality_sofs_config
+ config = self.configuration.scality_sofs_config
if not config:
msg = _("Value required for 'scality_sofs_config'")
LOG.warn(msg)
raise
def _mount_sofs(self):
- config = CONF.scality_sofs_config
- mount_path = CONF.scality_sofs_mount_point
+ config = self.configuration.scality_sofs_config
+ mount_path = self.configuration.scality_sofs_mount_point
sysdir = os.path.join(mount_path, 'sys')
self._makedirs(mount_path)
"""Any initialization the volume driver does while starting."""
self._check_prerequisites()
self._mount_sofs()
- voldir = os.path.join(CONF.scality_sofs_mount_point,
- CONF.scality_sofs_volume_dir)
+ voldir = os.path.join(self.configuration.scality_sofs_mount_point,
+ self.configuration.scality_sofs_volume_dir)
if not os.path.isdir(voldir):
self._makedirs(voldir)
def check_for_setup_error(self):
"""Returns an error if prerequisites aren't met."""
self._check_prerequisites()
- voldir = os.path.join(CONF.scality_sofs_mount_point,
- CONF.scality_sofs_volume_dir)
+ voldir = os.path.join(self.configuration.scality_sofs_mount_point,
+ self.configuration.scality_sofs_volume_dir)
if not os.path.isdir(voldir):
msg = _("Cannot find volume dir for Scality SOFS at '%s'") % voldir
LOG.warn(msg)
def create_snapshot(self, snapshot):
"""Creates a snapshot."""
- volume_path = os.path.join(CONF.scality_sofs_mount_point,
- CONF.scality_sofs_volume_dir,
+ volume_path = os.path.join(self.configuration.scality_sofs_mount_point,
+ self.configuration.scality_sofs_volume_dir,
snapshot['volume_name'])
snapshot_path = self.local_path(snapshot)
self._create_file(snapshot_path,
os.remove(self.local_path(snapshot))
def _sofs_path(self, volume):
- return os.path.join(CONF.scality_sofs_volume_dir,
+ return os.path.join(self.configuration.scality_sofs_volume_dir,
volume['name'])
def local_path(self, volume):
- return os.path.join(CONF.scality_sofs_mount_point,
+ return os.path.join(self.configuration.scality_sofs_mount_point,
self._sofs_path(volume))
def ensure_export(self, context, volume):
image_service,
image_id,
self.local_path(volume),
- CONF.volume_dd_blocksize,
+ self.configuration.volume_dd_blocksize,
size=volume['size'])
self.create_volume(volume)