• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python scsi.SCSI类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了SCSI类的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():
    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


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


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


示例18: main

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

    i = s.readcapacity16().result
    assert i['returned_lba'] == 281474976710656
    assert i['block_length'] == 4096
    assert i['p_type'] == 4
    assert i['prot_en'] == 1
    assert i['p_i_exponent'] == 8
    assert i['lbppbe'] == 8
    assert i['lbpme'] == 1
    assert i['lbprz'] == 1
    assert i['lowest_aligned_lba'] == 8193

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


示例19: main

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

    w = s.testunitready()
    cdb = w.cdb
    assert cdb[0] == s.device.opcodes.TEST_UNIT_READY.value
    assert cdb[1] == 0
    assert cdb[2] == 0
    assert cdb[3] == 0
    assert cdb[4] == 0
    assert cdb[5] == 0
    cdb = w.unmarshall_cdb(cdb)
    assert cdb['opcode'] == s.device.opcodes.TEST_UNIT_READY.value

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


示例20: __init__

    def __init__(self, device):
        if not device:
            raise exceptions.CommandLineError(
                '--device parameter is required, should point to the disk '
                'device representing the meter.')

        self.device_name_ = device
        self.scsi_device_ = SCSIDevice(device, readwrite=True)
        self.scsi_ = SCSI(self.scsi_device_)
        self.scsi_.blocksize = _REGISTER_SIZE
开发者ID:Flameeyes,项目名称:glucometerutils,代码行数:10,代码来源:otverio2015.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python scsi_command.SCSICommand类代码示例发布时间:2022-05-27
下一篇:
Python pyscreenshot.grab函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap