Example #1
0
    def test_vzstorage_with_mds_list(self, mock_read_mounts, mock_exists):
        client = remotefs.VZStorageRemoteFSClient(
            "vzstorage", root_helper='true', vzstorage_mount_point_base='/mnt')
        cluster_name = 'qwe'
        mds_list = ['10.0.0.1', '10.0.0.2']
        share = '%s:/%s' % (','.join(mds_list), cluster_name)
        mount_point = client.get_mount_point(share)
        vz_conf_dir = os.path.join('/etc/pstorage/clusters/', cluster_name)

        tmp_dir = '/tmp/fake_dir/'

        with mock.patch.object(tempfile, 'mkdtemp',
                               return_value=tmp_dir):
            mock_open = mock.mock_open()
            with mock.patch.object(six.moves.builtins, "open",
                                   mock_open, create=True):
                client.mount(share)

                write_calls = [mock.call(tmp_dir + 'bs_list', 'w'),
                               mock.call().__enter__(),
                               mock.call().write('10.0.0.1\n'),
                               mock.call().write('10.0.0.2\n'),
                               mock.call().__exit__(None, None, None)]

                mock_open.assert_has_calls(write_calls)
        calls = [mock.call('mkdir', '-p', mount_point, check_exit_code=0),
                 mock.call('cp', '-rf', tmp_dir, vz_conf_dir,
                           run_as_root=True, root_helper='true'),
                 mock.call('chown', '-R', 'root:root', vz_conf_dir,
                           run_as_root=True, root_helper='true'),
                 mock.call('pstorage-mount', '-c', cluster_name, mount_point,
                           root_helper='true', check_exit_code=0,
                           run_as_root=True)]
        self.mock_execute.assert_has_calls(calls)
Example #2
0
 def test_vzstorage_with_auth(self, mock_read_mounts):
     client = remotefs.VZStorageRemoteFSClient(
         "vzstorage", root_helper='true', vzstorage_mount_point_base='/mnt')
     cluster_name = 'qwe'
     password = '******'
     share = '%s:%s' % (cluster_name, password)
     mount_point = client.get_mount_point(share)
     client.mount(share)
     calls = [
         mock.call('mkdir', '-p', mount_point, check_exit_code=0),
         mock.call('pstorage',
                   '-c',
                   cluster_name,
                   'auth-node',
                   '-P',
                   process_input=password,
                   root_helper='true',
                   run_as_root=True),
         mock.call('pstorage-mount',
                   '-c',
                   cluster_name,
                   mount_point,
                   root_helper='true',
                   check_exit_code=0,
                   run_as_root=True)
     ]
     self.mock_execute.assert_has_calls(calls)
Example #3
0
 def test_vzstorage_by_cluster_name(self, mock_read_mounts):
     client = remotefs.VZStorageRemoteFSClient(
         "vzstorage", root_helper='true', vzstorage_mount_point_base='/mnt')
     share = 'qwe'
     cluster_name = share
     mount_point = client.get_mount_point(share)
     client.mount(share)
     calls = [mock.call('mkdir', '-p', mount_point, check_exit_code=0),
              mock.call('pstorage-mount', '-c', cluster_name, mount_point,
                        root_helper='true', check_exit_code=0,
                        run_as_root=True)]
     self.mock_execute.assert_has_calls(calls)
Example #4
0
    def __init__(self, execute=putils.execute, *args, **kwargs):
        self._remotefsclient = None
        super(VZStorageDriver, self).__init__(*args, **kwargs)
        self.configuration.append_config_values(vzstorage_opts)
        self._execute_as_root = False
        root_helper = utils.get_root_helper()
        # base bound to instance is used in RemoteFsConnector.
        self.base = self.configuration.vzstorage_mount_point_base
        opts = self.configuration.vzstorage_mount_options

        self._remotefsclient = remotefs.VZStorageRemoteFSClient(
            'vzstorage',
            root_helper,
            execute=execute,
            vzstorage_mount_point_base=self.base,
            vzstorage_mount_options=opts)
Example #5
0
 def test_vzstorage_invalid_share(self, mock_read_mounts):
     client = remotefs.VZStorageRemoteFSClient(
         "vzstorage", root_helper='true', vzstorage_mount_point_base='/mnt')
     self.assertRaises(exception.BrickException, client.mount, ':')