示例#1
0
def getPathsStatus():
    res = {}
    for devName, statusLine in dmsetup.status(target="multipath"):
        for m in PATH_STATUS_RE.finditer(statusLine):
            devNum, status = m.groups()
            physdevName = device_name(devNum)
            res[physdevName] = {"A": "active", "F": "failed"}[status]

    return res
示例#2
0
def multipath_status():
    res = {}
    for guid, paths in dmsetup.status(target="multipath"):
        statuses = []
        for m in PATH_STATUS_RE.finditer(paths):
            major_minor, status = m.groups()
            statuses.append(PathStatus(major_minor, status))

        res[guid] = statuses

    return res
示例#3
0
def test_status(fake_dmsetup):
    fake_dmsetup.write(DMSETUP_SCRIPT.format(FAKE_DMSETUP_OUTPUT))

    res = dmsetup.status(target="multipath")
    expected = [
        ("360014053d0b83eff3d347c48509fc426",
         " 0 104857600 multipath 2 0 1 0 3 2 E 0 1 1 67:16 F 4 0 E 0 1 1 65:240 A 84 0 E 0 1 1 66:64 A 39 0"
         ),  # NOQA: E501 (long line)
        ("3600140543cb8d7510d54f058c7b3f7ec",
         " 0 209715200 multipath 2 0 1 0 3 1 A 0 1 1 65:224 A 0 0 E 0 1 1 65:160 A 0 0 E 0 1 1 66:176 F 1 0"
         ),  # NOQA: E501 (long line)
    ]

    assert list(res) == expected
示例#4
0
def test_status_no_output(fake_run_status):
    dmsetup.run_status.out = NO_MULTIPATH_DEVICE
    assert list(dmsetup.status()) == []
示例#5
0
def test_status_no_device(fake_run_status):
    dmsetup.run_status.out = NO_DEVICE_MAPPER_DEVICES
    assert list(dmsetup.status()) == []