glusterfs: check nfs.export-volumes with Gluster NFS + vol layout
nfs.export-volumes is required to be set to 'on' on the backing
GlusterFS cluster (nb. it's a cluster-wide setting) if the driver's
setup is
glusterfs_nfs_server_type = Gluster
glusterfs_share_layout = layout_volume.GlusterfsVolumeMappedLayout
Change-Id: I472eb5534110e8b216275ad3f4295f27a81f9815
Closes-Bug: #1499124
(cherry picked from commit d7ff0f4314
)
This commit is contained in:
parent
552a80a5bf
commit
5671c464f7
|
@ -98,6 +98,13 @@ class GlusterfsShareDriver(driver.ExecuteMixin, driver.GaneshaMixin,
|
|||
gluster_manager = share_manager['manager']
|
||||
# TODO(csaba): This should be refactored into proper dispatch to helper
|
||||
if self.nfs_helper == GlusterNFSHelper and not gluster_manager.path:
|
||||
# default is 'on'
|
||||
export_vol = gluster_manager.get_gluster_vol_option(
|
||||
NFS_EXPORT_VOL) or 'on'
|
||||
if export_vol.lower() not in ('on', '1', 'true', 'yes', 'enable'):
|
||||
raise exception.GlusterfsException(
|
||||
_("Gluster-NFS with volume layout should be used "
|
||||
"with `nfs.export-volumes = on`"))
|
||||
setting = [NFS_RPC_AUTH_REJECT, '*']
|
||||
else:
|
||||
# gluster-nfs export of the whole volume must be prohibited
|
||||
|
|
|
@ -117,11 +117,15 @@ class GlusterfsShareDriverTestCase(test.TestCase):
|
|||
helper.get_export = mock.Mock(return_value='host:/vol')
|
||||
helpercls = mock.Mock(return_value=helper)
|
||||
self._driver.nfs_helper = helpercls
|
||||
if helpercls == glusterfs.GlusterNFSHelper and path is None:
|
||||
gmgr.get_gluster_vol_option = mock.Mock(return_value='on')
|
||||
|
||||
self._driver._setup_via_manager(
|
||||
{'manager': gmgr, 'share': self.share})
|
||||
|
||||
if helpercls == glusterfs.GlusterNFSHelper and not path:
|
||||
if helpercls == glusterfs.GlusterNFSHelper and path is None:
|
||||
gmgr.get_gluster_vol_option.assert_called_once_with(
|
||||
NFS_EXPORT_VOL)
|
||||
args = (NFS_RPC_AUTH_REJECT, '*')
|
||||
else:
|
||||
args = (NFS_EXPORT_VOL, 'off')
|
||||
|
@ -140,6 +144,19 @@ class GlusterfsShareDriverTestCase(test.TestCase):
|
|||
_exception, _exception), self._driver._setup_via_manager,
|
||||
{'manager': gmgr, 'share': self.share})
|
||||
|
||||
@ddt.data('off', 'no', '0', 'false', 'disable', 'foobarbaz')
|
||||
def test_setup_via_manager_export_volumes_on(self, export_vol):
|
||||
gmgr = mock.Mock()
|
||||
gmgr.path = None
|
||||
gmgr.get_gluster_vol_option = mock.Mock(return_value=export_vol)
|
||||
self._driver.nfs_helper = glusterfs.GlusterNFSHelper
|
||||
|
||||
self.assertRaises(exception.GlusterfsException,
|
||||
self._driver._setup_via_manager,
|
||||
{'manager': gmgr, 'share': self.share})
|
||||
|
||||
gmgr.get_gluster_vol_option.assert_called_once_with(NFS_EXPORT_VOL)
|
||||
|
||||
def test_check_for_setup_error(self):
|
||||
self._driver.check_for_setup_error()
|
||||
|
||||
|
|
Loading…
Reference in New Issue