Skip to content

Commit c087cea

Browse files
committed
Merge remote-tracking branch 'origin/3.10-devel' into 3.10-release
2 parents 0fbc1d4 + 144c3e7 commit c087cea

File tree

113 files changed

+976
-738
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+976
-738
lines changed

.packit.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ actions:
44
- 'git config user.email "blivet-ci@example.com"'
55
- 'git config user.name "Blivet CI"'
66
# merge the release branch to get correct version in spec
7-
- 'git merge --ff origin/3.9-release'
7+
- 'git merge --ff origin/3.10-release'
88
# bump release to 99 to always be ahead of Fedora builds
99
- 'bash -c "sed -i -r \"s/Release:(\s*)\S+/Release: 99%{?dist}/\" python-blivet.spec"'
1010
get-current-version:
@@ -30,7 +30,7 @@ jobs:
3030
trigger: commit
3131
owner: "@storage"
3232
project: blivet-daily
33-
branch: 3.9-devel
33+
branch: 3.10-devel
3434
preserve_project: true
3535

3636
srpm_build_deps:

blivet/actionlist.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
import copy
2424
from functools import wraps
25-
from six import add_metaclass
2625

2726
from .callbacks import callbacks as _callbacks
2827
from .deviceaction import ActionCreateDevice
@@ -53,8 +52,7 @@ def wrapped_func(obj, *args, **kwargs):
5352
return run_func_with_flag_attr_set
5453

5554

56-
@add_metaclass(SynchronizedMeta)
57-
class ActionList(object):
55+
class ActionList(object, metaclass=SynchronizedMeta):
5856
_unsynchronized_methods = ['process']
5957

6058
def __init__(self, addfunc=None, removefunc=None):

blivet/blivet.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import contextlib
2626
import time
2727
import functools
28-
import six
2928

3029
from .storage_log import log_method_call, log_exception_info
3130
from .devices import BTRFSSubVolumeDevice, BTRFSVolumeDevice
@@ -62,8 +61,7 @@
6261
FSTAB_PATH = ""
6362

6463

65-
@six.add_metaclass(SynchronizedMeta)
66-
class Blivet(object):
64+
class Blivet(object, metaclass=SynchronizedMeta):
6765

6866
""" Top-level class for managing storage configuration. """
6967

blivet/deviceaction.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
import copy
2424

25-
from six import add_metaclass
26-
2725
from . import util
2826
from . import udev
2927
from .errors import DependencyError, PartitioningError
@@ -108,8 +106,7 @@ def resize_type_from_string(type_string):
108106
return k
109107

110108

111-
@add_metaclass(SynchronizedMeta)
112-
class DeviceAction(util.ObjectID):
109+
class DeviceAction(util.ObjectID, metaclass=SynchronizedMeta):
113110

