diff --git a/lib/vdsm/storage/lvm.py b/lib/vdsm/storage/lvm.py index a421da778..67adcc4b4 100644 --- a/lib/vdsm/storage/lvm.py +++ b/lib/vdsm/storage/lvm.py @@ -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): @@ -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( @@ -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('') @@ -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) @@ -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 # @@ -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: @@ -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: @@ -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 @@ -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) @@ -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: @@ -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) @@ -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 # @@ -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: @@ -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) @@ -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) @@ -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: