Skip to content

Commit

Permalink
Add lvm2 version check to pass the --fs flag along
Browse files Browse the repository at this point in the history
Signed-off-by: Brooklyn Dewolf <[email protected]>
  • Loading branch information
BrooklynDewolf committed May 23, 2024
1 parent 23ee0ba commit 701bfe8
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions lib/vdsm/storage/lvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ def fromlvm(cls, *args):
args[cls._fields.index("attr")] = attrs
# Add properties. Should be ordered as VG_PROPERTIES.
args.append(attrs.permission == "w") # writable
args.append(attrs.devopen == "o") # opened
args.append(attrs.state == "a") # active
args.append(attrs.devopen == "o") # opened
args.append(attrs.state == "a") # active
return cls(*args)

def is_stale(self):
Expand Down Expand Up @@ -240,6 +240,7 @@ def __getattr__(self, attrName):

USE_DEVICES = config.get("lvm", "config_method").lower() == "devices"


def _get_lvm_version():
packages = osinfo.package_versions()
lvm_version = tuple(
Expand All @@ -248,6 +249,7 @@ def _get_lvm_version():
)
return lvm_version


def _prepare_device_set(devs):
devices = set(d.strip() for d in chain(devs, USER_DEV_LIST))
devices.discard('')
Expand Down Expand Up @@ -1281,7 +1283,7 @@ def changelv(vg, lvs, attrs):
cmd.extend(attr)
cmd.extend(lvnames)
try:
_lvminfo.run_command(tuple(cmd), devices=_lvminfo._getVGDevs((vg, )))
_lvminfo.run_command(tuple(cmd), devices=_lvminfo._getVGDevs((vg,)))
finally:
_lvminfo._invalidatelvs(vg, lvs)

Expand Down Expand Up @@ -1312,6 +1314,7 @@ def _lvs_proc_info(vg, lvs):
paths = [lvPath(vg, lv) for lv in lvs]
return {p: list(lsof.proc_info(p)) for p in paths}


#
# Public Object Accessors
#
Expand Down Expand Up @@ -1367,7 +1370,7 @@ def resizePV(vgName, guid):
pvName = _fqpvname(guid)
cmd = ["pvresize", pvName]
try:
_lvminfo.run_command(cmd, devices=_lvminfo._getVGDevs((vgName, )))
_lvminfo.run_command(cmd, devices=_lvminfo._getVGDevs((vgName,)))
except se.LVMCommandError as e:
raise se.CouldNotResizePhysicalVolume.from_lvmerror(e)
else:
Expand Down Expand Up @@ -1403,7 +1406,7 @@ def movePV(vgName, src_device, dst_devices):
try:
# lvmpolld has to be disabled: https://bugzilla.redhat.com/1949059
_lvminfo.run_command(
cmd, devices=_lvminfo._getVGDevs((vgName, )), use_lvmpolld=False)
cmd, devices=_lvminfo._getVGDevs((vgName,)), use_lvmpolld=False)
except se.LVMCommandError as e:
raise se.CouldNotMovePVData.from_lvmerror(e)
finally:
Expand Down Expand Up @@ -1496,7 +1499,7 @@ def removeVG(vgName):
# if vg is removed they are staled, if vg remove failed, something must be
# wrong with devices and we want cache updated as well
try:
_lvminfo.run_command(cmd, devices=_lvminfo._getVGDevs((vgName, )))
_lvminfo.run_command(cmd, devices=_lvminfo._getVGDevs((vgName,)))
except se.LVMCommandError as e:
_lvminfo._invalidatevgpvs(vgName)
# If vgremove failed reintroduce the VG into the cache
Expand All @@ -1523,7 +1526,7 @@ def extendVG(vgName, devices, force):
_initpvs(pvs, int(vg.vg_mda_size) // MiB, force)

cmd = ["vgextend", vgName] + pvs
devs = tuple(_lvminfo._getVGDevs((vgName, )) + tuple(pvs))
devs = tuple(_lvminfo._getVGDevs((vgName,)) + tuple(pvs))

try:
_lvminfo.run_command(cmd, devices=devs)
Expand Down Expand Up @@ -1561,7 +1564,7 @@ def reduceVG(vgName, device):
log.info("Removing pv %s from vg %s", pvName, vgName)
cmd = ["vgreduce", vgName, pvName]
try:
_lvminfo.run_command(cmd, devices=_lvminfo._getVGDevs((vgName, )))
_lvminfo.run_command(cmd, devices=_lvminfo._getVGDevs((vgName,)))
except se.LVMCommandError as e:
raise se.VolumeGroupReduceError.from_lvmerror(e)
else:
Expand All @@ -1572,7 +1575,7 @@ def reduceVG(vgName, device):
def chkVG(vgName):
cmd = ["vgck", vgName]
try:
_lvminfo.run_command(cmd, devices=_lvminfo._getVGDevs((vgName, )))
_lvminfo.run_command(cmd, devices=_lvminfo._getVGDevs((vgName,)))
except se.LVMCommandError:
_lvminfo._invalidatevgs(vgName)
_lvminfo._invalidatelvs(vgName)
Expand Down Expand Up @@ -1641,6 +1644,7 @@ def getVGBlockSizes(vg_name):
# devices with different block size to be on the same VG.
return _getpvblksize(listPVNames(vg_name)[0])


#
# Public Logical volume interface
#
Expand Down Expand Up @@ -1676,7 +1680,7 @@ def createLV(vgName, lvName, size, activate=True, contiguous=False,
cmd.append(_fqpvname(device))

try:
_lvminfo.run_command(cmd, devices=_lvminfo._getVGDevs((vgName, )))
_lvminfo.run_command(cmd, devices=_lvminfo._getVGDevs((vgName,)))
except se.LVMCommandError as e:
raise se.CannotCreateLogicalVolume.from_lvmerror(e)
else:
Expand Down Expand Up @@ -1721,7 +1725,7 @@ def removeLVs(vgName, lvNames):
cmd.append("%s/%s" % (vgName, lvName))

try:
_lvminfo.run_command(cmd, devices=_lvminfo._getVGDevs((vgName, )))
_lvminfo.run_command(cmd, devices=_lvminfo._getVGDevs((vgName,)))
except se.LVMCommandError as e:
# LV info needs to be refreshed
_lvminfo._invalidatelvs(vgName, lvNames)
Expand Down Expand Up @@ -1872,7 +1876,7 @@ def _refreshLVs(vgName, lvNames):
cmd = ['lvchange', '--refresh']
cmd.extend("%s/%s" % (vgName, lv) for lv in lvNames)
try:
_lvminfo.run_command(cmd, devices=_lvminfo._getVGDevs((vgName, )))
_lvminfo.run_command(cmd, devices=_lvminfo._getVGDevs((vgName,)))
except se.LVMCommandError as e:
_lvminfo._invalidatelvs(vgName, lvNames)
raise se.LogicalVolumeRefreshError.from_lvmerror(e)
Expand Down Expand Up @@ -1948,7 +1952,7 @@ def changeVGTags(vgName, delTags=(), addTags=()):

cmd.append(vgName)
try:
_lvminfo.run_command(cmd, devices=_lvminfo._getVGDevs((vgName, )))
_lvminfo.run_command(cmd, devices=_lvminfo._getVGDevs((vgName,)))
except se.LVMCommandError as e:
raise se.VolumeGroupReplaceTagError.from_lvmerror(e)
finally:
Expand Down

0 comments on commit 701bfe8

Please sign in to comment.