def test_mount_nfs_with_specific_vers(self): opts = ['vers=2,nointr', 'nfsvers=3,lock', 'nolock,v2', 'v4.0'] for opt in opts: client = remotefs.RemoteFsClient( 'nfs', 'sudo', nfs_mount_point_base=self.TEST_MNT_BASE, nfs_mount_options=opt) client._read_mounts = mock.Mock(return_value=[]) client._execute = mock.Mock(return_value=True) client.mount(self.TEST_EXPORT) client._execute.assert_any_call('mkdir', '-p', self.TEST_MNT_POINT, check_exit_code=0) client._execute.assert_any_call('mount', '-t', 'nfs', '-o', opt, self.TEST_EXPORT, self.TEST_MNT_POINT, root_helper='sudo', run_as_root=True, check_exit_code=0)
def setUp(self): super(BrickRemoteFsTestCase, self).setUp() self._mox = mox.Mox() self._nfsclient = remotefs.RemoteFsClient('nfs') self._nfsclient._mount_options = None self._nfsclient._mount_base = self.TEST_MNT_BASE self.addCleanup(self._mox.UnsetStubs)
def __init__(self, mount_type, root_helper, driver=None, execute=putils.execute, device_scan_attempts=DEVICE_SCAN_ATTEMPTS_DEFAULT, *args, **kwargs): kwargs = kwargs or {} conn = kwargs.get('conn') if conn: mount_point_base = conn.get('mount_point_base') if mount_type.lower() == 'nfs': kwargs['nfs_mount_point_base'] =\ kwargs.get('nfs_mount_point_base') or\ mount_point_base elif mount_type.lower() == 'glusterfs': kwargs['glusterfs_mount_point_base'] =\ kwargs.get('glusterfs_mount_point_base') or\ mount_point_base else: LOG.warn(_("Connection details not present." " RemoteFsClient may not initialize properly.")) self._remotefsclient = remotefs.RemoteFsClient(mount_type, root_helper, execute=execute, *args, **kwargs) super(RemoteFsConnector, self).__init__(root_helper, driver=driver, execute=execute, device_scan_attempts= device_scan_attempts, *args, **kwargs)
def test_nfs_mount_options(self): opts = 'test_nfs_mount_options' client = remotefs.RemoteFsClient( 'nfs', 'sudo', nfs_mount_point_base=self.TEST_MNT_BASE, nfs_mount_options=opts) self.assertEqual(opts, client._mount_options)
def _init_backup_repo_path(self): remotefsclient = remotefs_brick.RemoteFsClient( 'nfs', utils.get_root_helper(), nfs_mount_point_base=self.backup_mount_point_base, nfs_mount_options=self.mount_options) remotefsclient.mount(self.backup_share) return remotefsclient.get_mount_point(self.backup_share)
def __init__(self, execute=processutils.execute, *args, **kwargs): self._remotefsclient = None super(GlusterfsDriver, self).__init__(*args, **kwargs) self.configuration.append_config_values(volume_opts) self.base = getattr(self.configuration, 'glusterfs_mount_point_base', CONF.glusterfs_mount_point_base) self._remotefsclient = remotefs_brick.RemoteFsClient( 'glusterfs', execute, glusterfs_mount_point_base=self.base)
def __init__(self, mount_type, root_helper, driver=None, execute=putils.execute, *args, **kwargs): self._remotefsclient = remotefs.RemoteFsClient(mount_type, execute, root_helper) super(RemoteFsConnector, self).__init__(driver, execute, root_helper, *args, **kwargs)
def __init__(self, mount_type, root_helper, driver=None, execute=putils.execute, device_scan_attempts=DEVICE_SCAN_ATTEMPTS_DEFAULT, *args, **kwargs): self._remotefsclient = remotefs.RemoteFsClient(mount_type, root_helper, execute=execute, *args, **kwargs) super(RemoteFsConnector, self).__init__(root_helper, driver=driver, execute=execute, device_scan_attempts= device_scan_attempts, *args, **kwargs)
def __init__(self, execute=putils.execute, *args, **kwargs): self._remotefsclient = None super(SmbfsDriver, self).__init__(*args, **kwargs) self.configuration.append_config_values(volume_opts) root_helper = utils.get_root_helper() self.base = getattr(self.configuration, 'smbfs_mount_point_base') opts = getattr(self.configuration, 'smbfs_mount_options') self._remotefsclient = remotefs.RemoteFsClient( 'cifs', root_helper, execute=execute, smbfs_mount_point_base=self.base, smbfs_mount_options=opts) self.img_suffix = None
def __init__(self, execute=putils.execute, *args, **kwargs): self._remotefsclient = None super(NfsDriver, self).__init__(*args, **kwargs) self.configuration.append_config_values(volume_opts) root_helper = utils.get_root_helper() base = getattr(self.configuration, 'nfs_mount_point_base', CONF.nfs_mount_point_base) opts = getattr(self.configuration, 'nfs_mount_options', CONF.nfs_mount_options) self._remotefsclient = remotefs.RemoteFsClient( 'nfs', root_helper, execute=execute, nfs_mount_point_base=base, nfs_mount_options=opts)
def __init__(self, execute=putils.execute, *args, **kwargs): self._remotefsclient = None super(NfsDriver, self).__init__(*args, **kwargs) self.configuration.append_config_values(nfs_opts) root_helper = utils.get_root_helper() # base bound to instance is used in RemoteFsConnector. self.base = getattr(self.configuration, 'nfs_mount_point_base', CONF.nfs_mount_point_base) opts = getattr(self.configuration, 'nfs_mount_options', CONF.nfs_mount_options) self._remotefsclient = remotefs_brick.RemoteFsClient( 'nfs', root_helper, execute=execute, nfs_mount_point_base=self.base, nfs_mount_options=opts)
def test_mount_nfs_with_fallback_no_vers(self): def execute(*args, **kwargs): if 'mkdir' in args: return True elif 'mount' in args: if 'lock,nointr,vers=4,minorversion=1' in args: raise Exception() else: return True else: self.fail(_("Unexpected call to _execute.")) opts = 'lock,nointr' client = remotefs.RemoteFsClient( 'nfs', 'sudo', nfs_mount_point_base=self.TEST_MNT_BASE, nfs_mount_options=opts) client._read_mounts = mock.Mock(return_value=[]) client._execute = mock.Mock(wraps=execute) client.mount(self.TEST_EXPORT) client._execute.assert_any_call('mkdir', '-p', self.TEST_MNT_POINT, check_exit_code=0) client._execute.assert_any_call('mount', '-t', 'nfs', '-o', 'lock,nointr,vers=4,minorversion=1', self.TEST_EXPORT, self.TEST_MNT_POINT, root_helper='sudo', run_as_root=True, check_exit_code=0) client._execute.assert_any_call('mount', '-t', 'nfs', '-o', 'lock,nointr', self.TEST_EXPORT, self.TEST_MNT_POINT, root_helper='sudo', run_as_root=True, check_exit_code=0)
def test_mount_nfs_with_fallback_all_fail(self): def execute(*args, **kwargs): if 'mkdir' in args: return True else: raise Exception(_("mount failed.")) opts = 'lock,nointr' client = remotefs.RemoteFsClient( 'nfs', 'sudo', nfs_mount_point_base=self.TEST_MNT_BASE, nfs_mount_options=opts) client._read_mounts = mock.Mock(return_value=[]) client._execute = mock.Mock(wraps=execute) self.assertRaises(exception.BrickException, client.mount, self.TEST_EXPORT)
def __init__(self, execute=putils.execute, *args, **kwargs): self._remotefsclient = None super(NfsDriver, self).__init__(*args, **kwargs) self.configuration.append_config_values(nfs_opts) root_helper = utils.get_root_helper() # base bound to instance is used in RemoteFsConnector. self.base = getattr(self.configuration, 'nfs_mount_point_base', CONF.nfs_mount_point_base) self.base = os.path.realpath(self.base) opts = getattr(self.configuration, 'nfs_mount_options', CONF.nfs_mount_options) nas_mount_options = getattr(self.configuration, 'nas_mount_options', None) if nas_mount_options is not None: LOG.debug('overriding nfs_mount_options with nas_mount_options') opts = nas_mount_options self._remotefsclient = remotefs_brick.RemoteFsClient( 'nfs', root_helper, execute=execute, nfs_mount_point_base=self.base, nfs_mount_options=opts)
def setUp(self): super(BrickRemoteFsTestCase, self).setUp() self._mox = mox.Mox() self._nfsclient = remotefs.RemoteFsClient( 'nfs', 'sudo', nfs_mount_point_base=self.TEST_MNT_BASE) self.addCleanup(self._mox.UnsetStubs)
def test_glusterfs_mount_point_base(self): base = '/mnt/test/glusterfs/mount/point/base' client = remotefs.RemoteFsClient('glusterfs', 'sudo', glusterfs_mount_point_base=base) self.assertEqual(base, client._mount_base)
def __init__(self, execute=putils.execute, *args, **kwargs): self._remotefsclient = None super(NfsDriver, self).__init__(*args, **kwargs) self.configuration.append_config_values(volume_opts) self._remotefsclient = remotefs.RemoteFsClient('nfs', execute)