本文整理汇总了Python中pyscsi.utils.converter.scsi_ba_to_int函数的典型用法代码示例。如果您正苦于以下问题:Python scsi_ba_to_int函数的具体用法?Python scsi_ba_to_int怎么用?Python scsi_ba_to_int使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scsi_ba_to_int函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main():
dev = MockReadElementStatus()
dev.opcodes = smc
s = SCSI(dev)
s.device.opcodes = smc
# cdb for SMC: ReadElementStatus
r = s.readelementstatus(300, 700, element_type=READELEMENTSTATUS.ELEMENT_TYPE.STORAGE, voltag=1, curdata=1, dvcid=1)
cdb = r.cdb
assert cdb[0] == s.device.opcodes.READ_ELEMENT_STATUS.value
assert cdb[1] == 0x10 | READELEMENTSTATUS.ELEMENT_TYPE.STORAGE
assert scsi_ba_to_int(cdb[2:4]) == 300
assert scsi_ba_to_int(cdb[4:6]) == 700
assert cdb[6] == 0x03
assert scsi_ba_to_int(cdb[7:10]) == 16384
cdb = r.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.READ_ELEMENT_STATUS.value
assert cdb['voltag'] == 1
assert cdb['element_type'] == READELEMENTSTATUS.ELEMENT_TYPE.STORAGE
assert cdb['starting_element_address'] == 300
assert cdb['num_elements'] == 700
assert cdb['curdata'] == 1
assert cdb['dvcid'] == 1
assert cdb['alloc_len'] == 16384
d = ReadElementStatus.unmarshall_cdb(ReadElementStatus.marshall_cdb(cdb))
assert d == cdb
开发者ID:Katana-Steel,项目名称:python-scsi,代码行数:26,代码来源:test_cdb_readelementstatus.py
示例2: main
def main():
with MockSCSI(MockDevice(spc)) as s:
# cdb for standard page request
i = s.inquiry(alloclen=128)
cdb = i.cdb
assert cdb[0] == s.device.opcodes.INQUIRY.value
assert cdb[1:3] == bytearray(2)
assert scsi_ba_to_int(cdb[3:5]) == 128
assert cdb[5] == 0
cdb = i.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.INQUIRY.value
assert cdb['evpd'] == 0
assert cdb['page_code'] == 0
assert cdb['alloc_len'] == 128
d = Inquiry.unmarshall_cdb(Inquiry.marshall_cdb(cdb))
assert d == cdb
# supported vpd pages
i = s.inquiry(evpd=1, page_code=0x88, alloclen=300)
cdb = i.cdb
assert cdb[0] == s.device.opcodes.INQUIRY.value
assert cdb[1] == 0x01
assert cdb[2] == 0x88
assert scsi_ba_to_int(cdb[3:5]) == 300
assert cdb[5] == 0
cdb = i.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.INQUIRY.value
assert cdb['evpd'] == 1
assert cdb['page_code'] == 0x88
assert cdb['alloc_len'] == 300
d = Inquiry.unmarshall_cdb(Inquiry.marshall_cdb(cdb))
assert d == cdb
开发者ID:rosjat,项目名称:python-scsi,代码行数:34,代码来源:test_cdb_inquiry.py
示例3: main
def main():
dev = MockMoveMedium()
dev.opcodes = smc
s = SCSI(dev)
s.device.opcodes = smc
m = s.exchangemedium(15, 32, 64, 32, inv1=1)
cdb = m.cdb
assert cdb[0] == s.device.opcodes.EXCHANGE_MEDIUM.value
assert cdb[1] == 0
assert scsi_ba_to_int(cdb[2:4]) == 15
assert scsi_ba_to_int(cdb[4:6]) == 32
assert scsi_ba_to_int(cdb[6:8]) == 64
assert scsi_ba_to_int(cdb[8:10]) == 32
assert cdb[10] == 0x02
cdb = m.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.EXCHANGE_MEDIUM.value
assert cdb['medium_transport_address'] == 15
assert cdb['source_address'] == 32
assert cdb['first_destination_address'] == 64
assert cdb['second_destination_address'] == 32
assert cdb['inv1'] == 1
assert cdb['inv2'] == 0
d = ExchangeMedium.unmarshall_cdb(ExchangeMedium.marshall_cdb(cdb))
assert d == cdb
开发者ID:Katana-Steel,项目名称:python-scsi,代码行数:25,代码来源:test_cdb_exchangemedium.py
示例4: unmarshall_designator
def unmarshall_designator(type, data):
_d = {}
if type == inquiry_enums.DESIGNATOR.VENDOR_SPECIFIC:
_d['vendor_specific'] = data
if type == inquiry_enums.DESIGNATOR.T10_VENDOR_ID:
_d['t10_vendor_id'] = data[:8]
_d['vendor_specific_id'] = data[8:]
if type == inquiry_enums.DESIGNATOR.EUI_64:
if len(data) == 8:
_d['ieee_company_id'] = scsi_ba_to_int(data[:3])
_d['vendor_specific_extension_id'] = data[3:8]
if len(data) == 12:
_d['ieee_company_id'] = scsi_ba_to_int(data[:3])
_d['vendor_specific_extension_id'] = data[3:8]
_d['directory_id'] = data[8:]
if len(data) == 16:
_d['identifier_extension'] = data[:8]
_d['ieee_company_id'] = scsi_ba_to_int(data[8:11])
_d['vendor_specific_extension_id'] = data[11:]
if type == inquiry_enums.DESIGNATOR.NAA:
decode_bits(data, Inquiry._naa_type_bits, _d)
if _d['naa'] == inquiry_enums.NAA.IEEE_EXTENDED:
decode_bits(data, Inquiry._naa_ieee_extended_bits, _d)
if _d['naa'] == inquiry_enums.NAA.LOCALLY_ASSIGNED:
decode_bits(data, Inquiry._naa_locally_assigned_bits, _d)
if _d['naa'] == inquiry_enums.NAA.IEEE_REGISTERED:
decode_bits(data, Inquiry._naa_ieee_registered_bits, _d)
if _d['naa'] == inquiry_enums.NAA.IEEE_REGISTERED_EXTENDED:
decode_bits(data, Inquiry._naa_ieee_registered_extended_bits, _d)
if type == inquiry_enums.DESIGNATOR.RELATIVE_TARGET_PORT_IDENTIFIER:
decode_bits(data, Inquiry._relative_port_bits, _d)
if type == inquiry_enums.DESIGNATOR.TARGET_PORTAL_GROUP:
decode_bits(data, Inquiry._target_portal_group_bits, _d)
if type == inquiry_enums.DESIGNATOR.LOGICAL_UNIT_GROUP:
decode_bits(data, Inquiry._logical_unit_group_bits, _d)
if type == inquiry_enums.DESIGNATOR.MD5_LOGICAL_IDENTIFIER:
_d['md5_logical_identifier'] = data[0:16]
if type == inquiry_enums.DESIGNATOR.SCSI_NAME_STRING:
_d['scsi_name_string'] = data
if type == inquiry_enums.DESIGNATOR.PCI_EXPRESS_ROUTING_ID:
decode_bits(data, Inquiry._pci_express_routing_id_bits, _d)
return _d
开发者ID:harapr-fds,项目名称:python-scsi,代码行数:52,代码来源:scsi_cdb_inquiry.py
示例5: unmarshall_datain
def unmarshall_datain(data):
"""
"""
result = {}
_esd = []
decode_bits(data, ReadElementStatus._datain_bits, result)
#
# Loop over the remaining data until we have consumed all
# element status pages
#
_bc = scsi_ba_to_int(data[5:8])
data = data[8:8 + _bc]
while len(data):
_r = {}
_bc = scsi_ba_to_int(data[5:8])
_edl = scsi_ba_to_int(data[2:4])
decode_bits(data, ReadElementStatus._element_status_page_bits, _r)
_d = data[8:8 + _bc]
_ed = []
while len(_d):
_rr = {}
decode_bits(_d, ReadElementStatus._element_status_descriptor_bits, _rr)
_dd = _d[12:]
if _r['pvoltag']:
_rr.update({'primary_volume_tag': _dd[0:36]})
_dd = _dd[36:]
if _r['avoltag']:
_rr.update({'alternate_volume_tag': _dd[0:36]})
_dd = _dd[36:]
if _r['element_type'] == readelementstatus_enums.ELEMENT_TYPE.DATA_TRANSFER:
decode_bits(_d, ReadElementStatus._data_transfer_descriptor_bits, _rr)
if _r['element_type'] == readelementstatus_enums.ELEMENT_TYPE.STORAGE:
decode_bits(_d, ReadElementStatus._storage_descriptor_bits, _rr)
if _r['element_type'] == readelementstatus_enums.ELEMENT_TYPE.IMPORT_EXPORT:
decode_bits(_d, ReadElementStatus._import_export_descriptor_bits, _rr)
_ed.append(_rr)
_d = _d[_edl:]
_r.update({'element_descriptors': _ed})
_esd.append(_r)
data = data[8 + _bc:]
result.update({'element_status_pages': _esd})
return result
开发者ID:harapr-fds,项目名称:python-scsi,代码行数:50,代码来源:scsi_cdb_readelementstatus.py
示例6: unmarshall_datain
def unmarshall_datain(data):
"""
Unmarshall the ReportLuns datain buffer.
:param data: a byte array
:return result: a dic
"""
result = {}
_data = data[8:scsi_ba_to_int(data[:4]) + 4]
_luns = []
_count = 0
while len(_data):
# maybe we drop the whole "put a dict into the list for every lun" thing at all
_r = {}
decode_bits(_data[:8],
ReportLuns._datain_bits,
_r)
key = 'lun%s' % _count
_r[key] = _r.pop('lun')
_luns.append(_r)
_data = _data[8:]
_count += 1
result.update({'luns': _luns})
return result
开发者ID:Katana-Steel,项目名称:python-scsi,代码行数:25,代码来源:scsi_cdb_report_luns.py
示例7: main
def main():
dev = MockWrite12()
dev.opcodes = sbc
s = SCSI(dev)
s.blocksize = 512
data = bytearray(27 * 512)
w = s.write12(1024, 27, data)
cdb = w.cdb
assert cdb[0] == s.device.opcodes.WRITE_12.value
assert cdb[1] == 0
assert scsi_ba_to_int(cdb[2:6]) == 1024
assert scsi_ba_to_int(cdb[6:10]) == 27
assert cdb[10] == 0
assert cdb[11] == 0
cdb = w.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.WRITE_12.value
assert cdb['wrprotect'] == 0
assert cdb['dpo'] == 0
assert cdb['fua'] == 0
assert cdb['lba'] == 1024
assert cdb['group'] == 0
assert cdb['tl'] == 27
d = Write12.unmarshall_cdb(Write12.marshall_cdb(cdb))
assert d == cdb
w = s.write12(65536, 27, data, wrprotect=2, dpo=1, fua=1, group=19)
cdb = w.cdb
assert cdb[0] == s.device.opcodes.WRITE_12.value
assert cdb[1] == 0x58
assert scsi_ba_to_int(cdb[2:6]) == 65536
assert scsi_ba_to_int(cdb[6:10]) == 27
assert cdb[10] == 0x13
assert cdb[11] == 0
cdb = w.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.WRITE_12.value
assert cdb['wrprotect'] == 2
assert cdb['dpo'] == 1
assert cdb['fua'] == 1
assert cdb['lba'] == 65536
assert cdb['group'] == 19
assert cdb['tl'] == 27
d = Write12.unmarshall_cdb(Write12.marshall_cdb(cdb))
assert d == cdb
开发者ID:Katana-Steel,项目名称:python-scsi,代码行数:47,代码来源:test_cdb_write12.py
示例8: main
def main():
dev = MockRead16()
dev.opcodes = sbc
s = SCSI(dev)
s.blocksize = 512
r = s.read16(1024, 27)
cdb = r.cdb
assert cdb[0] == s.device.opcodes.READ_16.value
assert cdb[1] == 0
assert scsi_ba_to_int(cdb[2:10]) == 1024
assert scsi_ba_to_int(cdb[10:14]) == 27
assert cdb[14] == 0
assert cdb[15] == 0
cdb = r.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.READ_16.value
assert cdb['rdprotect'] == 0
assert cdb['dpo'] == 0
assert cdb['fua'] == 0
assert cdb['rarc'] == 0
assert cdb['lba'] == 1024
assert cdb['group'] == 0
assert cdb['tl'] == 27
d = Read16.unmarshall_cdb(Read16.marshall_cdb(cdb))
assert d == cdb
r = s.read16(1024, 27, rdprotect=2, dpo=1, fua=1, rarc=1, group=19)
cdb = r.cdb
assert cdb[0] == s.device.opcodes.READ_16.value
assert cdb[1] == 0x5c
assert scsi_ba_to_int(cdb[2:10]) == 1024
assert scsi_ba_to_int(cdb[10:14]) == 27
assert cdb[14] == 0x13
assert cdb[15] == 0
cdb = r.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.READ_16.value
assert cdb['rdprotect'] == 2
assert cdb['dpo'] == 1
assert cdb['fua'] == 1
assert cdb['rarc'] == 1
assert cdb['lba'] == 1024
assert cdb['group'] == 19
assert cdb['tl'] == 27
d = Read16.unmarshall_cdb(Read16.marshall_cdb(cdb))
assert d == cdb
开发者ID:Katana-Steel,项目名称:python-scsi,代码行数:47,代码来源:test_cdb_read16.py
示例9: main
def main():
with MockSCSI(MockDevice(sbc)) as s:
s.blocksize = 512
data = bytearray(27 * 512)
w = s.write10(1024, 27, data)
cdb = w.cdb
assert cdb[0] == s.device.opcodes.WRITE_10.value
assert cdb[1] == 0
assert scsi_ba_to_int(cdb[2:6]) == 1024
assert cdb[6] == 0
assert scsi_ba_to_int(cdb[7:9]) == 27
assert cdb[9] == 0
cdb = w.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.WRITE_10.value
assert cdb['wrprotect'] == 0
assert cdb['dpo'] == 0
assert cdb['fua'] == 0
assert cdb['lba'] == 1024
assert cdb['group'] == 0
assert cdb['tl'] == 27
d = Write10.unmarshall_cdb(Write10.marshall_cdb(cdb))
assert d == cdb
w = s.write10(65536, 27, data, wrprotect=2, dpo=1, fua=1, group=19)
cdb = w.cdb
assert cdb[0] == s.device.opcodes.WRITE_10.value
assert cdb[1] == 0x58
assert scsi_ba_to_int(cdb[2:6]) == 65536
assert cdb[6] == 0x13
assert scsi_ba_to_int(cdb[7:9]) == 27
assert cdb[9] == 0
cdb = w.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.WRITE_10.value
assert cdb['wrprotect'] == 2
assert cdb['dpo'] == 1
assert cdb['fua'] == 1
assert cdb['lba'] == 65536
assert cdb['group'] == 19
assert cdb['tl'] == 27
d = Write10.unmarshall_cdb(Write10.marshall_cdb(cdb))
assert d == cdb
开发者ID:rosjat,项目名称:python-scsi,代码行数:46,代码来源:test_cdb_write10.py
示例10: main
def main():
with MockSCSI(MockDevice(smc)) as s:
m = s.positiontoelement(15, 32, invert=1)
cdb = m.cdb
assert cdb[0] == s.device.opcodes.POSITION_TO_ELEMENT.value
assert cdb[1] == 0
assert scsi_ba_to_int(cdb[2:4]) == 15
assert scsi_ba_to_int(cdb[4:6]) == 32
assert cdb[8] == 0x01
cdb = m.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.POSITION_TO_ELEMENT.value
assert cdb['medium_transport_address'] == 15
assert cdb['destination_address'] == 32
assert cdb['invert'] == 1
d = PositionToElement.unmarshall_cdb(PositionToElement.marshall_cdb(cdb))
assert d == cdb
开发者ID:rosjat,项目名称:python-scsi,代码行数:17,代码来源:test_cdb_positiontoelement.py
示例11: unmarshall_datain
def unmarshall_datain(data):
"""
Unmarshall the ReportPriority datain.
"""
result = {}
# get the data after the ppd_len
_data = data[4:scsi_ba_to_int(data[:4])]
_descriptors = []
while len(_data):
_r = {}
_dict = dict(ReportPriority._datain_bits.copy)
_dict.update({'transport_id': [hex(scsi_ba_to_int(_data[6:7])), 8], })
decode_bits(_data[:8 + scsi_ba_to_int(_data[6:7])], _dict, _r)
_descriptors.append(_r)
_data = _data[scsi_ba_to_int(_r['adlen']) + 8:]
result.update({'priority_descriptors': _descriptors, })
return result
开发者ID:sahlberg,项目名称:python-scsi,代码行数:17,代码来源:scsi_cdb_report_priority.py
示例12: main
def main():
with MockSCSI(MockDevice(sbc)) as s:
s.blocksize = 512
r = s.read12(1024, 27)
cdb = r.cdb
assert cdb[0] == s.device.opcodes.READ_12.value
assert cdb[1] == 0
assert scsi_ba_to_int(cdb[2:6]) == 1024
assert scsi_ba_to_int(cdb[6:10]) == 27
assert cdb[10] == 0
assert cdb[11] == 0
cdb = r.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.READ_12.value
assert cdb['rdprotect'] == 0
assert cdb['dpo'] == 0
assert cdb['fua'] == 0
assert cdb['rarc'] == 0
assert cdb['lba'] == 1024
assert cdb['group'] == 0
assert cdb['tl'] == 27
d = Read12.unmarshall_cdb(Read12.marshall_cdb(cdb))
assert d == cdb
r = s.read12(1024, 27, rdprotect=2, dpo=1, fua=1, rarc=1, group=19)
cdb = r.cdb
assert cdb[0] == s.device.opcodes.READ_12.value
assert cdb[1] == 0x5c
assert scsi_ba_to_int(cdb[2:6]) == 1024
assert scsi_ba_to_int(cdb[6:10]) == 27
assert cdb[10] == 0x13
assert cdb[11] == 0
cdb = r.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.READ_12.value
assert cdb['rdprotect'] == 2
assert cdb['dpo'] == 1
assert cdb['fua'] == 1
assert cdb['rarc'] == 1
assert cdb['lba'] == 1024
assert cdb['group'] == 19
assert cdb['tl'] == 27
d = Read12.unmarshall_cdb(Read12.marshall_cdb(cdb))
assert d == cdb
开发者ID:rosjat,项目名称:python-scsi,代码行数:46,代码来源:test_cdb_read12.py
示例13: main
def main():
dev = MockRead10()
dev.opcodes = sbc
s = SCSI(dev)
r = s.read10(1024, 27)
cdb = r.cdb
assert cdb[0] == s.device.opcodes.READ_10.value
assert cdb[1] == 0
assert scsi_ba_to_int(cdb[2:6]) == 1024
assert cdb[6] == 0
assert scsi_ba_to_int(cdb[7:9]) == 27
assert cdb[9] == 0
cdb = r.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.READ_10.value
assert cdb['rdprotect'] == 0
assert cdb['dpo'] == 0
assert cdb['fua'] == 0
assert cdb['rarc'] == 0
assert cdb['lba'] == 1024
assert cdb['group'] == 0
assert cdb['tl'] == 27
d = Read10.unmarshall_cdb(Read10.marshall_cdb(cdb))
assert d == cdb
r = s.read10(1024, 27, rdprotect=2, dpo=1, fua=1, rarc=1, group=19)
cdb = r.cdb
assert cdb[0] == s.device.opcodes.READ_10.value
assert cdb[1] == 0x5c
assert scsi_ba_to_int(cdb[2:6]) == 1024
assert cdb[6] == 0x13
assert scsi_ba_to_int(cdb[7:9]) == 27
assert cdb[9] == 0
cdb = r.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.READ_10.value
assert cdb['rdprotect'] == 2
assert cdb['dpo'] == 1
assert cdb['fua'] == 1
assert cdb['rarc'] == 1
assert cdb['lba'] == 1024
assert cdb['group'] == 19
assert cdb['tl'] == 27
d = Read10.unmarshall_cdb(Read10.marshall_cdb(cdb))
assert d == cdb
开发者ID:c-r-h,项目名称:python-scsi,代码行数:46,代码来源:test_cdb_read10.py
示例14: main
def main():
dev = MockModeSense10()
dev.opcodes = smc
s = SCSI(dev)
# cdb for SMC: ElementAddressAssignment
m = s.modesense10(page_code=MODESENSE10.PAGE_CODE.ELEMENT_ADDRESS_ASSIGNMENT)
cdb = m.cdb
assert cdb[0] == s.device.opcodes.MODE_SENSE_10.value
assert cdb[1] == 0
assert cdb[2] == MODESENSE10.PAGE_CODE.ELEMENT_ADDRESS_ASSIGNMENT
assert cdb[3] == 0
assert cdb[4:6] == bytearray(2)
assert scsi_ba_to_int(cdb[7:9]) == 96
assert cdb[9] == 0
cdb = m.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.MODE_SENSE_10.value
assert cdb['dbd'] == 0
assert cdb['llbaa'] == 0
assert cdb['page_code'] == MODESENSE10.PAGE_CODE.ELEMENT_ADDRESS_ASSIGNMENT
assert cdb['pc'] == 0
assert cdb['sub_page_code'] == 0
assert cdb['alloc_len'] == 96
d = ModeSense10.unmarshall_cdb(ModeSense10.marshall_cdb(cdb))
assert d == cdb
m = s.modesense10(page_code=0, sub_page_code=3, llbaa=1, dbd=1, pc=MODESENSE10.PC.DEFAULT, alloclen=90)
cdb = m.cdb
assert cdb[0] == s.device.opcodes.MODE_SENSE_10.value
assert cdb[1] == 0x18
assert cdb[2] == MODESENSE10.PC.DEFAULT << 6
assert cdb[3] == 3
assert scsi_ba_to_int(cdb[7:9]) == 90
cdb = m.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.MODE_SENSE_10.value
assert cdb['dbd'] == 1
assert cdb['pc'] == MODESENSE10.PC.DEFAULT
assert cdb['page_code'] == 0
assert cdb['sub_page_code'] == 3
assert cdb['alloc_len'] == 90
assert cdb['llbaa'] == 1
d = ModeSense10.unmarshall_cdb(ModeSense10.marshall_cdb(cdb))
assert d == cdb
开发者ID:Katana-Steel,项目名称:python-scsi,代码行数:45,代码来源:test_cdb_modesense10.py
示例15: main
def main():
with MockSCSI(MockDevice(smc)) as s:
r = s.initializeelementstatuswithrange(15, 3, rng=1, fast=1)
cdb = r.cdb
assert cdb[0] == s.device.opcodes.INITIALIZE_ELEMENT_STATUS_WITH_RANGE.value
assert cdb[1] == 0x03
assert scsi_ba_to_int(cdb[2:4]) == 15
assert scsi_ba_to_int(cdb[6:8]) == 3
cdb = r.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.INITIALIZE_ELEMENT_STATUS_WITH_RANGE.value
assert cdb['starting_element_address'] == 15
assert cdb['number_of_elements'] == 3
assert cdb['fast'] == 1
assert cdb['range'] == 1
d = InitializeElementStatusWithRange.unmarshall_cdb(InitializeElementStatusWithRange.marshall_cdb(cdb))
assert d == cdb
开发者ID:rosjat,项目名称:python-scsi,代码行数:18,代码来源:test_cdb_initelementstatuswithrange.py
示例16: main
def main():
dev = MockGetLBAStatus()
dev.opcodes = sbc
s = SCSI(dev)
r = s.getlbastatus(19938722, alloclen=1112527)
cdb = r.cdb
assert cdb[0] == s.device.opcodes.SBC_OPCODE_9E.value
assert cdb[1] == s.device.opcodes.SBC_OPCODE_9E.serviceaction.GET_LBA_STATUS
assert scsi_ba_to_int(cdb[2:10]) == 19938722
assert scsi_ba_to_int(cdb[10:14]) == 1112527
assert cdb[14:16] == bytearray(2)
cdb = r.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.SBC_OPCODE_9E.value
assert cdb['service_action'] == s.device.opcodes.SBC_OPCODE_9E.serviceaction.GET_LBA_STATUS
assert cdb['lba'] == 19938722
assert cdb['alloc_len'] == 1112527
d = GetLBAStatus.unmarshall_cdb(GetLBAStatus.marshall_cdb(cdb))
assert d == cdb
开发者ID:Katana-Steel,项目名称:python-scsi,代码行数:20,代码来源:test_cdb_getlbastatus.py
示例17: unmarshall_datain
def unmarshall_datain(data):
"""
Unmarshall the ModeSense10 datain.
:param data: a byte array
:return result: a dict
"""
result = {}
_mps = []
decode_bits(data[0:8],
MODESENSE10.mode_parameter_header_bits,
result)
_bdl = scsi_ba_to_int(data[6:8])
block_descriptor = data[8:_bdl] # no one really use this variable in here ?
data = data[8 + _bdl:]
_r = {}
if not data[0] & 0x40:
decode_bits(data,
MODESENSE10.page_zero_bits,
_r)
data = data[2:]
else:
decode_bits(data,
MODESENSE10.sub_page_bits,
_r)
data = data[4:]
if _r['page_code'] == PAGE_CODE.ELEMENT_ADDRESS_ASSIGNMENT:
decode_bits(data,
MODESENSE10.element_address_bits,
_r)
if _r['page_code'] == PAGE_CODE.CONTROL:
if not 'sub_page_code' in _r:
decode_bits(data,
MODESENSE10.control_bits,
_r)
elif _r['sub_page_code'] == 1:
decode_bits(data,
MODESENSE10.control_extension_1_bits,
_r)
if _r['page_code'] == PAGE_CODE.DISCONNECT_RECONNECT:
if not 'sub_page_code' in _r:
decode_bits(data,
MODESENSE10.disconnect_reconnect_bits,
_r)
_mps.append(_r)
result.update({'mode_pages': _mps})
return result
开发者ID:Katana-Steel,项目名称:python-scsi,代码行数:53,代码来源:scsi_cdb_modesense10.py
示例18: main
def main():
with MockSCSI(MockDevice(smc)) as s:
m = s.movemedium(15, 32, 64, invert=1)
cdb = m.cdb
assert cdb[0] == s.device.opcodes.MOVE_MEDIUM.value
assert cdb[1] == 0
assert scsi_ba_to_int(cdb[2:4]) == 15
assert scsi_ba_to_int(cdb[4:6]) == 32
assert scsi_ba_to_int(cdb[6:8]) == 64
assert cdb[8] == 0
assert cdb[9] == 0
assert cdb[10] == 0x01
cdb = m.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.MOVE_MEDIUM.value
assert cdb['medium_transport_address'] == 15
assert cdb['source_address'] == 32
assert cdb['destination_address'] == 64
assert cdb['invert'] == 1
d = MoveMedium.unmarshall_cdb(MoveMedium.marshall_cdb(cdb))
assert d == cdb
开发者ID:rosjat,项目名称:python-scsi,代码行数:21,代码来源:test_cdb_movemedium.py
示例19: main
def main():
with MockSCSI(MockDevice(smc)) as s:
m = s.opencloseimportexportelement(32, s.device.opcodes.OPEN_CLOSE_IMPORT_EXPORT_ELEMENT.serviceaction.CLOSE_IMPORTEXPORT_ELEMENT)
cdb = m.cdb
assert cdb[0] == s.device.opcodes.OPEN_CLOSE_IMPORT_EXPORT_ELEMENT.value
assert scsi_ba_to_int(cdb[2:4]) == 32
assert cdb[4] == 0x01
cdb = m.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.OPEN_CLOSE_IMPORT_EXPORT_ELEMENT.value
assert cdb['element_address'] == 32
assert cdb['action_code'] == s.device.opcodes.OPEN_CLOSE_IMPORT_EXPORT_ELEMENT.serviceaction.CLOSE_IMPORTEXPORT_ELEMENT
d = OpenCloseImportExportElement.unmarshall_cdb(OpenCloseImportExportElement.marshall_cdb(cdb))
assert d == cdb
开发者ID:rosjat,项目名称:python-scsi,代码行数:14,代码来源:test_cdb_openclose_exportimport_element.py
示例20: main
def main():
dev = MockInitializeElementStatusWithRange()
dev.opcodes = smc
s = SCSI(dev)
# we need to reassign the right enum again because the MockDevice will return the wrong
# peripheral_device_type and therefor assign the spc enum instead of smc.
s.device.opcodes = smc
r = s.initializeelementstatuswithrange(15, 3, rng=1, fast=1)
cdb = r.cdb
assert cdb[0] == s.device.opcodes.INITIALIZE_ELEMENT_STATUS_WITH_RANGE.value
assert cdb[1] == 0x03
assert scsi_ba_to_int(cdb[2:4]) == 15
assert scsi_ba_to_int(cdb[6:8]) == 3
cdb = r.unmarshall_cdb(cdb)
assert cdb['opcode'] == s.device.opcodes.INITIALIZE_ELEMENT_STATUS_WITH_RANGE.value
assert cdb['starting_element_address'] == 15
assert cdb['number_of_elements'] == 3
assert cdb['fast'] == 1
assert cdb['range'] == 1
d = InitializeElementStatusWithRange.unmarshall_cdb(InitializeElementStatusWithRange.marshall_cdb(cdb))
assert d == cdb
开发者ID:Katana-Steel,项目名称:python-scsi,代码行数:24,代码来源:test_cdb_initelementstatuswithrange.py
注:本文中的pyscsi.utils.converter.scsi_ba_to_int函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论