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


Python SCSI.modesense6方法代码示例

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


在下文中一共展示了SCSI.modesense6方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from pyscsi.pyscsi.scsi import SCSI [as 别名]
# 或者: from pyscsi.pyscsi.scsi.SCSI import modesense6 [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 modesense6 [as 别名]
def main():
    dev = MockModeSense6()
    dev.opcodes = spc
    s = SCSI(dev)

    # cdb for SMC: ElementAddressAssignment
    m = s.modesense6(page_code=MODESENSE6.PAGE_CODE.ELEMENT_ADDRESS_ASSIGNMENT)
    cdb = m.cdb
    assert cdb[0] == s.device.opcodes.MODE_SENSE_6.value
    assert cdb[1] == 0
    assert cdb[2] == MODESENSE6.PAGE_CODE.ELEMENT_ADDRESS_ASSIGNMENT
    assert cdb[3] == 0
    assert cdb[4] == 96
    assert cdb[5] == 0
    cdb = m.unmarshall_cdb(cdb)
    assert cdb['opcode'] == s.device.opcodes.MODE_SENSE_6.value
    assert cdb['dbd'] == 0
    assert cdb['pc'] == 0
    assert cdb['page_code'] == MODESENSE6.PAGE_CODE.ELEMENT_ADDRESS_ASSIGNMENT
    assert cdb['sub_page_code'] == 0
    assert cdb['alloc_len'] == 96

    d = ModeSense6.unmarshall_cdb(ModeSense6.marshall_cdb(cdb))
    assert d == cdb

    m = s.modesense6(page_code=0, sub_page_code=3, dbd=1, pc=MODESENSE6.PC.DEFAULT, alloclen=90)
    cdb = m.cdb
    assert cdb[0] == s.device.opcodes.MODE_SENSE_6.value
    assert cdb[1] == 0x08
    assert cdb[2] == MODESENSE6.PC.DEFAULT << 6
    assert cdb[3] == 3
    assert cdb[4] == 90
    assert cdb[5] == 0
    cdb = m.unmarshall_cdb(cdb)
    assert cdb['opcode'] == s.device.opcodes.MODE_SENSE_6.value
    assert cdb['dbd'] == 1
    assert cdb['pc'] == MODESENSE6.PC.DEFAULT
    assert cdb['page_code'] == 0
    assert cdb['sub_page_code'] == 3
    assert cdb['alloc_len'] == 90

    d = ModeSense6.unmarshall_cdb(ModeSense6.marshall_cdb(cdb))
    assert d == cdb
开发者ID:c-r-h,项目名称:python-scsi,代码行数:45,代码来源:test_cdb_modesense6.py

示例3: main

# 需要导入模块: from pyscsi.pyscsi.scsi import SCSI [as 别名]
# 或者: from pyscsi.pyscsi.scsi.SCSI import modesense6 [as 别名]
def main():
    swp_on = 0
    swp_off = 0
    i = 1
    while i < len(sys.argv):
        if sys.argv[i] == '--help':
            return usage()
        if sys.argv[i] == '--on':
            del sys.argv[i]
            swp_on = 1
            continue
        if sys.argv[i] == '--off':
            del sys.argv[i]
            swp_off = 1
            continue
        i += 1

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

    device = sys.argv[1]

    sd = SCSIDevice(device)
    s = SCSI(sd)
    i = s.modesense6(page_code=MODESENSE6.PAGE_CODE.CONTROL).result

    if swp_on:
        i['mode_pages'][0]['swp'] = 1
        s.modeselect6(i)
        print 'Set SWP ON'
        return

    if swp_off:
        i['mode_pages'][0]['swp'] = 0
        s.modeselect6(i)
        print 'Set SWP OFF'
        return

    print 'SWP is %s' % ("ON" if i['mode_pages'][0]['swp'] else "OFF")
开发者ID:c-r-h,项目名称:python-scsi,代码行数:41,代码来源:swp.py

示例4: main

