glusterfs: edit config option specifying volume
glusterfs driver has an option to specify the GlusterFS volume to be mounted on the Manila host. The GlusterFS volume to be mounted is presently specified in a file, whose path is the config option glusterfs_volumes_config. Instead have a string valued config option in manila.conf that directly takes the same input. Change-Id: I3f8734174db71ef232620c55d4ecdd2b5d0192ad Closes-Bug: #1365941
This commit is contained in:
parent
642f9af68c
commit
2ab3e7da43
|
@ -40,10 +40,10 @@ from oslo.config import cfg
|
|||
LOG = logging.getLogger(__name__)
|
||||
|
||||
GlusterfsManilaShare_opts = [
|
||||
cfg.StrOpt('glusterfs_volumes_config',
|
||||
default='/etc/manila/glusterfs_volumes',
|
||||
help='File with the list of Gluster volumes that can '
|
||||
'be used to create shares.'),
|
||||
cfg.StrOpt('glusterfs_target',
|
||||
help='Specifies the GlusterFS volume to be mounted on the '
|
||||
'Manila host. It is of the form '
|
||||
'[remoteuser@]<volserver>:<volid>.'),
|
||||
cfg.StrOpt('glusterfs_mount_point_base',
|
||||
default='$state_path/mnt',
|
||||
help='Base directory containing mount points for Gluster '
|
||||
|
@ -100,8 +100,12 @@ class GlusterfsShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
|||
def do_setup(self, context):
|
||||
"""Native mount the GlusterFS volume and tune it."""
|
||||
super(GlusterfsShareDriver, self).do_setup(context)
|
||||
if not self.configuration.glusterfs_target:
|
||||
raise exception.GlusterfsException(
|
||||
_('glusterfs_target configuration that specifies the GlusterFS'
|
||||
' volume to be mounted on the Manila host is not set.'))
|
||||
self.gluster_address = GlusterAddress(
|
||||
self._read_gluster_vol_from_config()
|
||||
self.configuration.glusterfs_target
|
||||
)
|
||||
try:
|
||||
self._execute('mount.glusterfs', check_exit_code=False)
|
||||
|
@ -159,17 +163,6 @@ class GlusterfsShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
|||
mount_path]
|
||||
self._do_mount(command, ensure)
|
||||
|
||||
def _read_gluster_vol_from_config(self):
|
||||
config_file = self.configuration.glusterfs_volumes_config
|
||||
if not os.access(config_file, os.R_OK):
|
||||
msg = (_("Gluster config file %(config)s doesn't exist") %
|
||||
{'config': config_file})
|
||||
LOG.error(msg)
|
||||
raise exception.GlusterfsException(msg)
|
||||
|
||||
with open(config_file) as f:
|
||||
return f.readline().strip()
|
||||
|
||||
def _get_export_dir_dict(self):
|
||||
"""Get the export entries of shares in the GlusterFS volume."""
|
||||
try:
|
||||
|
|
|
@ -111,6 +111,7 @@ class GlusterfsShareDriverTestCase(test.TestCase):
|
|||
self._execute = fake_utils.fake_execute
|
||||
self._context = context.get_admin_context()
|
||||
|
||||
CONF.set_default('glusterfs_target', '127.0.0.1:/testvol')
|
||||
CONF.set_default('glusterfs_mount_point_base', '/mnt/nfs')
|
||||
CONF.set_default('reserved_share_percentage', 50)
|
||||
|
||||
|
@ -128,8 +129,6 @@ class GlusterfsShareDriverTestCase(test.TestCase):
|
|||
fake_utils.fake_execute_clear_log()
|
||||
|
||||
def test_do_setup(self):
|
||||
self._driver._read_gluster_vol_from_config =\
|
||||
mock.Mock(return_value='127.0.0.1:/testvol')
|
||||
self._driver._ensure_gluster_vol_mounted = mock.Mock()
|
||||
exec_cmd1 = 'mount.glusterfs'
|
||||
exec_cmd2 = 'gluster volume set testvol nfs.export-volumes off'
|
||||
|
@ -138,9 +137,12 @@ class GlusterfsShareDriverTestCase(test.TestCase):
|
|||
self._driver._ensure_gluster_vol_mounted.assert_called_once_with()
|
||||
self.assertEqual(fake_utils.fake_execute_get_log(), expected_exec)
|
||||
|
||||
def test_do_setup_glusterfs_target_not_set(self):
|
||||
self._driver.configuration.glusterfs_target = None
|
||||
self.assertRaises(exception.GlusterfsException, self._driver.do_setup,
|
||||
self._context)
|
||||
|
||||
def test_do_setup_mount_glusterfs_not_installed(self):
|
||||
self._driver._read_gluster_vol_from_config =\
|
||||
mock.Mock(return_value='127.0.0.1:/testvol')
|
||||
self._driver._ensure_gluster_vol_mounted = mock.Mock()
|
||||
|
||||
def exec_runner(*ignore_args, **ignore_kwargs):
|
||||
|
@ -152,8 +154,6 @@ class GlusterfsShareDriverTestCase(test.TestCase):
|
|||
self._context)
|
||||
|
||||
def test_do_setup_mount_glusterfs_error_gluster_vol_set(self):
|
||||
self._driver._read_gluster_vol_from_config =\
|
||||
mock.Mock(return_value='127.0.0.1:/testvol')
|
||||
self._driver._ensure_gluster_vol_mounted = mock.Mock()
|
||||
glusterfs.LOG.error = mock.Mock()
|
||||
|
||||
|
|
Loading…
Reference in New Issue