def supports_snapshot_lv_activation(self):
"""Property indicating whether snap activation changes are supported.
- Check for LVM version > 2.02.91.
+ Check for LVM version >= 2.02.91.
(LVM2 git: e8a40f6 Allow to activate snapshot)
:returns: True/False indicating support
def supports_lvchange_ignoreskipactivation(self):
"""Property indicating whether lvchange can ignore skip activation.
- Tests whether lvchange -K/--ignoreactivationskip exists.
+ Check for LVM version >= 2.02.99.
+ (LVM2 git: ab789c1bc add --ignoreactivationskip to lvchange)
"""
if self._supports_lvchange_ignoreskipactivation is not None:
return self._supports_lvchange_ignoreskipactivation
- cmd = ['lvchange', '--help']
- (out, err) = self._execute(*cmd)
-
- self._supports_lvchange_ignoreskipactivation = False
-
- lines = out.split('\n')
- for line in lines:
- if '-K' in line and '--ignoreactivationskip' in line:
- self._supports_lvchange_ignoreskipactivation = True
- break
+ self._supports_lvchange_ignoreskipactivation = (
+ self.get_lvm_version(self._root_helper) >= (2, 2, 99))
return self._supports_lvchange_ignoreskipactivation
self.vg._supports_snapshot_lv_activation = None
def test_lvchange_ignskipact_support_yes(self):
- """Tests the ability to test support for lvchange -K
-
- Stubs provide output for "lvchange --help".
- """
-
- def lvchange_ign_yes(obj, *args, **kwargs):
- return ("""
- WARNING: Running as a non-root user. Functionality may be
- unavailable.
- lvchange: Change the attributes of logical volume(s)
-
- lvchange
- [-A|--autobackup y|n]
- [-k|--setactivationskip {y|n}]
- [-K|--ignoreactivationskip]
- [-y|--yes]
- [-Z|--zero {y|n}]
- LogicalVolume[Path] [LogicalVolume[Path]...]
- """, "")
+ """Tests if lvchange -K is available via a lvm2 version check."""
self.vg._supports_lvchange_ignoreskipactivation = None
- self.stubs.Set(self.vg, '_execute', lvchange_ign_yes)
+ self.stubs.Set(processutils, 'execute', self.fake_pretend_lvm_version)
self.assertTrue(self.vg.supports_lvchange_ignoreskipactivation)
self.vg._supports_lvchange_ignoreskipactivation = None
-
- def test_lvchange_ignskipact_support_no(self):
- def lvchange_ign_no(obj, *args, **kwargs):
- return ("""
- WARNING: Running as a non-root user. Functionality may be
- unavailable.
- lvchange: Change the attributes of logical volume(s)
-
- lvchange
- [-A|--autobackup y|n]
- [-k|--setactivationskip {y|n}]
- [-y|--yes]
- [-Z|--zero {y|n}]
- LogicalVolume[Path] [LogicalVolume[Path]...]
- """, "")
-
- self.vg._supports_lvchange_ignoreskipactivation = None
- self.stubs.Set(self.vg, '_execute', lvchange_ign_no)
+ self.stubs.Set(processutils, 'execute', self.fake_old_lvm_version)
self.assertFalse(self.vg.supports_lvchange_ignoreskipactivation)
self.vg._supports_lvchange_ignoreskipactivation = None