def test_main(self):
        with MockSCSI(MockGetLBAStatus(sbc)) as s:
            i = s.getlbastatus(0).result
            self.assertEqual(len(i['lbas']), 2)
            self.assertEqual(i['lbas'][0]['lba'], 1023)
            self.assertEqual(i['lbas'][0]['num_blocks'], 27)
            self.assertEqual(i['lbas'][0]['p_status'], P_STATUS.MAPPED)
            self.assertEqual(i['lbas'][1]['lba'], 200000)
            self.assertEqual(i['lbas'][1]['num_blocks'], 9999)
            self.assertEqual(i['lbas'][1]['p_status'], P_STATUS.DEALLOCATED)

            d = GetLBAStatus.unmarshall_datain(GetLBAStatus.marshall_datain(i))
            self.assertEqual(d, i)
def main():
    with MockSCSI(MockGetLBAStatus(sbc)) as s:
        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
Beispiel #3
0
    def getlbastatus(self, lba, **kwargs):
        """
        Returns a GetLBAStatus Instance

        :param lba: starting lba
        :param kwargs: a dict with key/value pairs
                       alloc_len = 16384: size of requested datain
        :return: a GetLBAStatus instance
        """
        opcode = next(get_opcode(self.device.opcodes, '9E'))
        cmd = GetLBAStatus(opcode, lba, **kwargs)
        self.execute(cmd)
        cmd.unmarshall()
        return cmd
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
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
Beispiel #6
0
    def getlbastatus(self, lba, **kwargs):
        """
        Returns a GetLBAStatus Instance

        :param lba: starting lba
        :param alloc_len = 16384: size of requested datain
        :return: a getlbastatus instance
        """
        return GetLBAStatus(self, lba, **kwargs)
Beispiel #7
0
    def getlbastatus(self,
                     lba,
                     **kwargs):
        """
        Returns a GetLBAStatus Instance

        :param lba: starting lba
        :param kwargs: a dict with key/value pairs
                       alloc_len = 16384: size of requested datain
        :return: a GetLBAStatus instance
        """
        opcode = next(get_opcode(self.device.opcodes, '9E'))
        cmd = GetLBAStatus(opcode,
                           lba,
                           **kwargs)
        self.execute(cmd)
        cmd.unmarshall()
        return cmd
def main():
    with MockSCSI(MockDevice(sbc)) as s:
        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
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