Lines 1-6
Link Here
|
1 |
import base64 |
1 |
import base64 |
2 |
import os |
2 |
import os |
3 |
import logging |
3 |
import logging |
|
|
4 |
import re |
4 |
from ceph_volume import process, conf, terminal |
5 |
from ceph_volume import process, conf, terminal |
5 |
from ceph_volume.util import constants, system |
6 |
from ceph_volume.util import constants, system |
6 |
from ceph_volume.util.device import Device |
7 |
from ceph_volume.util.device import Device |
Lines 12-25
Link Here
|
12 |
mlogger = terminal.MultiLogger(__name__) |
13 |
mlogger = terminal.MultiLogger(__name__) |
13 |
|
14 |
|
14 |
def set_dmcrypt_no_workqueue(target_version: str = '2.3.4') -> None: |
15 |
def set_dmcrypt_no_workqueue(target_version: str = '2.3.4') -> None: |
15 |
""" |
16 |
"""Set `conf.dmcrypt_no_workqueue` to `True` if the installed version |
16 |
set `conf.dmcrypt_no_workqueue` to `True` if the available |
17 |
of `cryptsetup` is greater than or equal to the specified `target_version`. |
17 |
version of `cryptsetup` is greater or equal to `version` |
18 |
|
|
|
19 |
Depending on the crypsetup version, `cryptsetup --version` output can be different. |
20 |
Eg: |
21 |
|
22 |
CentOS Stream9: |
23 |
$ cryptsetup --version |
24 |
cryptsetup 2.6.0 flags: UDEV BLKID KEYRING FIPS KERNEL_CAPI PWQUALITY |
25 |
|
26 |
CentOS Stream8: |
27 |
$ cryptsetup --version |
28 |
cryptsetup 2.3.7 |
29 |
|
30 |
Args: |
31 |
target_version (str, optional): The minimum version required for setting |
32 |
`conf.dmcrypt_no_workqueue` to `True`. Defaults to '2.3.4'. |
33 |
|
34 |
Raises: |
35 |
RuntimeError: If failed to retrieve the cryptsetup version. |
36 |
RuntimeError: If failed to parse the cryptsetup version. |
37 |
RuntimeError: If failed to compare the cryptsetup version with the target version. |
18 |
""" |
38 |
""" |
19 |
command = ["cryptsetup", "--version"] |
39 |
command = ["cryptsetup", "--version"] |
20 |
out, err, rc = process.call(command) |
40 |
out, err, rc = process.call(command) |
|
|
41 |
|
42 |
# This regex extracts the version number from |
43 |
# the `cryptsetup --version` output |
44 |
pattern: str = r'\b\d+(\.\d+)*\b' |
45 |
|
46 |
if rc: |
47 |
raise RuntimeError(f"Can't retrieve cryptsetup version: {err}") |
48 |
|
21 |
try: |
49 |
try: |
22 |
if version.parse(out[0]) >= version.parse(f'cryptsetup {target_version}'): |
50 |
cryptsetup_version = re.match(pattern, out[0]) |
|
|
51 |
|
52 |
if cryptsetup_version is None: |
53 |
_output: str = "\n".join(out) |
54 |
raise RuntimeError('Error while checking cryptsetup version.\n', |
55 |
'`cryptsetup --version` output:\n', |
56 |
f'{_output}') |
57 |
|
58 |
if version.parse(cryptsetup_version.group(0)) >= version.parse(target_version): |
23 |
conf.dmcrypt_no_workqueue = True |
59 |
conf.dmcrypt_no_workqueue = True |
24 |
except IndexError: |
60 |
except IndexError: |
25 |
mlogger.debug(f'cryptsetup version check: rc={rc} out={out} err={err}') |
61 |
mlogger.debug(f'cryptsetup version check: rc={rc} out={out} err={err}') |