當前位置: 首頁>>代碼示例>>Python>>正文


Python SCSI.readelementstatus方法代碼示例

本文整理匯總了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)
開發者ID:c-r-h,項目名稱:python-scsi,代碼行數:58,代碼來源:mtx.py

示例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
開發者ID:Katana-Steel,項目名稱:python-scsi,代碼行數:28,代碼來源:test_cdb_readelementstatus.py

示例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
開發者ID:Katana-Steel,項目名稱:python-scsi,代碼行數:63,代碼來源:test_unmarshall_readelementstatus.py


注:本文中的pyscsi.pyscsi.scsi.SCSI.readelementstatus方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。