storage/lvm: add workaround for ancient lvm2 in Travis-CI environment

This commit is contained in:
Marek Marczykowski-Górecki 2016-11-25 02:04:09 +01:00
parent 2a4af124f8
commit bb4dc91ee8
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -27,6 +27,17 @@ import subprocess
import qubes
def check_lvm_version():
#Check if lvm is very very old, like in Travis-CI
try:
lvm_help = subprocess.check_output(['lvm', 'lvcreate', '--help'],
stderr=subprocess.DEVNULL).decode()
return '--setactivationskip' not in lvm_help
except subprocess.CalledProcessError:
pass
lvm_is_very_old = check_lvm_version()
class ThinPool(qubes.storage.Pool):
''' LVM Thin based pool implementation
''' # pylint: disable=protected-access
@ -437,6 +448,9 @@ def qubes_lvm(cmd, log=logging.getLogger('qube.storage.lvm')):
lvm_cmd = ["lvextend", "-L%s" % size, cmd[1]]
else:
raise NotImplementedError('unsupported action: ' + action)
if lvm_is_very_old:
# old lvm in trusty image used there does not support -k option
lvm_cmd = [x for x in lvm_cmd if x != '-kn']
if os.getuid() != 0:
cmd = ['sudo', 'lvm'] + lvm_cmd
else: