# 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/initiator/linuxscsi.py
# LOG = logging.getLogger(__name__)
# MULTIPATH_ERROR_REGEX = re.compile(r"\w{3} \d+ \d\d:\d\d:\d\d \|.*$")
# MULTIPATH_WWID_REGEX = re.compile(r"\((?P<wwid>.+)\)")
# MULTIPATH_DEVICE_ACTIONS = ['unchanged:', 'reject:', 'reload:',
#                             'switchpg:', 'rename:', 'create:',
#                             'resize:']
#     WWN_TYPES = {'t10.': '1', 'eui.': '2', 'naa.': '3'}
# class LinuxSCSI(executor.Executor):
#     def echo_scsi_command(self, path, content) -> None:
#     def get_name_from_path(self, path) -> Optional[str]:
#     def remove_scsi_device(self,
#                            device: str,
#                            force: bool = False,
#                            exc=None,
#                            flush: bool = True) -> None:
#     def wait_for_volumes_removal(self, volumes_names: List[str]) -> None:
#     def get_device_info(self, device: str) -> Dict[str, Optional[str]]:
#     def get_sysfs_wwn(self, device_names, mpath=None) -> str:
#     def get_sysfs_wwid(self, device_names):
#     def get_scsi_wwn(self, path):
#     def is_multipath_running(enforce_multipath,
#                              root_helper,
#                              execute=None) -> bool:
#     def get_dm_name(self, dm):
#     def find_sysfs_multipath_dm(self, device_names):
#     def get_dev_path(connection_properties, device_info):
#     def requires_flush(path, path_used, was_multipath):
#     def remove_connection(self, devices_names, force=False, exc=None,
#                           path_used=None, was_multipath=False):
#     def _remove_scsi_symlinks(self, devices_names):
#     def flush_device_io(self, device):
#     def flush_multipath_device(self, device_map_name):
#     def wait_for_path(self, volume_path):
#     def wait_for_rw(self, wwn, device_path):
#     def find_multipath_device_path(self, wwn):
#     def find_multipath_device(self, device):
#     def get_device_size(self, device):
#     def multipath_reconfigure(self):
#     def multipath_resize_map(self, mpath_id):
#     def extend_volume(self, volume_paths, use_multipath=False):
#     def process_lun_id(self, lun_ids):
#     def _format_lun_id(self, lun_id):
#     def get_hctl(self, session, lun):
#     def device_name_by_hctl(self, session, hctl):
#     def scan_iscsi(self, host, channel='-', target='-', lun='-'):
#     def multipath_add_wwid(self, wwid):
#     def multipath_add_path(self, realpath):
#     def multipath_del_path(self, realpath):
# 
# 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 os.path
import textwrap
import ddt
from unittest import mock
from oslo_concurrency import processutils as putils
from oslo_log import log as logging
from os_brick import exception
from os_brick.initiator import linuxscsi
from os_brick.tests import base
# (c) Copyright 2013 Hewlett-Packard Development Company, L.P.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.




LOG = logging.getLogger(__name__)


@ddt.ddt
class LinuxSCSITestCase(base.TestCase):
    def setUp(self):
        super(LinuxSCSITestCase, self).setUp()
        self.cmds = []
        self.realpath = os.path.realpath
        self.mock_object(os.path, 'realpath', return_value='/dev/sdc')
        self.mock_object(os, 'stat', returns=os.stat(__file__))

# 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/initiator/linuxscsi.py
# LOG = logging.getLogger(__name__)
# MULTIPATH_ERROR_REGEX = re.compile(r"\w{3} \d+ \d\d:\d\d:\d\d \|.*$")
# MULTIPATH_WWID_REGEX = re.compile(r"\((?P<wwid>.+)\)")
# MULTIPATH_DEVICE_ACTIONS = ['unchanged:', 'reject:', 'reload:',
#                             'switchpg:', 'rename:', 'create:',
#                             'resize:']
#     WWN_TYPES = {'t10.': '1', 'eui.': '2', 'naa.': '3'}
# class LinuxSCSI(executor.Executor):
#     def echo_scsi_command(self, path, content) -> None:
#     def get_name_from_path(self, path) -> Optional[str]:
#     def remove_scsi_device(self,
#                            device: str,
#                            force: bool = False,
#                            exc=None,
#                            flush: bool = True) -> None:
#     def wait_for_volumes_removal(self, volumes_names: List[str]) -> None:
#     def get_device_info(self, device: str) -> Dict[str, Optional[str]]:
#     def get_sysfs_wwn(self, device_names, mpath=None) -> str:
#     def get_sysfs_wwid(self, device_names):
#     def get_scsi_wwn(self, path):
#     def is_multipath_running(enforce_multipath,
#                              root_helper,
#                              execute=None) -> bool:
#     def get_dm_name(self, dm):
#     def find_sysfs_multipath_dm(self, device_names):
#     def get_dev_path(connection_properties, device_info):
#     def requires_flush(path, path_used, was_multipath):
#     def remove_connection(self, devices_names, force=False, exc=None,
#                           path_used=None, was_multipath=False):
#     def _remove_scsi_symlinks(self, devices_names):
#     def flush_device_io(self, device):
#     def flush_multipath_device(self, device_map_name):
#     def wait_for_path(self, volume_path):
#     def wait_for_rw(self, wwn, device_path):
#     def find_multipath_device_path(self, wwn):
#     def find_multipath_device(self, device):
#     def get_device_size(self, device):
#     def multipath_reconfigure(self):
#     def multipath_resize_map(self, mpath_id):
#     def extend_volume(self, volume_paths, use_multipath=False):
#     def process_lun_id(self, lun_ids):
#     def _format_lun_id(self, lun_id):
#     def get_hctl(self, session, lun):
#     def device_name_by_hctl(self, session, hctl):
#     def scan_iscsi(self, host, channel='-', target='-', lun='-'):
#     def multipath_add_wwid(self, wwid):
#     def multipath_add_path(self, realpath):
#     def multipath_del_path(self, realpath):
# 
# 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/initiator/test_linuxscsi.py
import os
import os.path
import textwrap
import ddt
from unittest import mock
from oslo_concurrency import processutils as putils
from oslo_log import log as logging
from os_brick import exception
from os_brick.initiator import linuxscsi
from os_brick.tests import base

# (c) Copyright 2013 Hewlett-Packard Development Company, L.P.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.




LOG = logging.getLogger(__name__)


@ddt.ddt
class LinuxSCSITestCase(base.TestCase):
    def setUp(self):
        super(LinuxSCSITestCase, self).setUp()
        self.cmds = []
        self.realpath = os.path.realpath
        self.mock_object(os.path, 'realpath', return_value='/dev/sdc')
        self.mock_object(os, 'stat', returns=os.stat(__file__))

        self.linuxscsi = linuxscsi.LinuxSCSI(None, execute=self.fake_execute)