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
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
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
def test_status_no_output(fake_run_status): dmsetup.run_status.out = NO_MULTIPATH_DEVICE assert list(dmsetup.status()) == []
def test_status_no_device(fake_run_status): dmsetup.run_status.out = NO_DEVICE_MAPPER_DEVICES assert list(dmsetup.status()) == []