114111
""" An action that will be carried out in the future on a Device.
115112
@@ -295,10 +292,7 @@ def _to_string(self):
295292
return s
296293

297294
def __str__(self):
298-
return util.stringize(self._to_string())
299-
300-
def __unicode__(self):
301-
return util.unicodeize(self._to_string())
295+
return self._to_string()
302296

303297
def requires(self, action):
304298
""" Return True if self requires action. """

blivet/devicefactory.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
# Red Hat Author(s): David Lehman <dlehman@redhat.com>
2121
#
2222

23-
from six import raise_from
24-
2523
from .storage_log import log_method_call
2624
from .errors import DeviceFactoryError, StorageError
2725
from .devices import BTRFSDevice, DiskDevice
@@ -746,7 +744,7 @@ def _create_device(self):
746744
except (StorageError, blockdev.BlockDevError) as e:
747745
log.error("device post-create method failed: %s", e)
748746
self.storage.destroy_device(device)
749-
raise_from(StorageError(e), e)
747+
raise StorageError(e) from e
750748
else:
751749
if not device.size:
752750
self.storage.destroy_device(device)
@@ -941,7 +939,7 @@ def configure(self):
941939
self._revert_devicetree()
942940

943941
if not isinstance(e, (StorageError, OverflowError)):
944-
raise_from(DeviceFactoryError(e), e)
942+
raise DeviceFactoryError(e) from e
945943

946944
raise
947945

@@ -2189,7 +2187,7 @@ def _create_device(self):
21892187
except (StorageError, blockdev.BlockDevError) as e:
21902188
log.error("device post-create method failed: %s", e)
21912189
self.storage.destroy_device(device)
2192-
raise_from(StorageError(e), e)
2190+
raise StorageError(e) from e
21932191
else:
21942192
if not device.size:
21952193
self.storage.destroy_device(device)

blivet/devicelibs/raid.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323

2424
import abc
2525

26-
from six import add_metaclass
27-
2826
from ..errors import RaidError
2927
from ..size import Size
3028

@@ -38,8 +36,7 @@ def div_up(a, b):
3836
return (a + (b - 1)) // b
3937

4038

41-
@add_metaclass(abc.ABCMeta)
42-
class RAIDLevel(object):
39+
class RAIDLevel(object, metaclass=abc.ABCMeta):
4340

4441
"""An abstract class which is the parent of all classes which represent
4542
a RAID level.
@@ -77,8 +74,7 @@ def __deepcopy__(self, memo):
7774
return self
7875

7976

80-
@add_metaclass(abc.ABCMeta)
81-
class RAIDn(RAIDLevel):
77+
class RAIDn(RAIDLevel, metaclass=abc.ABCMeta):
8278

