# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
#     def __init__(self, message=None, **kwargs):
#     def __init__(self, *args, **kwargs):
#     def __repr__(self):
#     def __nonzero__(self) -> bool:
#     def add_exception(self, exc_type, exc_val, exc_tb) -> None:
#     def context(self,
#                 catch_exception: bool,
#                 msg: str = '',
#                 *msg_args: Iterable):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_val, exc_tb):
# 
# Path: os_brick/privileged/rootwrap.py
# LOG = logging.getLogger(__name__)
# def custom_execute(*cmd, **kwargs):
#     def on_timeout(proc):
#     def on_execute(proc):
#     def on_completion(proc):
# def execute(*cmd, **kwargs):
# def execute_root(*cmd, **kwargs):
# def unlink_root(*links, **kwargs):
# 
# Path: os_brick/remotefs/remotefs.py
# LOG = logging.getLogger(__name__)
# class RemoteFsClient(executor.Executor):
# class ScalityRemoteFsClient(RemoteFsClient):
# class VZStorageRemoteFSClient(RemoteFsClient):
#     def __init__(self, mount_type, root_helper,
#                  execute=None, *args, **kwargs):
#     def get_mount_base(self):
#     def _get_hash_str(self, base_str):
#     def get_mount_point(self, device_name: str):
#     def _read_mounts(self):
#     def mount(self, share, flags=None):
#     def _do_mount(self, mount_type, share, mount_path, mount_options=None,
#                   flags=None):
#     def _mount_nfs(self, nfs_share, mount_path, flags=None):
#     def _check_nfs_options(self):
#     def _option_exists(self, options, opt_pattern):
#     def _update_option(self, options, option, value=None):
#     def __init__(self, mount_type, root_helper,
#                  execute=None, *args, **kwargs):
#     def get_mount_point(self, device_name):
#     def mount(self, share, flags=None):
#     def _vzstorage_write_mds_list(self, cluster_name, mdss):
#     def _do_mount(self, mount_type, vz_share, mount_path,
#                   mount_options=None, flags=None):
# 
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
#     SENTINEL = object()
#     def setUp(self):
#     def _common_cleanup(self):
#     def log_level(self, level):
#     def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
#     def patch(self, path, *args, **kwargs):


import os
import tempfile
from unittest import mock
from oslo_concurrency import processutils as putils
from os_brick import exception
from os_brick.privileged import rootwrap as priv_rootwrap
from os_brick.remotefs import remotefs
from os_brick.tests import base
        mounts = {client.get_mount_point(share): 'some_dev'}
        with mock.patch.object(client, '_read_mounts',
                               return_value=mounts):
            client.mount(share)
            self.assertEqual(mock_do_mount.call_count, 0)
            self.assertEqual(mock_execute.call_count, 0)

    @mock.patch.object(priv_rootwrap, 'execute')
    def test_mount_race(self, mock_execute):
        err_msg = 'mount.nfs: /var/asdf is already mounted'
        mock_execute.side_effect = putils.ProcessExecutionError(stderr=err_msg)
        mounts = {'192.0.2.20:/share': '/var/asdf/'}
        client = remotefs.RemoteFsClient("nfs", root_helper='true',
                                         nfs_mount_point_base='/var/asdf')

        with mock.patch.object(client, '_read_mounts',
                               return_value=mounts):
            client._do_mount('nfs', '192.0.2.20:/share', '/var/asdf')

    @mock.patch.object(priv_rootwrap, 'execute')
    def test_mount_failure(self, mock_execute):
        err_msg = 'mount.nfs: nfs broke'
        mock_execute.side_effect = putils.ProcessExecutionError(stderr=err_msg)
        client = remotefs.RemoteFsClient("nfs", root_helper='true',
                                         nfs_mount_point_base='/var/asdf')
        self.assertRaises(putils.ProcessExecutionError,
                          client._do_mount,
                          'nfs', '192.0.2.20:/share', '/var/asdf')

    def _test_no_mount_point(self, fs_type):

# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
#     def __init__(self, message=None, **kwargs):
#     def __init__(self, *args, **kwargs):
#     def __repr__(self):
#     def __nonzero__(self) -> bool:
#     def add_exception(self, exc_type, exc_val, exc_tb) -> None:
#     def context(self,
#                 catch_exception: bool,
#                 msg: str = '',
#                 *msg_args: Iterable):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_val, exc_tb):
# 
# Path: os_brick/privileged/rootwrap.py
# LOG = logging.getLogger(__name__)
# def custom_execute(*cmd, **kwargs):
#     def on_timeout(proc):
#     def on_execute(proc):
#     def on_completion(proc):
# def execute(*cmd, **kwargs):
# def execute_root(*cmd, **kwargs):
# def unlink_root(*links, **kwargs):
# 
# Path: os_brick/remotefs/remotefs.py
# LOG = logging.getLogger(__name__)
# class RemoteFsClient(executor.Executor):
# class ScalityRemoteFsClient(RemoteFsClient):
# class VZStorageRemoteFSClient(RemoteFsClient):
#     def __init__(self, mount_type, root_helper,
#                  execute=None, *args, **kwargs):
#     def get_mount_base(self):
#     def _get_hash_str(self, base_str):
#     def get_mount_point(self, device_name: str):
#     def _read_mounts(self):
#     def mount(self, share, flags=None):
#     def _do_mount(self, mount_type, share, mount_path, mount_options=None,
#                   flags=None):
#     def _mount_nfs(self, nfs_share, mount_path, flags=None):
#     def _check_nfs_options(self):
#     def _option_exists(self, options, opt_pattern):
#     def _update_option(self, options, option, value=None):
#     def __init__(self, mount_type, root_helper,
#                  execute=None, *args, **kwargs):
#     def get_mount_point(self, device_name):
#     def mount(self, share, flags=None):
#     def _vzstorage_write_mds_list(self, cluster_name, mdss):
#     def _do_mount(self, mount_type, vz_share, mount_path,
#                   mount_options=None, flags=None):
# 
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
#     SENTINEL = object()
#     def setUp(self):
#     def _common_cleanup(self):
#     def log_level(self, level):
#     def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
#     def patch(self, path, *args, **kwargs):


# Path: os_brick/tests/remotefs/test_remotefs.py
import os
import tempfile
from unittest import mock
from oslo_concurrency import processutils as putils
from os_brick import exception
from os_brick.privileged import rootwrap as priv_rootwrap
from os_brick.remotefs import remotefs
from os_brick.tests import base

        mounts = {client.get_mount_point(share): 'some_dev'}
        with mock.patch.object(client, '_read_mounts',
                               return_value=mounts):
            client.mount(share)
            self.assertEqual(mock_do_mount.call_count, 0)
            self.assertEqual(mock_execute.call_count, 0)

    @mock.patch.object(priv_rootwrap, 'execute')
    def test_mount_race(self, mock_execute):
        err_msg = 'mount.nfs: /var/asdf is already mounted'
        mock_execute.side_effect = putils.ProcessExecutionError(stderr=err_msg)
        mounts = {'192.0.2.20:/share': '/var/asdf/'}
        client = remotefs.RemoteFsClient("nfs", root_helper='true',
                                         nfs_mount_point_base='/var/asdf')

        with mock.patch.object(client, '_read_mounts',
                               return_value=mounts):
            client._do_mount('nfs', '192.0.2.20:/share', '/var/asdf')

    @mock.patch.object(priv_rootwrap, 'execute')
    def test_mount_failure(self, mock_execute):
        err_msg = 'mount.nfs: nfs broke'
        mock_execute.side_effect = putils.ProcessExecutionError(stderr=err_msg)
        client = remotefs.RemoteFsClient("nfs", root_helper='true',
                                         nfs_mount_point_base='/var/asdf')
        self.assertRaises(putils.ProcessExecutionError,
                          client._do_mount,
                          'nfs', '192.0.2.20:/share', '/var/asdf')

    def _test_no_mount_point(self, fs_type):

        self.assertRaises(exception.InvalidParameterValue,