Merge "Remotefs: add ScalityFS support"
This commit is contained in:
commit
fae66fbc2d
|
@ -72,6 +72,7 @@ HUAWEISDSHYPERVISOR = "HUAWEISDSHYPERVISOR"
|
||||||
HGST = "HGST"
|
HGST = "HGST"
|
||||||
RBD = "RBD"
|
RBD = "RBD"
|
||||||
SCALEIO = "SCALEIO"
|
SCALEIO = "SCALEIO"
|
||||||
|
SCALITY = "SCALITY"
|
||||||
|
|
||||||
|
|
||||||
def _check_multipathd_running(root_helper, enforce_multipath):
|
def _check_multipathd_running(root_helper, enforce_multipath):
|
||||||
|
@ -195,7 +196,7 @@ class InitiatorConnector(executor.Executor):
|
||||||
execute=execute,
|
execute=execute,
|
||||||
device_scan_attempts=device_scan_attempts,
|
device_scan_attempts=device_scan_attempts,
|
||||||
*args, **kwargs)
|
*args, **kwargs)
|
||||||
elif protocol == NFS or protocol == GLUSTERFS:
|
elif protocol in (NFS, GLUSTERFS, SCALITY):
|
||||||
return RemoteFsConnector(mount_type=protocol.lower(),
|
return RemoteFsConnector(mount_type=protocol.lower(),
|
||||||
root_helper=root_helper,
|
root_helper=root_helper,
|
||||||
driver=driver,
|
driver=driver,
|
||||||
|
@ -1215,14 +1216,11 @@ class RemoteFsConnector(InitiatorConnector):
|
||||||
conn = kwargs.get('conn')
|
conn = kwargs.get('conn')
|
||||||
if conn:
|
if conn:
|
||||||
mount_point_base = conn.get('mount_point_base')
|
mount_point_base = conn.get('mount_point_base')
|
||||||
if mount_type.lower() == 'nfs':
|
mount_type_lower = mount_type.lower()
|
||||||
kwargs['nfs_mount_point_base'] =\
|
if mount_type_lower in ('nfs', 'glusterfs', 'scality'):
|
||||||
kwargs.get('nfs_mount_point_base') or\
|
kwargs[mount_type_lower + '_mount_point_base'] = (
|
||||||
mount_point_base
|
kwargs.get(mount_type_lower + '_mount_point_base') or
|
||||||
elif mount_type.lower() == 'glusterfs':
|
mount_point_base)
|
||||||
kwargs['glusterfs_mount_point_base'] =\
|
|
||||||
kwargs.get('glusterfs_mount_point_base') or\
|
|
||||||
mount_point_base
|
|
||||||
else:
|
else:
|
||||||
LOG.warning(_LW("Connection details not present."
|
LOG.warning(_LW("Connection details not present."
|
||||||
" RemoteFsClient may not initialize properly."))
|
" RemoteFsClient may not initialize properly."))
|
||||||
|
|
|
@ -35,34 +35,30 @@ class RemoteFsClient(object):
|
||||||
def __init__(self, mount_type, root_helper,
|
def __init__(self, mount_type, root_helper,
|
||||||
execute=putils.execute, *args, **kwargs):
|
execute=putils.execute, *args, **kwargs):
|
||||||
|
|
||||||
self._mount_type = mount_type
|
mount_type_to_option_prefix = {
|
||||||
if mount_type == "nfs":
|
'nfs': 'nfs',
|
||||||
self._mount_base = kwargs.get('nfs_mount_point_base', None)
|
'cifs': 'smbfs',
|
||||||
if not self._mount_base:
|
'glusterfs': 'glusterfs',
|
||||||
raise exception.InvalidParameterValue(
|
'vzstorage': 'vzstorage',
|
||||||
err=_('nfs_mount_point_base required'))
|
'scality': 'scality_sofs'
|
||||||
self._mount_options = kwargs.get('nfs_mount_options', None)
|
}
|
||||||
self._check_nfs_options()
|
|
||||||
elif mount_type == "cifs":
|
if mount_type not in mount_type_to_option_prefix:
|
||||||
self._mount_base = kwargs.get('smbfs_mount_point_base', None)
|
|
||||||
if not self._mount_base:
|
|
||||||
raise exception.InvalidParameterValue(
|
|
||||||
err=_('smbfs_mount_point_base required'))
|
|
||||||
self._mount_options = kwargs.get('smbfs_mount_options', None)
|
|
||||||
elif mount_type == "glusterfs":
|
|
||||||
self._mount_base = kwargs.get('glusterfs_mount_point_base', None)
|
|
||||||
if not self._mount_base:
|
|
||||||
raise exception.InvalidParameterValue(
|
|
||||||
err=_('glusterfs_mount_point_base required'))
|
|
||||||
self._mount_options = None
|
|
||||||
elif mount_type == "vzstorage":
|
|
||||||
self._mount_base = kwargs.get('vzstorage_mount_point_base', None)
|
|
||||||
if not self._mount_base:
|
|
||||||
raise exception.InvalidParameterValue(
|
|
||||||
err=_('vzstorage_mount_point_base required'))
|
|
||||||
self._mount_options = None
|
|
||||||
else:
|
|
||||||
raise exception.ProtocolNotSupported(protocol=mount_type)
|
raise exception.ProtocolNotSupported(protocol=mount_type)
|
||||||
|
|
||||||
|
self._mount_type = mount_type
|
||||||
|
option_prefix = mount_type_to_option_prefix[mount_type]
|
||||||
|
|
||||||
|
self._mount_base = kwargs.get(option_prefix + '_mount_point_base')
|
||||||
|
if not self._mount_base:
|
||||||
|
raise exception.InvalidParameterValue(
|
||||||
|
err=_('%s_mount_point_base required') % option_prefix)
|
||||||
|
|
||||||
|
self._mount_options = kwargs.get(option_prefix + '_mount_options')
|
||||||
|
|
||||||
|
if mount_type == "nfs":
|
||||||
|
self._check_nfs_options()
|
||||||
|
|
||||||
self.root_helper = root_helper
|
self.root_helper = root_helper
|
||||||
self.set_execute(execute)
|
self.set_execute(execute)
|
||||||
|
|
||||||
|
|
|
@ -159,6 +159,10 @@ class ConnectorTestCase(base.TestCase):
|
||||||
'glusterfs', None, glusterfs_mount_point_base='/mnt/test')
|
'glusterfs', None, glusterfs_mount_point_base='/mnt/test')
|
||||||
self.assertEqual(obj.__class__.__name__, "RemoteFsConnector")
|
self.assertEqual(obj.__class__.__name__, "RemoteFsConnector")
|
||||||
|
|
||||||
|
obj = connector.InitiatorConnector.factory(
|
||||||
|
'scality', None, scality_sofs_mount_point_base='/mnt/test')
|
||||||
|
self.assertEqual(obj.__class__.__name__, "RemoteFsConnector")
|
||||||
|
|
||||||
obj = connector.InitiatorConnector.factory('local', None)
|
obj = connector.InitiatorConnector.factory('local', None)
|
||||||
self.assertEqual(obj.__class__.__name__, "LocalConnector")
|
self.assertEqual(obj.__class__.__name__, "LocalConnector")
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,26 @@ class RemoteFsClientTestCase(base.TestCase):
|
||||||
def test_no_mount_point_vzstorage(self):
|
def test_no_mount_point_vzstorage(self):
|
||||||
self._test_no_mount_point('vzstorage')
|
self._test_no_mount_point('vzstorage')
|
||||||
|
|
||||||
|
def test_no_mount_point_scality(self):
|
||||||
|
self._test_no_mount_point('scality')
|
||||||
|
|
||||||
def test_invalid_fs(self):
|
def test_invalid_fs(self):
|
||||||
self.assertRaises(exception.ProtocolNotSupported,
|
self.assertRaises(exception.ProtocolNotSupported,
|
||||||
remotefs.RemoteFsClient,
|
remotefs.RemoteFsClient,
|
||||||
'my_fs', root_helper='true', execute=putils.execute)
|
'my_fs', root_helper='true', execute=putils.execute)
|
||||||
|
|
||||||
|
def test_init_sets_mount_base(self):
|
||||||
|
client = remotefs.RemoteFsClient("cifs", root_helper='true',
|
||||||
|
smbfs_mount_point_base='/fake',
|
||||||
|
cifs_mount_point_base='/fake2')
|
||||||
|
# Tests that although the FS type is "cifs", the config option
|
||||||
|
# starts with "smbfs_"
|
||||||
|
self.assertEqual('/fake', client._mount_base)
|
||||||
|
|
||||||
|
def test_init_nfs_calls_check_nfs_options(self):
|
||||||
|
to_patch = remotefs.RemoteFsClient._check_nfs_options
|
||||||
|
with mock.patch.object(to_patch) as mock_check_nfs_options:
|
||||||
|
remotefs.RemoteFsClient("nfs", root_helper='true',
|
||||||
|
nfs_mount_point_base='/fake')
|
||||||
|
|
||||||
|
mock_check_nfs_options.assert_called_once_with()
|
||||||
|
|
Loading…
Reference in New Issue