当前位置: 首页>>代码示例>>Python>>正文


Python scsi.SCSI类代码示例

本文整理汇总了Python中pyscsi.pyscsi.scsi.SCSI的典型用法代码示例。如果您正苦于以下问题:Python SCSI类的具体用法?Python SCSI怎么用?Python SCSI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SCSI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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():
    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

示例3: main

def main():
    i = 1
    lba = 0
    while i < len(sys.argv):
        if sys.argv[i] == '--help':
            return usage()
        if sys.argv[i] == '-l':
            del sys.argv[i]
            lba = int(sys.argv[i], 10)
            del sys.argv[i]
            continue
        i += 1

    if len(sys.argv) < 2:
        return usage()

    device = sys.argv[1]

    sd = SCSIDevice(device)
    s = SCSI(sd)

    r = s.readcapacity16().result
    if not r['lbpme']:
        print 'LUN is fully provisioned.'
        return

    r = s.getlbastatus(lba).result
    for i in range(len(r['lbas'])):
        print 'LBA:%d-%d %s' % (
            r['lbas'][i]['lba'],
            r['lbas'][i]['lba'] + r['lbas'][i]['num_blocks'] - 1,
            P_STATUS[r['lbas'][i]['p_status']]
        )
开发者ID:Katana-Steel,项目名称:python-scsi,代码行数:33,代码来源:getlbastatus.py

示例4: main

def main():
    i = 1
    page_code = 0
    evpd = 0
    while i < len(sys.argv):
        if sys.argv[i] == '--help':
            return usage()
        if sys.argv[i] == '-p':
            del sys.argv[i]
            page_code = int(sys.argv[i], 16)
            evpd = 1
            del sys.argv[i]
            continue
        i += 1

    if len(sys.argv) < 2:
        return usage()

    device = sys.argv[1]

    sd = SCSIDevice(device)
    s = SCSI(sd)

    i = s.testunitready()

    if not evpd:
        inquiry_standard(s)
        return

    if page_code == INQUIRY.VPD.SUPPORTED_VPD_PAGES:
        inquiry_supported_vpd_pages(s)
        return

    if page_code == INQUIRY.VPD.BLOCK_LIMITS:
        inquiry_block_limits(s)
        return

    if page_code == INQUIRY.VPD.BLOCK_DEVICE_CHARACTERISTICS:
        inquiry_block_dev_char(s)
        return

    if page_code == INQUIRY.VPD.LOGICAL_BLOCK_PROVISIONING:
        inquiry_logical_block_prov(s)
        return

    if page_code == INQUIRY.VPD.UNIT_SERIAL_NUMBER:
        inquiry_unit_serial_number(s)
        return

    if page_code == INQUIRY.VPD.DEVICE_IDENTIFICATION:
        inquiry_device_identification(s)
        return

    print 'No pretty print for this page, page_code=0x%02x' % page_code
    print '=============================================\n'
    i = s.inquiry(evpd=1, page_code=page_code).result
    for k, v in i.iteritems():
        print '%s - %s' % (k, v)
开发者ID:c-r-h,项目名称:python-scsi,代码行数:58,代码来源:inquiry.py

示例5: main

def main(device):
    try:
        sd = SCSIDevice(device)
        s = SCSI(sd)
        print "ReportLuns"
        print "==========================================\n"
        r = s.reportluns().result
        for k, v in r.iteritems():
            print ("%s - %s" % (k, v))
    except Exception as e:
        print (e.message)
开发者ID:rosjat,项目名称:python-scsi,代码行数:11,代码来源:reportluns.py

示例6: main

def main():
    dev = MockReadCapacity10()
    dev.opcodes = sbc
    s = SCSI(dev)

    i = s.readcapacity10().result
    assert i["returned_lba"] == 65536
    assert i["block_length"] == 4096

    d = ReadCapacity10.unmarshall_datain(ReadCapacity10.marshall_datain(i))
    assert d == i
开发者ID:rosjat,项目名称:python-scsi,代码行数:11,代码来源:test_unmarshall_readcapacity10.py

示例7: main

def main(device):
    try:
        sd = SCSIDevice(device)
        s = SCSI(sd)
        print 'ReadCapacity10'
        print '==========================================\n'
        r = s.readcapacity10().result
        for k, v in r.iteritems():
            print '%s - %s' % (k, v)
    except Exception as e:
        print (e.message)
