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


Python SCSI.readcapacity16方法代碼示例

本文整理匯總了Python中pyscsi.pyscsi.scsi.SCSI.readcapacity16方法的典型用法代碼示例。如果您正苦於以下問題:Python SCSI.readcapacity16方法的具體用法?Python SCSI.readcapacity16怎麽用?Python SCSI.readcapacity16使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pyscsi.pyscsi.scsi.SCSI的用法示例。


在下文中一共展示了SCSI.readcapacity16方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from pyscsi.pyscsi.scsi import SCSI [as 別名]
# 或者: from pyscsi.pyscsi.scsi.SCSI import readcapacity16 [as 別名]
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,代碼行數:35,代碼來源:getlbastatus.py

示例2: main

# 需要導入模塊: from pyscsi.pyscsi.scsi import SCSI [as 別名]
# 或者: from pyscsi.pyscsi.scsi.SCSI import readcapacity16 [as 別名]
def main(device):
    try:
        sd = SCSIDevice(device)
        s = SCSI(sd)

        print 'ReadCapacity16'
        print '==========================================\n'
        r = s.readcapacity16().result
        for k, v in r.iteritems():
            print '%s - %s' % (k, v)
    except Exception as e:
        print(e.message)
開發者ID:Katana-Steel,項目名稱:python-scsi,代碼行數:14,代碼來源:readcapacity16.py

示例3: main

# 需要導入模塊: from pyscsi.pyscsi.scsi import SCSI [as 別名]
# 或者: from pyscsi.pyscsi.scsi.SCSI import readcapacity16 [as 別名]
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,代碼行數:20,代碼來源:test_unmarshall_readcapacity16.py

示例4: main

# 需要導入模塊: from pyscsi.pyscsi.scsi import SCSI [as 別名]
# 或者: from pyscsi.pyscsi.scsi.SCSI import readcapacity16 [as 別名]
def main():
    dev = MockReadCapacity16()
    dev.opcodes = sbc
    s = SCSI(dev)

    r = s.readcapacity16(alloclen=37)
    cdb = r.cdb
    assert cdb[0] == s.device.opcodes.SBC_OPCODE_9E.value
    assert cdb[1] == s.device.opcodes.SBC_OPCODE_9E.serviceaction.READ_CAPACITY_16
    assert cdb[2:10] == bytearray(8)
    assert scsi_ba_to_int(cdb[10:14]) == 37
    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.READ_CAPACITY_16
    assert cdb['alloc_len'] == 37

    d = ReadCapacity16.unmarshall_cdb(ReadCapacity16.marshall_cdb(cdb))
    assert d == cdb
開發者ID:Katana-Steel,項目名稱:python-scsi,代碼行數:21,代碼來源:test_cdb_readcapacity16.py


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