8379
"""An abstract class which is the parent of classes which represent a
8480
numeric RAID level. A better word would be classification, since 'level'

blivet/devicelibs/stratis.py

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646

4747
STRATIS_FS_SIZE = Size("1 TiB")
4848

49+
STRATIS_CALL_TIMEOUT = 120 * 1000 # 120 s (used by stratis-cli by default) in ms
50+
4951

5052
safe_name_characters = "0-9a-zA-Z._-"
5153

@@ -60,7 +62,7 @@ def pool_used(dev_sizes, encrypted=False):
6062
if encrypted:
6163
cmd.append("--encrypted")
6264

63-
rc, out = util.run_program_and_capture_output(cmd)
65+
rc, out = util.run_program_and_capture_output(cmd, stderr_to_stdout=True)
6466
if rc:
6567
raise StratisError("Failed to predict usage for stratis pool")
6668

@@ -78,7 +80,8 @@ def filesystem_md_size(fs_size):
7880

7981
rc, out = util.run_program_and_capture_output([availability.STRATISPREDICTUSAGE_APP.name, "filesystem",
8082
"--filesystem-size",
81-
str(fs_size.get_bytes())])
83+
str(fs_size.get_bytes())],
84+
stderr_to_stdout=True)
8285
if rc:
8386
raise StratisError("Failed to predict usage for stratis filesystem: %s" % out)
8487

@@ -107,7 +110,8 @@ def remove_pool(pool_uuid):
107110
STRATIS_PATH,
108111
STRATIS_MANAGER_INTF,
109112
"DestroyPool",
110-
GLib.Variant("(o)", (pool_info.object_path,)))
113+
GLib.Variant("(o)", (pool_info.object_path,)),
114+
timeout=STRATIS_CALL_TIMEOUT)
111115
except safe_dbus.DBusCallError as e:
112116
raise StratisError("Failed to remove stratis pool: %s" % str(e))
113117
else:
@@ -135,7 +139,8 @@ def remove_filesystem(pool_uuid, fs_uuid):
135139
pool_info.object_path,
136140
STRATIS_POOL_INTF,
137141
"DestroyFilesystems",
138-
GLib.Variant("(ao)", ([fs_info.object_path],)))
142+
GLib.Variant("(ao)", ([fs_info.object_path],)),
143+
timeout=STRATIS_CALL_TIMEOUT)
139144
except safe_dbus.DBusCallError as e:
140145
raise StratisError("Failed to remove stratis filesystem: %s" % str(e))
141146
else:
@@ -172,7 +177,7 @@ def set_key(key_desc, passphrase, key_file):
172177
os.close(write)
173178

174179

175-
def unlock_pool(pool_uuid):
180+
def unlock_pool(pool_uuid, method):
176181
if not availability.STRATIS_DBUS.available:
177182
raise StratisError("Stratis DBus service not available")
178183

@@ -181,15 +186,15 @@ def unlock_pool(pool_uuid):
181186
STRATIS_PATH,
182187
STRATIS_MANAGER_INTF,
183188
"UnlockPool",
184-
GLib.Variant("(ss)", (pool_uuid, "keyring")))
189+
GLib.Variant("(ss)", (pool_uuid, method)))
185190
except safe_dbus.DBusCallError as e:
186191
raise StratisError("Failed to unlock pool: %s" % str(e))
187192
else:
188193
if not succ:
189194
raise StratisError("Failed to unlock pool: %s" % err)
190195

191196

192-
def create_pool(name, devices, encrypted, passphrase, key_file):
197+
def create_pool(name, devices, encrypted, passphrase, key_file, clevis):
193198
if not availability.STRATIS_DBUS.available:
194199
raise StratisError("Stratis DBus service not available")
195200

@@ -202,10 +207,18 @@ def create_pool(name, devices, encrypted, passphrase, key_file):
202207
key_desc = "blivet-%s" % name # XXX what would be a good key description?
203208
set_key(key_desc, passphrase, key_file)
204209
key_opt = GLib.Variant("(bs)", (True, key_desc))
210+
if clevis:
211+
clevis_config = {"url": clevis.tang_url}
212+
if clevis.tang_thumbprint:
213+
clevis_config["thp"] = clevis.tang_thumbprint
214+
else:
215+
clevis_config["stratis:tang:trust_url"] = True
216+
clevis_opt = GLib.Variant("(b(ss))", (True, (clevis.pin, json.dumps(clevis_config))))
217+
else:
218+
clevis_opt = GLib.Variant("(b(ss))", (False, ("", "")))
205219
else:
206220
key_opt = GLib.Variant("(bs)", (False, ""))
207-
208-
clevis_opt = GLib.Variant("(b(ss))", (False, ("", "")))
221+
clevis_opt = GLib.Variant("(b(ss))", (False, ("", "")))
209222

210223
try:
211224
((succ, _paths), rc, err) = safe_dbus.call_sync(STRATIS_SERVICE,
@@ -214,7 +227,8 @@ def create_pool(name, devices, encrypted, passphrase, key_file):
214227
"CreatePool",
215228
GLib.Variant("(s(bq)as(bs)(b(ss)))", (name, raid_opt,
216229
devices, key_opt,
217-
clevis_opt)))
230+
clevis_opt)),
231+
timeout=STRATIS_CALL_TIMEOUT)
218232
except safe_dbus.DBusCallError as e:
219233
raise StratisError("Failed to create stratis pool: %s" % str(e))
220234
else:
@@ -246,7 +260,34 @@ def create_filesystem(name, pool_uuid, fs_size=None):
246260
pool_info.object_path,
247261
STRATIS_POOL_INTF,
248262
"CreateFilesystems",
249-
GLib.Variant("(a(s(bs)))", ([GLib.Variant("(s(bs))", (name, size_opt))],)))
263+
GLib.Variant("(a(s(bs)))", ([GLib.Variant("(s(bs))", (name, size_opt))],)),
264+
timeout=STRATIS_CALL_TIMEOUT)
265+
except safe_dbus.DBusCallError as e:
266+
raise StratisError("Failed to create stratis filesystem on '%s': %s" % (pool_info.name, str(e)))
267+
else:
268+
if not succ:
269+
raise StratisError("Failed to create stratis filesystem on '%s': %s (%d)" % (pool_info.name, err, rc))
270+
271+
# repopulate the stratis info cache so the new filesystem will be added
272+
stratis_info.drop_cache()
273+
274+
275+
def add_device(pool_uuid, device):
276+
if not availability.STRATIS_DBUS.available:
277+
raise StratisError("Stratis DBus service not available")
278+
279+
# repopulate the stratis info cache just to be sure all values are still valid
280+
stratis_info.drop_cache()
281+
282+
pool_info = stratis_info.pools[pool_uuid]
283+
284+
try:
285+
((succ, _paths), rc, err) = safe_dbus.call_sync(STRATIS_SERVICE,
286+
pool_info.object_path,
287+
STRATIS_POOL_INTF,
288+
"AddDataDevs",
289+
GLib.Variant("(as)", ([device],)),
290+
timeout=STRATIS_CALL_TIMEOUT)
250291
except safe_dbus.DBusCallError as e:
251292
raise StratisError("Failed to create stratis filesystem on '%s': %s" % (pool_info.name, str(e)))
252293
else:

blivet/devices/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from .disk import DiskDevice, DiskFile, MultipathDevice, iScsiDiskDevice, FcoeDiskDevice, DASDDevice, ZFCPDiskDevice, NVMeNamespaceDevice, NVMeFabricsNamespaceDevice
2626
from .partition import PartitionDevice
2727
from .dm import DMDevice, DMLinearDevice, DMCryptDevice, DMIntegrityDevice, DM_MAJORS
28-
from .luks import LUKSDevice, IntegrityDevice
28+
from .luks import LUKSDevice, IntegrityDevice, BITLKDevice
2929
from .lvm import LVMVolumeGroupDevice, LVMLogicalVolumeDevice
3030
from .md import MDBiosRaidArrayDevice, MDContainerDevice, MDRaidArrayDevice, MD_MAJORS
3131
from .btrfs import BTRFSDevice, BTRFSVolumeDevice, BTRFSSubVolumeDevice, BTRFSSnapShotDevice

blivet/devices/cache.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@
2424
2525
"""
2626

27-
from six import add_metaclass
2827
import abc
2928

3029

31-
@add_metaclass(abc.ABCMeta)
32-
class Cache(object):
30+
class Cache(object, metaclass=abc.ABCMeta):
3331

3432
"""Abstract base class for cache objects providing the cache-related
3533
functionality on cached devices. Instances of this class are not expected to
@@ -74,8 +72,7 @@ def detach(self):
7472
"""
7573

7674

77-
@add_metaclass(abc.ABCMeta)
78-
class CacheStats(object):
75+
class CacheStats(object, metaclass=abc.ABCMeta):
7976

8077
"""Abstract base class for common statistics of caches (cached
8178
devices). Inheriting classes are expected to add (cache-)type-specific
@@ -109,8 +106,7 @@ def misses(self):
109106
"""number of misses"""
110107

111108

112-
@add_metaclass(abc.ABCMeta)
113-
class CacheRequest(object):
109+
class CacheRequest(object, metaclass=abc.ABCMeta):
114110

115111
"""Abstract base class for cache requests specifying cache parameters for a
116112
cached device

blivet/devices/container.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
import abc
2323

24-
from six import add_metaclass
25-
2624
from .. import errors
2725
from ..storage_log import log_method_call
2826
from ..formats import get_device_format_class
@@ -34,8 +32,7 @@
3432
from .storage import StorageDevice
3533

3634

37-
@add_metaclass(SynchronizedABCMeta)
38-
class ContainerDevice(StorageDevice):
35+
class ContainerDevice(StorageDevice, metaclass=SynchronizedABCMeta):
3936

4037
""" A device that aggregates a set of member devices.
4138

0 commit comments

Comments
 (0)