本文整理汇总了Python中pyscsi.pyscsi.scsi.SCSI.getlbastatus方法的典型用法代码示例。如果您正苦于以下问题:Python SCSI.getlbastatus方法的具体用法?Python SCSI.getlbastatus怎么用?Python SCSI.getlbastatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyscsi.pyscsi.scsi.SCSI
的用法示例。
在下文中一共展示了SCSI.getlbastatus方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pyscsi.pyscsi.scsi import SCSI [as 别名]
# 或者: from pyscsi.pyscsi.scsi.SCSI import getlbastatus [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']]
)
示例2: main
# 需要导入模块: from pyscsi.pyscsi.scsi import SCSI [as 别名]
# 或者: from pyscsi.pyscsi.scsi.SCSI import getlbastatus [as 别名]
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
示例3: main
# 需要导入模块: from pyscsi.pyscsi.scsi import SCSI [as 别名]
# 或者: from pyscsi.pyscsi.scsi.SCSI import getlbastatus [as 别名]
def main():
dev = MockGetLBAStatus()
dev.opcodes = sbc
s = SCSI(dev)
r = s.getlbastatus(19938722, alloclen=1112527)
cdb = r.cdb
assert cdb[0] == s.device.opcodes.SBC_OPCODE_9E.value
assert cdb[1] == s.device.opcodes.SBC_OPCODE_9E.serviceaction.GET_LBA_STATUS
assert scsi_ba_to_int(cdb[2:10]) == 19938722
assert scsi_ba_to_int(cdb[10:14]) == 1112527
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.GET_LBA_STATUS
assert cdb['lba'] == 19938722
assert cdb['alloc_len'] == 1112527
d = GetLBAStatus.unmarshall_cdb(GetLBAStatus.marshall_cdb(cdb))
assert d == cdb