# 需要导入模块: from pyscsi.pyscsi.scsi import SCSI [as 别名]
# 或者: from pyscsi.pyscsi.scsi.SCSI import modesense6 [as 别名]
def main():
    # SMC ElementAddressAssignment
    dev = MockModeSenseEAA()
    dev.opcodes = spc
    s = SCSI(dev)
    i = s.modesense6(page_code=MODESENSE6.PAGE_CODE.ELEMENT_ADDRESS_ASSIGNMENT).result
    assert i['medium_type'] == 97
    assert i['device_specific_parameter'] == 98

    assert len(i['mode_pages']) == 1

    assert i['mode_pages'][0]['ps'] == 1
    assert i['mode_pages'][0]['spf'] == 0
    assert i['mode_pages'][0]['page_code'] == MODESENSE6.PAGE_CODE.ELEMENT_ADDRESS_ASSIGNMENT
    assert i['mode_pages'][0]['first_medium_transport_element_address'] == 257
    assert i['mode_pages'][0]['num_medium_transport_elements'] == 258
    assert i['mode_pages'][0]['first_storage_element_address'] == 259
    assert i['mode_pages'][0]['num_storage_elements'] == 260
    assert i['mode_pages'][0]['first_import_element_address'] == 261
    assert i['mode_pages'][0]['num_import_elements'] == 262
    assert i['mode_pages'][0]['first_data_transfer_element_address'] == 263
    assert i['mode_pages'][0]['num_data_transfer_elements'] == 264

    d = ModeSense6.unmarshall_datain(ModeSense6.marshall_datain(i))
    assert d == i

    # SPC Control
    dev = MockModeSenseControl()
    dev.opcodes = spc
    s = SCSI(dev)
    i = s.modesense6(page_code=MODESENSE6.PAGE_CODE.CONTROL).result
    assert i['medium_type'] == 0
    assert i['device_specific_parameter'] == 0x90

    assert len(i['mode_pages']) == 1

    assert i['mode_pages'][0]['ps'] == 1
    assert i['mode_pages'][0]['spf'] == 0
    assert i['mode_pages'][0]['page_code'] == MODESENSE6.PAGE_CODE.CONTROL
    assert i['mode_pages'][0]['tst'] == 4
    assert i['mode_pages'][0]['tmf_only'] == 1
    assert i['mode_pages'][0]['dpicz'] == 1
    assert i['mode_pages'][0]['d_sense'] == 1
    assert i['mode_pages'][0]['gltsd'] == 1
    assert i['mode_pages'][0]['rlec'] == 1
    assert i['mode_pages'][0]['queue_algorithm_modifier'] == 9
    assert i['mode_pages'][0]['nuar'] == 1
    assert i['mode_pages'][0]['qerr'] == 3
    assert i['mode_pages'][0]['vs'] == 1
    assert i['mode_pages'][0]['rac'] == 1
    assert i['mode_pages'][0]['ua_intlck_ctrl'] == 3
    assert i['mode_pages'][0]['swp'] == 1
    assert i['mode_pages'][0]['ato'] == 1
    assert i['mode_pages'][0]['tas'] == 1
    assert i['mode_pages'][0]['atmpe'] == 1
    assert i['mode_pages'][0]['rwwp'] == 1
    assert i['mode_pages'][0]['autoload_mode'] == 7
    assert i['mode_pages'][0]['busy_timeout_period'] == 500
    assert i['mode_pages'][0]['extended_self_test_completion_time'] == 700

    d = ModeSense6.unmarshall_datain(ModeSense6.marshall_datain(i))
    assert d == i

    # SPC Control Ext 1
    dev = MockModeSenseControlExt1()
    dev.opcodes = spc
    s = SCSI(dev)
    i = s.modesense6(page_code=MODESENSE6.PAGE_CODE.CONTROL, sub_page_code=1).result
    assert i['medium_type'] == 0
    assert i['device_specific_parameter'] == 0x90

    assert len(i['mode_pages']) == 1

    assert i['mode_pages'][0]['ps'] == 1
    assert i['mode_pages'][0]['spf'] == 1
    assert i['mode_pages'][0]['page_code'] == MODESENSE6.PAGE_CODE.CONTROL
    assert i['mode_pages'][0]['sub_page_code'] == 1
    assert i['mode_pages'][0]['tcmos'] == 1
    assert i['mode_pages'][0]['scsip'] == 1
    assert i['mode_pages'][0]['ialuae'] == 1
    assert i['mode_pages'][0]['initial_command_priority'] == 15
    assert i['mode_pages'][0]['maximum_sense_data_length'] == 29

    d = ModeSense6.unmarshall_datain(ModeSense6.marshall_datain(i))
    assert d == i

    # SPC Disconnect
    dev = MockModeSenseDisconnect()
    dev.opcodes = spc
    s = SCSI(dev)
    i = s.modesense6(page_code=MODESENSE6.PAGE_CODE.DISCONNECT_RECONNECT).result
    assert i['medium_type'] == 0
    assert i['device_specific_parameter'] == 0x90

    assert len(i['mode_pages']) == 1

    assert i['mode_pages'][0]['ps'] == 1
    assert i['mode_pages'][0]['spf'] == 0
    assert i['mode_pages'][0]['page_code'] == MODESENSE6.PAGE_CODE.DISCONNECT_RECONNECT
    assert i['mode_pages'][0]['buffer_full_ratio'] == 122
#.........这里部分代码省略.........
开发者ID:Katana-Steel,项目名称:python-scsi,代码行数:103,代码来源:test_unmarshall_modesense6.py


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