if we reload lvs, why we don't update lvs that seg_start_pe != "0" ? there's in [1] with red mark.
def _reloadlvs(self, vgName, lvNames=None):
lvNames = _normalizeargs(lvNames)
cmd = list(LVS_CMD)
if lvNames:
cmd.extend(["%s/%s" % (vgName, lvName) for lvName in lvNames])
else:
cmd.append(vgName)
rc, out, err = self.cmd(cmd, self._getVGDevs((vgName,)))
with self._lock:
if rc != 0:
log.warning("lvm lvs failed: %s %s %s", str(rc), str(out),
str(err))
lvNames = lvNames if lvNames else self._lvs.keys()
for l in lvNames:
if isinstance(self._lvs.get(l), Stub):
self._lvs[l] = Unreadable(self._lvs[l].name, True)
return dict(self._lvs)
updatedLVs = {}
for line in out:
fields = [field.strip() for field in line.split(SEPARATOR)]
lv = makeLV(*fields)
# For LV we are only interested in its first extent
if lv.seg_start_pe == "0":
self._lvs[(lv.vg_name, lv.name)] = lv
updatedLVs[(lv.vg_name, lv.name)] = lv
# Determine if there are stale LVs
if lvNames:
staleLVs = (lvName for lvName in lvNames
if (vgName, lvName) not in updatedLVs.iterkeys())
else:
# All the LVs in the VG
staleLVs = (lvName for v, lvName in self._lvs.keys()
if (v == vgName) and
((vgName, lvName) not in updatedLVs.iterkeys()))
for lvName in staleLVs:
log.warning("Removing stale lv: %s/%s", vgName, lvName)
self._lvs.pop((vgName, lvName), None)
log.debug("lvs reloaded")
return updatedLVs