本文整理汇总了Python中pyscsi.pyscsi.scsi.SCSI.readelementstatus方法的典型用法代码示例。如果您正苦于以下问题:Python SCSI.readelementstatus方法的具体用法?Python SCSI.readelementstatus怎么用?Python SCSI.readelementstatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyscsi.pyscsi.scsi.SCSI
的用法示例。
在下文中一共展示了SCSI.readelementstatus方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pyscsi.pyscsi.scsi import SCSI [as 别名]
# 或者: from pyscsi.pyscsi.scsi.SCSI import readelementstatus [as 别名]
def main():
device = ''
for i in range(len(sys.argv)):
if sys.argv[i] == '-f':
del sys.argv[i]
device = sys.argv[i]
del sys.argv[i]
break
if not device:
usage()
exit(1)
scsi = SCSI(SCSIDevice(device))
i = scsi.inquiry().result
if i['peripheral_device_type'] != INQUIRY.DEVICE_TYPE.MEDIA_CHANGER_DEVICE:
print '%s is not a MediaChanger device' % device
exit(1)
eaa = scsi.modesense6(page_code=MODESENSE6.PAGE_CODE.ELEMENT_ADDRESS_ASSIGNMENT).result['mode_pages'][0]
# get the data transfer elements
dte = scsi.readelementstatus(
start=eaa['first_data_transfer_element_address'],
num=eaa['num_data_transfer_elements'],
element_type=READELEMENTSTATUS.ELEMENT_TYPE.DATA_TRANSFER,
voltag=1, curdata=1, dvcid=1,
alloclen=16384).result['element_status_pages'][0]['element_descriptors']
# get all the storage elements
se = scsi.readelementstatus(
start=eaa['first_storage_element_address'],
num=eaa['num_storage_elements'],
element_type=READELEMENTSTATUS.ELEMENT_TYPE.STORAGE,
voltag=1, curdata=1, dvcid=1,
alloclen=16384).result['element_status_pages'][0]['element_descriptors']
# get all the medium transport elements
mte = scsi.readelementstatus(
start=eaa['first_medium_transport_element_address'],
num=eaa['num_medium_transport_elements'],
element_type=READELEMENTSTATUS.ELEMENT_TYPE.MEDIUM_TRANSPORT,
voltag=1, curdata=1, dvcid=1,
alloclen=16384).result['element_status_pages'][0]['element_descriptors']
if sys.argv[1] == 'status':
return status(scsi, dte, se)
if sys.argv[1] == 'load':
return load(scsi, mte, dte, se, int(sys.argv[2]), int(sys.argv[3]))
if sys.argv[1] == 'unload':
return unload(scsi, mte, dte, se, int(sys.argv[2]), int(sys.argv[3]))
usage()
exit(1)
示例2: main
# 需要导入模块: from pyscsi.pyscsi.scsi import SCSI [as 别名]
# 或者: from pyscsi.pyscsi.scsi.SCSI import readelementstatus [as 别名]
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
示例3: main
# 需要导入模块: from pyscsi.pyscsi.scsi import SCSI [as 别名]
# 或者: from pyscsi.pyscsi.scsi.SCSI import readelementstatus [as 别名]
def main():
dev = MockReadElementStatus()
dev.opcodes = smc
s = SCSI(dev)
s.device.opcodes = smc
i = s.readelementstatus(300, 700, element_type=READELEMENTSTATUS.ELEMENT_TYPE.STORAGE, voltag=1, curdata=1,
dvcid=1).result
assert i['first_element_address'] == 12
assert i['num_elements'] == 3
assert len(i['element_status_pages']) == 2
page = i['element_status_pages'][0]
assert page['element_type'] == 2
assert page['pvoltag'] == 0
assert page['avoltag'] == 0
assert len(page['element_descriptors']) == 1
assert page['element_descriptors'][0]['element_address'] == 12
assert page['element_descriptors'][0]['access'] == 1
assert page['element_descriptors'][0]['except'] == 1
assert page['element_descriptors'][0]['full'] == 1
assert page['element_descriptors'][0]['additional_sense_code'] == 55
assert page['element_descriptors'][0]['additional_sense_code_qualifier'] == 56
assert page['element_descriptors'][0]['svalid'] == 1
assert page['element_descriptors'][0]['invert'] == 1
assert page['element_descriptors'][0]['ed'] == 1
assert page['element_descriptors'][0]['medium_type'] == 2
assert page['element_descriptors'][0]['source_storage_element_address'] == 27
page = i['element_status_pages'][1]
assert page['element_type'] == 4
assert page['pvoltag'] == 0
assert page['avoltag'] == 0
assert len(page['element_descriptors']) == 2
assert page['element_descriptors'][0]['element_address'] == 13
assert page['element_descriptors'][0]['access'] == 1
assert page['element_descriptors'][0]['except'] == 1
assert page['element_descriptors'][0]['full'] == 0
assert page['element_descriptors'][0]['additional_sense_code'] == 55
assert page['element_descriptors'][0]['additional_sense_code_qualifier'] == 56
assert page['element_descriptors'][0]['svalid'] == 1
assert page['element_descriptors'][0]['invert'] == 1
assert page['element_descriptors'][0]['ed'] == 1
assert page['element_descriptors'][0]['medium_type'] == 7
assert page['element_descriptors'][0]['source_storage_element_address'] == 28
assert page['element_descriptors'][1]['element_address'] == 14
assert page['element_descriptors'][1]['access'] == 1
assert page['element_descriptors'][1]['except'] == 0
assert page['element_descriptors'][1]['full'] == 0
assert page['element_descriptors'][1]['additional_sense_code'] == 55
assert page['element_descriptors'][1]['additional_sense_code_qualifier'] == 56
assert page['element_descriptors'][1]['svalid'] == 1
assert page['element_descriptors'][1]['invert'] == 0
assert page['element_descriptors'][1]['ed'] == 0
assert page['element_descriptors'][1]['medium_type'] == 6
assert page['element_descriptors'][1]['source_storage_element_address'] == 29
d = ReadElementStatus.unmarshall_datain(ReadElementStatus.marshall_datain(i))
assert d == i