"""Parse one line of the lvs output used in L{_GetLvInfo}.
"""
- elems = line.strip().rstrip(sep).split(sep)
+ elems = line.strip().split(sep)
+
+ # The previous iteration of code here assumed that LVM might put another
+ # separator to the right of the output. The PV info might be empty for
+ # thin volumes, so stripping off the separators might cut off the last
+ # empty element - do this instead.
+ if len(elems) == 7 and elems[-1] == "":
+ elems.pop()
+
if len(elems) != 6:
base.ThrowError("Can't parse LVS output, len(%s) != 6", str(elems))
base.ThrowError("Can't parse the number of stripes: %s", err)
pv_names = []
- for pv in pvs.split(","):
- m = re.match(cls._PARSE_PV_DEV_RE, pv)
- if not m:
- base.ThrowError("Can't parse this device list: %s", pvs)
- pv_names.append(m.group(1))
- assert len(pv_names) > 0
+ if pvs != "":
+ for pv in pvs.split(","):
+ m = re.match(cls._PARSE_PV_DEV_RE, pv)
+ if not m:
+ base.ThrowError("Can't parse this device list: %s", pvs)
+ pv_names.append(m.group(1))
return (status, major, minor, pe_size, stripes, pv_names)
("-wi-a-", 253, 7, 4096.00, 4, ["/dev/abc"]),
("-ri-a-", 253, 4, 4.00, 5, ["/dev/abc", "/dev/def"]),
("-wc-ao", 15, 18, 4096.00, 32, ["/dev/abc", "/dev/def", "/dev/ghi0"]),
+ # Physical devices might be missing with thin volumes
+ ("twc-ao", 15, 18, 4096.00, 32, []),
]
for exp in true_out:
for sep in "#;|":