def __init__(self, device, readwrite=False): """ initialize a new instance :param device: the file descriptor :param readwrite: access type """ self._is_libiscsi = False self._is_linux_sgio = False self._opcodes = scsi_enum_command.spc if _have_libiscsi and device[:8] == 'iscsi://': self._iscsi = libiscsi.iscsi_create_context( 'iqn.2007-10.com.github:python-scsi') self._iscsi_url = libiscsi.iscsi_parse_full_url( self._iscsi, device) libiscsi.iscsi_set_targetname(self._iscsi, self._iscsi_url.target) libiscsi.iscsi_set_session_type(self._iscsi, libiscsi.ISCSI_SESSION_NORMAL) libiscsi.iscsi_set_header_digest( self._iscsi, libiscsi.ISCSI_HEADER_DIGEST_NONE_CRC32C) libiscsi.iscsi_full_connect_sync(self._iscsi, self._iscsi_url.portal, self._iscsi_url.lun) self._is_libiscsi = True elif _have_linux_sgio and device[:5] == '/dev/': self._is_linux_sgio = True self._fd = linux_sgio.open(device, bool(readwrite)) else: raise NotImplementedError('No backend implemented for %s' % device)
def __init__(self, device, readwrite=False): """ initialize a new instance of a SCSIDevice :param device: the file descriptor :param readwrite: access type """ self._is_libiscsi = False self._is_linux_sgio = False self._opcodes = scsi_enum_command.spc if _have_libiscsi and device[:8] == 'iscsi://': self._iscsi = libiscsi.iscsi_create_context('iqn.2007-10.com.github:python-scsi') self._iscsi_url = libiscsi.iscsi_parse_full_url(self._iscsi, device) libiscsi.iscsi_set_targetname(self._iscsi, self._iscsi_url.target) libiscsi.iscsi_set_session_type(self._iscsi, libiscsi.ISCSI_SESSION_NORMAL) libiscsi.iscsi_set_header_digest(self._iscsi, libiscsi.ISCSI_HEADER_DIGEST_NONE_CRC32C) libiscsi.iscsi_full_connect_sync(self._iscsi, self._iscsi_url.portal, self._iscsi_url.lun) self._is_libiscsi = True elif _have_linux_sgio and device[:5] == '/dev/': self._is_linux_sgio = True self._fd = linux_sgio.open(device, bool(readwrite)) else: raise NotImplementedError('No backend implemented for %s' % device)
def open(self): """ :param dev: :param read_write: :return: """ self._fd = linux_sgio.open(self._file_name, bool(self._read_write))
def open(self): """ :param dev: :param read_write: :return: """ self._fd = linux_sgio.open(self._file_name, bool(self._read_write)) self._ino = get_inode(self._file_name)