from mox import IgnoreArg
from mox import IsA
from mox import stubout
+from oslo.config import cfg
from cinder import brick
from cinder import context
from cinder.volume.drivers import glusterfs
+CONF = cfg.CONF
+
+
class DumbVolume(object):
fields = {}
self.TEST_SHARES_CONFIG_FILE
self._configuration.glusterfs_mount_point_base = \
self.TEST_MNT_POINT_BASE
- self._configuration.glusterfs_disk_util = 'df'
self._configuration.glusterfs_sparsed_volumes = True
self._configuration.glusterfs_qcow2_volumes = False
def test_local_path(self):
"""local_path common use case."""
- glusterfs.CONF.glusterfs_mount_point_base = self.TEST_MNT_POINT_BASE
+ CONF.set_override("glusterfs_mount_point_base",
+ self.TEST_MNT_POINT_BASE)
drv = self._driver
volume = DumbVolume()
mox.StubOutWithMock(brick.remotefs.remotefs.RemoteFsClient,
'get_mount_point')
- glusterfs.CONF.glusterfs_mount_point_base = self.TEST_MNT_POINT_BASE
+ CONF.set_override("glusterfs_mount_point_base",
+ self.TEST_MNT_POINT_BASE)
brick.remotefs.remotefs.RemoteFsClient.\
get_mount_point(self.TEST_EXPORT1).AndReturn(hashed_path)
(df_total_size, df_avail)
df_output = df_head + df_data
- setattr(glusterfs.CONF, 'glusterfs_disk_util', 'df')
-
mox.StubOutWithMock(drv, '_get_mount_point_for_share')
drv._get_mount_point_for_share(self.TEST_EXPORT1).\
AndReturn(self.TEST_MNT_POINT)
mox.VerifyAll()
- delattr(glusterfs.CONF, 'glusterfs_disk_util')
-
def test_load_shares_config(self):
mox = self._mox
drv = self._driver
"""do_setup should throw error if shares config is not configured."""
drv = self._driver
- glusterfs.CONF.glusterfs_shares_config = self.TEST_SHARES_CONFIG_FILE
+ CONF.set_override("glusterfs_shares_config",
+ self.TEST_SHARES_CONFIG_FILE)
self.assertRaises(exception.GlusterfsException,
drv.do_setup, IsA(context.RequestContext))
mox = self._mox
drv = self._driver
- glusterfs.CONF.glusterfs_shares_config = self.TEST_SHARES_CONFIG_FILE
+ CONF.set_override("glusterfs_shares_config",
+ self.TEST_SHARES_CONFIG_FILE)
mox.StubOutWithMock(os.path, 'exists')
os.path.exists(self.TEST_SHARES_CONFIG_FILE).AndReturn(True)
mox = self._mox
drv = self._driver
- glusterfs.CONF.glusterfs_shares_config = self.TEST_SHARES_CONFIG_FILE
+ CONF.set_override("glusterfs_shares_config",
+ self.TEST_SHARES_CONFIG_FILE)
self.stubs.Set(drv, '_load_shares_config',
self._fake_load_shares_config)
drv = self._driver
volume = self._simple_volume()
- setattr(glusterfs.CONF, 'glusterfs_sparsed_volumes', True)
+ CONF.set_override('glusterfs_sparsed_volumes', True)
mox.StubOutWithMock(drv, '_create_sparsed_file')
mox.StubOutWithMock(drv, '_set_rw_permissions_for_all')
mox.VerifyAll()
- delattr(glusterfs.CONF, 'glusterfs_sparsed_volumes')
-
def test_create_nonsparsed_volume(self):
mox = self._mox
drv = self._driver
def test_get_backing_chain_for_path(self):
(mox, drv) = self._mox, self._driver
- glusterfs.CONF.glusterfs_mount_point_base = self.TEST_MNT_POINT_BASE
+ CONF.set_override('glusterfs_mount_point_base',
+ self.TEST_MNT_POINT_BASE)
volume = self._simple_volume()
vol_filename = volume['name']
drv = self._driver
volume = self._simple_volume()
- setattr(cfg.CONF, 'nfs_sparsed_volumes', True)
+ cfg.CONF.set_override('nfs_sparsed_volumes', True)
mox.StubOutWithMock(drv, '_create_sparsed_file')
mox.StubOutWithMock(drv, '_set_rw_permissions_for_all')
mox.VerifyAll()
- delattr(cfg.CONF, 'nfs_sparsed_volumes')
-
def test_create_nonsparsed_volume(self):
mox = self._mox
drv = self._driver
self.configuration.nfs_sparsed_volumes = False
volume = self._simple_volume()
- setattr(cfg.CONF, 'nfs_sparsed_volumes', False)
+ cfg.CONF.set_override('nfs_sparsed_volumes', False)
mox.StubOutWithMock(drv, '_create_regular_file')
mox.StubOutWithMock(drv, '_set_rw_permissions_for_all')
mox.VerifyAll()
- delattr(cfg.CONF, 'nfs_sparsed_volumes')
-
def test_create_volume_should_ensure_nfs_mounted(self):
"""create_volume ensures shares provided in config are mounted."""
mox = self._mox