开发者ID:Katana-Steel,项目名称:python-scsi,代码行数:11,代码来源:readcapacity10.py

示例8: main

def main():
    dev = MockPreventAllowMediumRemoval()
    dev.opcodes = smc
    s = SCSI(dev)
    s.device.opcodes = smc
    m = s.preventallowmediumremoval(prevent=3)
    cdb = m.cdb
    assert cdb[0] == s.device.opcodes.PREVENT_ALLOW_MEDIUM_REMOVAL.value
    assert cdb[8] == 0x03
    cdb = m.unmarshall_cdb(cdb)
    assert cdb['opcode'] == s.device.opcodes.PREVENT_ALLOW_MEDIUM_REMOVAL.value
    assert cdb['prevent'] == 3

    d = PreventAllowMediumRemoval.unmarshall_cdb(PreventAllowMediumRemoval.marshall_cdb(cdb))
    assert d == cdb
开发者ID:Katana-Steel,项目名称:python-scsi,代码行数:15,代码来源:test_cdb_preventallow_mediumremoval.py

示例9: main

def main():
    dev = MockReadCapacity10()
    dev.opcodes = sbc
    s = SCSI(dev)

    s.device.opcodes = sbc
    r = s.readcapacity10()
    cdb = r.cdb
    assert cdb[0] == s.device.opcodes.READ_CAPACITY_10.value
    assert cdb[1:10] == bytearray(9)
    cdb = r.unmarshall_cdb(cdb)
    assert cdb['opcode'] == s.device.opcodes.READ_CAPACITY_10.value

    d = ReadCapacity10.unmarshall_cdb(ReadCapacity10.marshall_cdb(cdb))
    assert d == cdb
开发者ID:Katana-Steel,项目名称:python-scsi,代码行数:15,代码来源:test_cdb_readcapacity10.py

示例10: main

def main(device):
    try:
        sd = SCSIDevice(device)
        s = SCSI(sd)
        s.testunitready()
    except Exception as e:
        print (e)
    else:
        print ('ReportPriority')
        print ('==========================================\n')
        try:
            r = s.reportpriority().result
            for k, v in r.iteritems():
                print('%s - %s' % (k, v))
        except Exception as e:
                print (e)
开发者ID:Katana-Steel,项目名称:python-scsi,代码行数:16,代码来源:reportpriority.py

示例11: main

def main():
    dev = MockGetLBAStatus()
    dev.opcodes = sbc
    s = SCSI(dev)
    
    i = s.getlbastatus(0).result
    assert len(i['lbas']) == 2
    assert i['lbas'][0]['lba'] == 1023
    assert i['lbas'][0]['num_blocks'] == 27
    assert i['lbas'][0]['p_status'] == P_STATUS.MAPPED
    assert i['lbas'][1]['lba'] == 200000
    assert i['lbas'][1]['num_blocks'] == 9999
    assert i['lbas'][1]['p_status'] == P_STATUS.DEALLOCATED

    d = GetLBAStatus.unmarshall_datain(GetLBAStatus.marshall_datain(i))
    assert d == i
开发者ID:Katana-Steel,项目名称:python-scsi,代码行数:16,代码来源:test_unmarshall_getlbastatus.py

示例12: main

def main():
    dev = MockInitializeElementStatus()
    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.initializeelementstatus()
    cdb = r.cdb
    assert cdb[0] == s.device.opcodes.INITIALIZE_ELEMENT_STATUS.value
    cdb = r.unmarshall_cdb(cdb)
    assert cdb['opcode'] == s.device.opcodes.INITIALIZE_ELEMENT_STATUS.value

    d = InitializeElementStatus.unmarshall_cdb(InitializeElementStatus.marshall_cdb(cdb))
    assert d == cdb
开发者ID:Katana-Steel,项目名称:python-scsi,代码行数:16,代码来源:test_cdb_initelementstatus.py

示例13: 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

示例14: 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

示例15: main

def main():
    dev = MockOpenCloseImportExportElement()
    dev.opcodes = smc
    s = SCSI(dev)
    s.device.opcodes = smc
    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:Katana-Steel,项目名称:python-scsi,代码行数:17,代码来源:test_cdb_openclose_exportimport_element.py


注:本文中的pyscsi.pyscsi.scsi.SCSI类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。