|
|
93a1d2 |
From d8a8d96450bf0d3458671b9b7d23d972aa540396 Mon Sep 17 00:00:00 2001
|
|
|
755168 |
From: Vojtech Trefny <vtrefny@redhat.com>
|
|
|
755168 |
Date: Wed, 26 May 2021 12:27:34 +0200
|
|
|
755168 |
Subject: [PATCH] Revert "Terminology cleanups"
|
|
|
755168 |
|
|
|
755168 |
This reverts following commits:
|
|
|
755168 |
- 3d46339fe9cf12e9082fcbe4dc5acc9f92617e8d
|
|
|
755168 |
- 63c9c7165e5cdfa4a47dcf0ed9d717b71e7921f2
|
|
|
755168 |
- 8956b9af8a785ae25e0e7153d2ef0702ce2f567c
|
|
|
755168 |
---
|
|
|
93a1d2 |
blivet/devicefactory.py | 24 +++----
|
|
|
93a1d2 |
blivet/devices/dm.py | 9 ++-
|
|
|
93a1d2 |
blivet/devices/loop.py | 20 +++---
|
|
|
93a1d2 |
blivet/devices/luks.py | 26 ++++---
|
|
|
93a1d2 |
blivet/errors.py | 2 +-
|
|
|
93a1d2 |
blivet/partitioning.py | 22 +++++-
|
|
|
93a1d2 |
blivet/populator/helpers/dm.py | 4 +-
|
|
|
93a1d2 |
blivet/populator/helpers/luks.py | 4 +-
|
|
|
93a1d2 |
blivet/populator/helpers/lvm.py | 2 +-
|
|
|
93a1d2 |
blivet/populator/helpers/mdraid.py | 14 ++--
|
|
|
93a1d2 |
blivet/populator/helpers/multipath.py | 8 +--
|
|
|
93a1d2 |
blivet/populator/populator.py | 67 ++++++++++---------
|
|
|
93a1d2 |
blivet/threads.py | 3 +-
|
|
|
93a1d2 |
blivet/udev.py | 34 +++++-----
|
|
|
93a1d2 |
tests/unit_tests/devicefactory_test.py | 10 +--
|
|
|
93a1d2 |
.../devices_test/device_size_test.py | 6 +-
|
|
|
93a1d2 |
tests/unit_tests/populator_test.py | 34 +++++-----
|
|
|
93a1d2 |
tests/unit_tests/udev_test.py | 12 ++--
|
|
|
93a1d2 |
tests/vmtests/vmbackedtestcase.py | 2 +-
|
|
|
93a1d2 |
19 files changed, 167 insertions(+), 136 deletions(-)
|
|
|
755168 |
|
|
|
755168 |
diff --git a/blivet/devicefactory.py b/blivet/devicefactory.py
|
|
|
93a1d2 |
index 6f460f6d..90082c28 100644
|
|
|
755168 |
--- a/blivet/devicefactory.py
|
|
|
755168 |
+++ b/blivet/devicefactory.py
|
|
|
93a1d2 |
@@ -859,12 +859,12 @@ class DeviceFactory(object):
|
|
|
755168 |
parent_container.parents.remove(orig_device)
|
|
|
755168 |
|
|
|
755168 |
if self.encrypted and isinstance(self.device, LUKSDevice) and \
|
|
|
755168 |
- self.raw_device.format.luks_version != self.luks_version:
|
|
|
755168 |
- self.raw_device.format.luks_version = self.luks_version
|
|
|
755168 |
+ self.device.slave.format.luks_version != self.luks_version:
|
|
|
755168 |
+ self.device.slave.format.luks_version = self.luks_version
|
|
|
755168 |
|
|
|
755168 |
if self.encrypted and isinstance(self.device, LUKSDevice) and \
|
|
|
755168 |
- self.raw_device.format.luks_sector_size != self.luks_sector_size:
|
|
|
755168 |
- self.raw_device.format.luks_sector_size = self.luks_sector_size
|
|
|
755168 |
+ self.device.slave.format.luks_sector_size != self.luks_sector_size:
|
|
|
755168 |
+ self.device.slave.format.luks_sector_size = self.luks_sector_size
|
|
|
755168 |
|
|
|
755168 |
def _set_name(self):
|
|
|
755168 |
if not self.device_name:
|
|
|
93a1d2 |
@@ -1201,11 +1201,11 @@ class PartitionSetFactory(PartitionFactory):
|
|
|
755168 |
container.parents.remove(member)
|
|
|
755168 |
self.storage.destroy_device(member)
|
|
|
755168 |
members.remove(member)
|
|
|
755168 |
- self.storage.format_device(member.raw_device,
|
|
|
755168 |
+ self.storage.format_device(member.slave,
|
|
|
755168 |
get_format(self.fstype))
|
|
|
755168 |
- members.append(member.raw_device)
|
|
|
755168 |
+ members.append(member.slave)
|
|
|
755168 |
if container:
|
|
|
755168 |
- container.parents.append(member.raw_device)
|
|
|
755168 |
+ container.parents.append(member.slave)
|
|
|
755168 |
|
|
|
755168 |
continue
|
|
|
755168 |
|
|
|
93a1d2 |
@@ -1227,10 +1227,10 @@ class PartitionSetFactory(PartitionFactory):
|
|
|
755168 |
|
|
|
755168 |
continue
|
|
|
755168 |
|
|
|
755168 |
- if member_encrypted and self.encrypted and self.luks_version != member.raw_device.format.luks_version:
|
|
|
755168 |
- member.raw_device.format.luks_version = self.luks_version
|
|
|
755168 |
- if member_encrypted and self.encrypted and self.luks_sector_size != member.raw_device.format.luks_sector_size:
|
|
|
755168 |
- member.raw_device.format.luks_sector_size = self.luks_sector_size
|
|
|
755168 |
+ if member_encrypted and self.encrypted and self.luks_version != member.slave.format.luks_version:
|
|
|
755168 |
+ member.slave.format.luks_version = self.luks_version
|
|
|
755168 |
+ if member_encrypted and self.encrypted and self.luks_sector_size != member.slave.format.luks_sector_size:
|
|
|
755168 |
+ member.slave.format.luks_sector_size = self.luks_sector_size
|
|
|
755168 |
|
|
|
755168 |
##
|
|
|
755168 |
# Prepare previously allocated member partitions for reallocation.
|
|
|
93a1d2 |
@@ -1290,7 +1290,7 @@ class PartitionSetFactory(PartitionFactory):
|
|
|
755168 |
|
|
|
755168 |
if isinstance(member, LUKSDevice):
|
|
|
755168 |
self.storage.destroy_device(member)
|
|
|
755168 |
- member = member.raw_device
|
|
|
755168 |
+ member = member.slave
|
|
|
755168 |
|
|
|
755168 |
self.storage.destroy_device(member)
|
|
|
755168 |
|
|
|
755168 |
diff --git a/blivet/devices/dm.py b/blivet/devices/dm.py
|
|
|
93a1d2 |
index 2f936170..ae25e8e6 100644
|
|
|
755168 |
--- a/blivet/devices/dm.py
|
|
|
755168 |
+++ b/blivet/devices/dm.py
|
|
|
755168 |
@@ -154,6 +154,11 @@ class DMDevice(StorageDevice):
|
|
|
755168 |
log_method_call(self, self.name, status=self.status)
|
|
|
755168 |
super(DMDevice, self)._set_name(value)
|
|
|
755168 |
|
|
|
755168 |
+ @property
|
|
|
755168 |
+ def slave(self):
|
|
|
755168 |
+ """ This device's backing device. """
|
|
|
755168 |
+ return self.parents[0]
|
|
|
755168 |
+
|
|
|
755168 |
|
|
|
755168 |
class DMLinearDevice(DMDevice):
|
|
|
755168 |
_type = "dm-linear"
|
|
|
755168 |
@@ -189,8 +194,8 @@ class DMLinearDevice(DMDevice):
|
|
|
755168 |
""" Open, or set up, a device. """
|
|
|
755168 |
log_method_call(self, self.name, orig=orig, status=self.status,
|
|
|
755168 |
controllable=self.controllable)
|
|
|
755168 |
- parent_length = self.parents[0].current_size / LINUX_SECTOR_SIZE
|
|
|
755168 |
- blockdev.dm.create_linear(self.name, self.parents[0].path, parent_length,
|
|
|
755168 |
+ slave_length = self.slave.current_size / LINUX_SECTOR_SIZE
|
|
|
755168 |
+ blockdev.dm.create_linear(self.name, self.slave.path, slave_length,
|
|
|
755168 |
self.dm_uuid)
|
|
|
755168 |
|
|
|
755168 |
def _post_setup(self):
|
|
|
755168 |
diff --git a/blivet/devices/loop.py b/blivet/devices/loop.py
|
|
|
755168 |
index 0f4d7775..78f88d7d 100644
|
|
|
755168 |
--- a/blivet/devices/loop.py
|
|
|
755168 |
+++ b/blivet/devices/loop.py
|
|
|
755168 |
@@ -73,7 +73,7 @@ class LoopDevice(StorageDevice):
|
|
|
755168 |
|
|
|
755168 |
def update_name(self):
|
|
|
755168 |
""" Update this device's name. """
|
|
|
755168 |
- if not self.parents[0].status:
|
|
|
755168 |
+ if not self.slave.status:
|
|
|
755168 |
# if the backing device is inactive, so are we
|
|
|
755168 |
return self.name
|
|
|
755168 |
|
|
|
755168 |
@@ -81,7 +81,7 @@ class LoopDevice(StorageDevice):
|
|
|
755168 |
# if our name is loopN we must already be active
|
|
|
755168 |
return self.name
|
|
|
755168 |
|
|
|
755168 |
- name = blockdev.loop.get_loop_name(self.parents[0].path)
|
|
|
755168 |
+ name = blockdev.loop.get_loop_name(self.slave.path)
|
|
|
755168 |
if name.startswith("loop"):
|
|
|
755168 |
self.name = name
|
|
|
755168 |
|
|
|
755168 |
@@ -89,24 +89,24 @@ class LoopDevice(StorageDevice):
|
|
|
755168 |
|
|
|
755168 |
@property
|
|
|
755168 |
def status(self):
|
|
|
755168 |
- return (self.parents[0].status and
|
|
|
755168 |
+ return (self.slave.status and
|
|
|
755168 |
self.name.startswith("loop") and
|
|
|
755168 |
- blockdev.loop.get_loop_name(self.parents[0].path) == self.name)
|
|
|
755168 |
+ blockdev.loop.get_loop_name(self.slave.path) == self.name)
|
|
|
755168 |
|
|
|
755168 |
@property
|
|
|
755168 |
def size(self):
|
|
|
755168 |
- return self.parents[0].size
|
|
|
755168 |
+ return self.slave.size
|
|
|
755168 |
|
|
|
755168 |
def _pre_setup(self, orig=False):
|
|
|
755168 |
- if not os.path.exists(self.parents[0].path):
|
|
|
755168 |
- raise errors.DeviceError("specified file (%s) does not exist" % self.parents[0].path)
|
|
|
755168 |
+ if not os.path.exists(self.slave.path):
|
|
|
755168 |
+ raise errors.DeviceError("specified file (%s) does not exist" % self.slave.path)
|
|
|
755168 |
return StorageDevice._pre_setup(self, orig=orig)
|
|
|
755168 |
|
|
|
755168 |
def _setup(self, orig=False):
|
|
|
755168 |
""" Open, or set up, a device. """
|
|
|
755168 |
log_method_call(self, self.name, orig=orig, status=self.status,
|
|
|
755168 |
controllable=self.controllable)
|
|
|
755168 |
- blockdev.loop.setup(self.parents[0].path)
|
|
|
755168 |
+ blockdev.loop.setup(self.slave.path)
|
|
|
755168 |
|
|
|
755168 |
def _post_setup(self):
|
|
|
755168 |
StorageDevice._post_setup(self)
|
|
|
755168 |
@@ -123,3 +123,7 @@ class LoopDevice(StorageDevice):
|
|
|
755168 |
StorageDevice._post_teardown(self, recursive=recursive)
|
|
|
755168 |
self.name = "tmploop%d" % self.id
|
|
|
755168 |
self.sysfs_path = ''
|
|
|
755168 |
+
|
|
|
755168 |
+ @property
|
|
|
755168 |
+ def slave(self):
|
|
|
755168 |
+ return self.parents[0]
|
|
|
755168 |
diff --git a/blivet/devices/luks.py b/blivet/devices/luks.py
|
|
|
93a1d2 |
index 2eb1f130..5ab840ea 100644
|
|
|
755168 |
--- a/blivet/devices/luks.py
|
|
|
755168 |
+++ b/blivet/devices/luks.py
|
|
|
755168 |
@@ -66,13 +66,17 @@ class LUKSDevice(DMCryptDevice):
|
|
|
755168 |
|
|
|
755168 |
@property
|
|
|
755168 |
def raw_device(self):
|
|
|
755168 |
+ return self.slave
|
|
|
755168 |
+
|
|
|
755168 |
+ @property
|
|
|
755168 |
+ def slave(self):
|
|
|
755168 |
if self._has_integrity:
|
|
|
755168 |
return self.parents[0].parents[0]
|
|
|
755168 |
return self.parents[0]
|
|
|
755168 |
|
|
|
755168 |
def _get_size(self):
|
|
|
755168 |
if not self.exists:
|
|
|
755168 |
- size = self.raw_device.size - crypto.LUKS_METADATA_SIZE
|
|
|
755168 |
+ size = self.slave.size - crypto.LUKS_METADATA_SIZE
|
|
|
755168 |
elif self.resizable and self.target_size != Size(0):
|
|
|
755168 |
size = self.target_size
|
|
|
755168 |
else:
|
|
|
755168 |
@@ -80,8 +84,8 @@ class LUKSDevice(DMCryptDevice):
|
|
|
755168 |
return size
|
|
|
755168 |
|
|
|
755168 |
def _set_size(self, newsize):
|
|
|
755168 |
- if not self.exists and not self.raw_device.exists:
|
|
|
755168 |
- self.raw_device.size = newsize + crypto.LUKS_METADATA_SIZE
|
|
|
755168 |
+ if not self.exists and not self.slave.exists:
|
|
|
755168 |
+ self.slave.size = newsize + crypto.LUKS_METADATA_SIZE
|
|
|
755168 |
|
|
|
755168 |
# just run the StorageDevice._set_size to make sure we are in the format limits
|
|
|
755168 |
super(LUKSDevice, self)._set_size(newsize - crypto.LUKS_METADATA_SIZE)
|
|
|
755168 |
@@ -108,22 +112,22 @@ class LUKSDevice(DMCryptDevice):
|
|
|
755168 |
raise ValueError("size is smaller than the minimum for this device")
|
|
|
755168 |
|
|
|
755168 |
# don't allow larger luks than size (or target size) of backing device
|
|
|
755168 |
- if newsize > (self.raw_device.size - crypto.LUKS_METADATA_SIZE):
|
|
|
755168 |
+ if newsize > (self.slave.size - crypto.LUKS_METADATA_SIZE):
|
|
|
755168 |
log.error("requested size %s is larger than size of the backing device %s",
|
|
|
755168 |
- newsize, self.raw_device.size)
|
|
|
755168 |
+ newsize, self.slave.size)
|
|
|
755168 |
raise ValueError("size is larger than the size of the backing device")
|
|
|
755168 |
|
|
|
755168 |
if self.align_target_size(newsize) != newsize:
|
|
|
755168 |
raise ValueError("new size would violate alignment requirements")
|
|
|
755168 |
|
|
|
755168 |
def _get_target_size(self):
|
|
|
755168 |
- return self.raw_device.format.target_size
|
|
|
755168 |
+ return self.slave.format.target_size
|
|
|
755168 |
|
|
|
755168 |
@property
|
|
|
755168 |
def max_size(self):
|
|
|
755168 |
""" The maximum size this luks device can be. Maximum is based on the
|
|
|
755168 |
maximum size of the backing device. """
|
|
|
755168 |
- max_luks = self.raw_device.max_size - crypto.LUKS_METADATA_SIZE
|
|
|
755168 |
+ max_luks = self.slave.max_size - crypto.LUKS_METADATA_SIZE
|
|
|
755168 |
max_format = self.format.max_size
|
|
|
755168 |
return min(max_luks, max_format) if max_format else max_luks
|
|
|
755168 |
|
|
|
755168 |
@@ -131,7 +135,7 @@ class LUKSDevice(DMCryptDevice):
|
|
|
755168 |
def resizable(self):
|
|
|
755168 |
""" Can this device be resized? """
|
|
|
755168 |
return (self._resizable and self.exists and self.format.resizable and
|
|
|
755168 |
- self.raw_device.resizable and not self._has_integrity)
|
|
|
755168 |
+ self.slave.resizable and not self._has_integrity)
|
|
|
755168 |
|
|
|
755168 |
def resize(self):
|
|
|
755168 |
# size of LUKSDevice depends on size of the LUKS format on backing
|
|
|
755168 |
@@ -139,7 +143,7 @@ class LUKSDevice(DMCryptDevice):
|
|
|
755168 |
log_method_call(self, self.name, status=self.status)
|
|
|
755168 |
|
|
|
755168 |
def _post_create(self):
|
|
|
755168 |
- self.name = self.raw_device.format.map_name
|
|
|
755168 |
+ self.name = self.slave.format.map_name
|
|
|
755168 |
StorageDevice._post_create(self)
|
|
|
755168 |
|
|
|
755168 |
def _post_teardown(self, recursive=False):
|
|
|
755168 |
@@ -162,10 +166,10 @@ class LUKSDevice(DMCryptDevice):
|
|
|
755168 |
self.name = new_name
|
|
|
755168 |
|
|
|
755168 |
def dracut_setup_args(self):
|
|
|
755168 |
- return set(["rd.luks.uuid=luks-%s" % self.raw_device.format.uuid])
|
|
|
755168 |
+ return set(["rd.luks.uuid=luks-%s" % self.slave.format.uuid])
|
|
|
755168 |
|
|
|
755168 |
def populate_ksdata(self, data):
|
|
|
755168 |
- self.raw_device.populate_ksdata(data)
|
|
|
755168 |
+ self.slave.populate_ksdata(data)
|
|
|
755168 |
data.encrypted = True
|
|
|
755168 |
super(LUKSDevice, self).populate_ksdata(data)
|
|
|
755168 |
|
|
|
755168 |
diff --git a/blivet/errors.py b/blivet/errors.py
|
|
|
93a1d2 |
index b886ffec..30c9921a 100644
|
|
|
755168 |
--- a/blivet/errors.py
|
|
|
755168 |
+++ b/blivet/errors.py
|
|
|
93a1d2 |
@@ -201,7 +201,7 @@ class DeviceTreeError(StorageError):
|
|
|
755168 |
pass
|
|
|
755168 |
|
|
|
755168 |
|
|
|
755168 |
-class NoParentsError(DeviceTreeError):
|
|
|
755168 |
+class NoSlavesError(DeviceTreeError):
|
|
|
755168 |
pass
|
|
|
755168 |
|
|
|
755168 |
|
|
|
755168 |
diff --git a/blivet/partitioning.py b/blivet/partitioning.py
|
|
|
93a1d2 |
index ce77e4eb..2cd6554c 100644
|
|
|
755168 |
--- a/blivet/partitioning.py
|
|
|
755168 |
+++ b/blivet/partitioning.py
|
|
|
755168 |
@@ -32,7 +32,7 @@ import _ped
|
|
|
755168 |
|
|
|
755168 |
from .errors import DeviceError, PartitioningError, AlignmentError
|
|
|
755168 |
from .flags import flags
|
|
|
755168 |
-from .devices import Device, PartitionDevice, device_path_to_name
|
|
|
755168 |
+from .devices import Device, PartitionDevice, LUKSDevice, device_path_to_name
|
|
|
755168 |
from .size import Size
|
|
|
755168 |
from .i18n import _
|
|
|
755168 |
from .util import stringize, unicodeize, compare
|
|
|
93a1d2 |
@@ -1635,7 +1635,15 @@ class TotalSizeSet(object):
|
|
|
755168 |
:param size: the target combined size
|
|
|
755168 |
:type size: :class:`~.size.Size`
|
|
|
755168 |
"""
|
|
|
755168 |
- self.devices = [d.raw_device for d in devices]
|
|
|
755168 |
+ self.devices = []
|
|
|
755168 |
+ for device in devices:
|
|
|
755168 |
+ if isinstance(device, LUKSDevice):
|
|
|
755168 |
+ partition = device.slave
|
|
|
755168 |
+ else:
|
|
|
755168 |
+ partition = device
|
|
|
755168 |
+
|
|
|
755168 |
+ self.devices.append(partition)
|
|
|
755168 |
+
|
|
|
755168 |
self.size = size
|
|
|
755168 |
|
|
|
755168 |
self.requests = []
|
|
|
93a1d2 |
@@ -1673,7 +1681,15 @@ class SameSizeSet(object):
|
|
|
755168 |
:keyword max_size: the maximum size for growable devices
|
|
|
755168 |
:type max_size: :class:`~.size.Size`
|
|
|
755168 |
"""
|
|
|
755168 |
- self.devices = [d.raw_device for d in devices]
|
|
|
755168 |
+ self.devices = []
|
|
|
755168 |
+ for device in devices:
|
|
|
755168 |
+ if isinstance(device, LUKSDevice):
|
|
|
755168 |
+ partition = device.slave
|
|
|
755168 |
+ else:
|
|
|
755168 |
+ partition = device
|
|
|
755168 |
+
|
|
|
755168 |
+ self.devices.append(partition)
|
|
|
755168 |
+
|
|
|
755168 |
self.size = size / len(devices)
|
|
|
755168 |
self.grow = grow
|
|
|
755168 |
self.max_size = max_size
|
|
|
755168 |
diff --git a/blivet/populator/helpers/dm.py b/blivet/populator/helpers/dm.py
|
|
|
93a1d2 |
index 4721390e..0ad065e2 100644
|
|
|
755168 |
--- a/blivet/populator/helpers/dm.py
|
|
|
755168 |
+++ b/blivet/populator/helpers/dm.py
|
|
|
93a1d2 |
@@ -47,13 +47,13 @@ class DMDevicePopulator(DevicePopulator):
|
|
|
755168 |
name = udev.device_get_name(self.data)
|
|
|
755168 |
log_method_call(self, name=name)
|
|
|
755168 |
sysfs_path = udev.device_get_sysfs_path(self.data)
|
|
|
755168 |
- parent_devices = self._devicetree._add_parent_devices(self.data)
|
|
|
755168 |
+ slave_devices = self._devicetree._add_slave_devices(self.data)
|
|
|
755168 |
device = self._devicetree.get_device_by_name(name)
|
|
|
755168 |
|
|
|
755168 |
if device is None:
|
|
|
755168 |
device = DMDevice(name, dm_uuid=self.data.get('DM_UUID'),
|
|
|
755168 |
sysfs_path=sysfs_path, exists=True,
|
|
|
755168 |
- parents=[parent_devices[0]])
|
|
|
755168 |
+ parents=[slave_devices[0]])
|
|
|
755168 |
device.protected = True
|
|
|
755168 |
device.controllable = False
|
|
|
755168 |
self._devicetree._add_device(device)
|
|
|
755168 |
diff --git a/blivet/populator/helpers/luks.py b/blivet/populator/helpers/luks.py
|
|
|
93a1d2 |
index 3221122a..9b5023f8 100644
|
|
|
755168 |
--- a/blivet/populator/helpers/luks.py
|
|
|
755168 |
+++ b/blivet/populator/helpers/luks.py
|
|
|
755168 |
@@ -43,7 +43,7 @@ class LUKSDevicePopulator(DevicePopulator):
|
|
|
755168 |
return udev.device_is_dm_luks(data)
|
|
|
755168 |
|
|
|
755168 |
def run(self):
|
|
|
755168 |
- parents = self._devicetree._add_parent_devices(self.data)
|
|
|
755168 |
+ parents = self._devicetree._add_slave_devices(self.data)
|
|
|
755168 |
device = LUKSDevice(udev.device_get_name(self.data),
|
|
|
755168 |
sysfs_path=udev.device_get_sysfs_path(self.data),
|
|
|
755168 |
parents=parents,
|
|
|
755168 |
@@ -58,7 +58,7 @@ class IntegrityDevicePopulator(DevicePopulator):
|
|
|
755168 |
return udev.device_is_dm_integrity(data)
|
|
|
755168 |
|
|
|
755168 |
def run(self):
|
|
|
755168 |
- parents = self._devicetree._add_parent_devices(self.data)
|
|
|
755168 |
+ parents = self._devicetree._add_slave_devices(self.data)
|
|
|
93a1d2 |
name = udev.device_get_name(self.data)
|
|
|
93a1d2 |
|
|
|
93a1d2 |
try:
|
|
|
755168 |
diff --git a/blivet/populator/helpers/lvm.py b/blivet/populator/helpers/lvm.py
|
|
|
93a1d2 |
index 6ef2f417..b549e8d3 100644
|
|
|
755168 |
--- a/blivet/populator/helpers/lvm.py
|
|
|
755168 |
+++ b/blivet/populator/helpers/lvm.py
|
|
|
93a1d2 |
@@ -58,7 +58,7 @@ class LVMDevicePopulator(DevicePopulator):
|
|
|
755168 |
log.warning("found non-vg device with name %s", vg_name)
|
|
|
755168 |
device = None
|
|
|
755168 |
|
|
|
755168 |
- self._devicetree._add_parent_devices(self.data)
|
|
|
755168 |
+ self._devicetree._add_slave_devices(self.data)
|
|
|
755168 |
|
|
|
755168 |
# LVM provides no means to resolve conflicts caused by duplicated VG
|
|
|
755168 |
# names, so we're just being optimistic here. Woo!
|
|
|
755168 |
diff --git a/blivet/populator/helpers/mdraid.py b/blivet/populator/helpers/mdraid.py
|
|
|
93a1d2 |
index a7602d20..9bec11ef 100644
|
|
|
755168 |
--- a/blivet/populator/helpers/mdraid.py
|
|
|
755168 |
+++ b/blivet/populator/helpers/mdraid.py
|
|
|
755168 |
@@ -31,7 +31,7 @@ from ... import udev
|
|
|
755168 |
from ...devicelibs import raid
|
|
|
755168 |
from ...devices import MDRaidArrayDevice, MDContainerDevice
|
|
|
755168 |
from ...devices import device_path_to_name
|
|
|
755168 |
-from ...errors import DeviceError, NoParentsError
|
|
|
755168 |
+from ...errors import DeviceError, NoSlavesError
|
|
|
755168 |
from ...flags import flags
|
|
|
755168 |
from ...storage_log import log_method_call
|
|
|
755168 |
from .devicepopulator import DevicePopulator
|
|
|
755168 |
@@ -52,12 +52,12 @@ class MDDevicePopulator(DevicePopulator):
|
|
|
755168 |
log_method_call(self, name=name)
|
|
|
755168 |
|
|
|
755168 |
try:
|
|
|
755168 |
- self._devicetree._add_parent_devices(self.data)
|
|
|
755168 |
- except NoParentsError:
|
|
|
755168 |
- log.error("no parents found for mdarray %s, skipping", name)
|
|
|
755168 |
+ self._devicetree._add_slave_devices(self.data)
|
|
|
755168 |
+ except NoSlavesError:
|
|
|
755168 |
+ log.error("no slaves found for mdarray %s, skipping", name)
|
|
|
755168 |
return None
|
|
|
755168 |
|
|
|
755168 |
- # try to get the device again now that we've got all the parents
|
|
|
755168 |
+ # try to get the device again now that we've got all the slaves
|
|
|
755168 |
device = self._devicetree.get_device_by_name(name, incomplete=flags.allow_imperfect_devices)
|
|
|
755168 |
|
|
|
755168 |
if device is None:
|
|
|
755168 |
@@ -74,8 +74,8 @@ class MDDevicePopulator(DevicePopulator):
|
|
|
755168 |
device.name = name
|
|
|
755168 |
|
|
|
755168 |
if device is None:
|
|
|
755168 |
- # if we get here, we found all of the parent devices and
|
|
|
755168 |
- # something must be wrong -- if all of the parents are in
|
|
|
755168 |
+ # if we get here, we found all of the slave devices and
|
|
|
755168 |
+ # something must be wrong -- if all of the slaves are in
|
|
|
755168 |
# the tree, this device should be as well
|
|
|
755168 |
if name is None:
|
|
|
755168 |
name = udev.device_get_name(self.data)
|
|
|
755168 |
diff --git a/blivet/populator/helpers/multipath.py b/blivet/populator/helpers/multipath.py
|
|
|
755168 |
index 96c0a9ad..10c745bf 100644
|
|
|
755168 |
--- a/blivet/populator/helpers/multipath.py
|
|
|
755168 |
+++ b/blivet/populator/helpers/multipath.py
|
|
|
755168 |
@@ -40,13 +40,13 @@ class MultipathDevicePopulator(DevicePopulator):
|
|
|
755168 |
name = udev.device_get_name(self.data)
|
|
|
755168 |
log_method_call(self, name=name)
|
|
|
755168 |
|
|
|
755168 |
- parent_devices = self._devicetree._add_parent_devices(self.data)
|
|
|
755168 |
+ slave_devices = self._devicetree._add_slave_devices(self.data)
|
|
|
755168 |
|
|
|
755168 |
device = None
|
|
|
755168 |
- if parent_devices:
|
|
|
755168 |
- device = MultipathDevice(name, parents=parent_devices,
|
|
|
755168 |
+ if slave_devices:
|
|
|
755168 |
+ device = MultipathDevice(name, parents=slave_devices,
|
|
|
755168 |
sysfs_path=udev.device_get_sysfs_path(self.data),
|
|
|
755168 |
- wwn=parent_devices[0].wwn)
|
|
|
755168 |
+ wwn=slave_devices[0].wwn)
|
|
|
755168 |
self._devicetree._add_device(device)
|
|
|
755168 |
|
|
|
755168 |
return device
|
|
|
755168 |
diff --git a/blivet/populator/populator.py b/blivet/populator/populator.py
|
|
|
93a1d2 |
index 3a419418..068270b2 100644
|
|
|
755168 |
--- a/blivet/populator/populator.py
|
|
|
755168 |
+++ b/blivet/populator/populator.py
|
|
|
755168 |
@@ -31,7 +31,7 @@ gi.require_version("BlockDev", "2.0")
|
|
|
755168 |
|
|
|
755168 |
from gi.repository import BlockDev as blockdev
|
|
|
755168 |
|
|
|
755168 |
-from ..errors import DeviceError, DeviceTreeError, NoParentsError
|
|
|
755168 |
+from ..errors import DeviceError, DeviceTreeError, NoSlavesError
|
|
|
755168 |
from ..devices import DMLinearDevice, DMRaidArrayDevice
|
|
|
755168 |
from ..devices import FileDevice, LoopDevice
|
|
|
755168 |
from ..devices import MDRaidArrayDevice
|
|
|
755168 |
@@ -92,55 +92,56 @@ class PopulatorMixin(object):
|
|
|
755168 |
|
|
|
755168 |
self._cleanup = False
|
|
|
755168 |
|
|
|
755168 |
- def _add_parent_devices(self, info):
|
|
|
755168 |
- """ Add all parents of a device, raising DeviceTreeError on failure.
|
|
|
755168 |
+ def _add_slave_devices(self, info):
|
|
|
755168 |
+ """ Add all slaves of a device, raising DeviceTreeError on failure.
|
|
|
755168 |
|
|
|
755168 |
:param :class:`pyudev.Device` info: the device's udev info
|
|
|
755168 |
- :raises: :class:`~.errors.DeviceTreeError if no parents are found or
|
|
|
755168 |
- if we fail to add any parent
|
|
|
755168 |
- :returns: a list of parent devices
|
|
|
755168 |
+ :raises: :class:`~.errors.DeviceTreeError if no slaves are found or
|
|
|
755168 |
+ if we fail to add any slave
|
|
|
755168 |
+ :returns: a list of slave devices
|
|
|
755168 |
:rtype: list of :class:`~.StorageDevice`
|
|
|
755168 |
"""
|
|
|
755168 |
name = udev.device_get_name(info)
|
|
|
755168 |
sysfs_path = udev.device_get_sysfs_path(info)
|
|
|
755168 |
- parent_dir = os.path.normpath("%s/slaves" % sysfs_path)
|
|
|
755168 |
- parent_names = os.listdir(parent_dir)
|
|
|
755168 |
- parent_devices = []
|
|
|
755168 |
- if not parent_names:
|
|
|
755168 |
- log.error("no parents found for %s", name)
|
|
|
755168 |
- raise NoParentsError("no parents found for device %s" % name)
|
|
|
755168 |
-
|
|
|
755168 |
- for parent_name in parent_names:
|
|
|
755168 |
- path = os.path.normpath("%s/%s" % (parent_dir, parent_name))
|
|
|
755168 |
- parent_info = udev.get_device(os.path.realpath(path))
|
|
|
755168 |
-
|
|
|
755168 |
- if not parent_info:
|
|
|
755168 |
- msg = "unable to get udev info for %s" % parent_name
|
|
|
755168 |
+ slave_dir = os.path.normpath("%s/slaves" % sysfs_path)
|
|
|
755168 |
+ slave_names = os.listdir(slave_dir)
|
|
|
755168 |
+ slave_devices = []
|
|
|
755168 |
+ if not slave_names:
|
|
|
755168 |
+ log.error("no slaves found for %s", name)
|
|
|
755168 |
+ raise NoSlavesError("no slaves found for device %s" % name)
|
|
|
755168 |
+
|
|
|
755168 |
+ for slave_name in slave_names:
|
|
|
755168 |
+ path = os.path.normpath("%s/%s" % (slave_dir, slave_name))
|
|
|
755168 |
+ slave_info = udev.get_device(os.path.realpath(path))
|
|
|
755168 |
+
|
|
|
755168 |
+ if not slave_info:
|
|
|
755168 |
+ msg = "unable to get udev info for %s" % slave_name
|
|
|
755168 |
raise DeviceTreeError(msg)
|
|
|
755168 |
|
|
|
755168 |
# cciss in sysfs is "cciss!cXdYpZ" but we need "cciss/cXdYpZ"
|
|
|
755168 |
- parent_name = udev.device_get_name(parent_info).replace("!", "/")
|
|
|
755168 |
-
|
|
|
755168 |
- parent_dev = self.get_device_by_name(parent_name)
|
|
|
755168 |
- if not parent_dev and parent_info:
|
|
|
755168 |
- # we haven't scanned the parent yet, so do it now
|
|
|
755168 |
- self.handle_device(parent_info)
|
|
|
755168 |
- parent_dev = self.get_device_by_name(parent_name)
|
|
|
755168 |
- if parent_dev is None:
|
|
|
755168 |
+ slave_name = udev.device_get_name(slave_info).replace("!", "/")
|
|
|
755168 |
+
|
|
|
755168 |
+ slave_dev = self.get_device_by_name(slave_name)
|
|
|
755168 |
+ if not slave_dev and slave_info:
|
|
|
755168 |
+ # we haven't scanned the slave yet, so do it now
|
|
|
755168 |
+ self.handle_device(slave_info)
|
|
|
755168 |
+ slave_dev = self.get_device_by_name(slave_name)
|
|
|
755168 |
+ if slave_dev is None:
|
|
|
755168 |
if udev.device_is_dm_lvm(info):
|
|
|
755168 |
- if parent_name not in lvs_info.cache:
|
|
|
755168 |
+ if slave_name not in lvs_info.cache:
|
|
|
755168 |
# we do not expect hidden lvs to be in the tree
|
|
|
755168 |
continue
|
|
|
755168 |
|
|
|
755168 |
- # if the current parent is still not in
|
|
|
755168 |
+ # if the current slave is still not in
|
|
|
755168 |
# the tree, something has gone wrong
|
|
|
755168 |
- log.error("failure scanning device %s: could not add parent %s", name, parent_name)
|
|
|
755168 |
- msg = "failed to add parent %s of device %s" % (parent_name, name)
|
|
|
755168 |
+ log.error("failure scanning device %s: could not add slave %s", name, slave_name)
|
|
|
755168 |
+ msg = "failed to add slave %s of device %s" % (slave_name,
|
|
|
755168 |
+ name)
|
|
|
755168 |
raise DeviceTreeError(msg)
|
|
|
755168 |
|
|
|
755168 |
- parent_devices.append(parent_dev)
|
|
|
755168 |
+ slave_devices.append(slave_dev)
|
|
|
755168 |
|
|
|
755168 |
- return parent_devices
|
|
|
755168 |
+ return slave_devices
|
|
|
755168 |
|
|
|
755168 |
def _add_name(self, name):
|
|
|
755168 |
if name not in self.names:
|
|
|
755168 |
diff --git a/blivet/threads.py b/blivet/threads.py
|
|
|
93a1d2 |
index 5e2dff3f..1a5cc6db 100644
|
|
|
755168 |
--- a/blivet/threads.py
|
|
|
755168 |
+++ b/blivet/threads.py
|
|
|
755168 |
@@ -63,11 +63,12 @@ class SynchronizedMeta(type):
|
|
|
755168 |
"""
|
|
|
755168 |
def __new__(cls, name, bases, dct):
|
|
|
755168 |
new_dct = {}
|
|
|
755168 |
+ blacklist = dct.get('_unsynchronized_methods', [])
|
|
|
755168 |
|
|
|
755168 |
for n in dct:
|
|
|
755168 |
obj = dct[n]
|
|
|
755168 |
# Do not decorate class or static methods.
|
|
|
755168 |
- if n in dct.get('_unsynchronized_methods', []):
|
|
|
755168 |
+ if n in blacklist:
|
|
|
755168 |
pass
|
|
|
755168 |
elif isinstance(obj, FunctionType):
|
|
|
755168 |
obj = exclusive(obj)
|
|
|
755168 |
diff --git a/blivet/udev.py b/blivet/udev.py
|
|
|
93a1d2 |
index efbc53d6..ddc49a37 100644
|
|
|
755168 |
--- a/blivet/udev.py
|
|
|
755168 |
+++ b/blivet/udev.py
|
|
|
755168 |
@@ -39,7 +39,7 @@ from gi.repository import BlockDev as blockdev
|
|
|
755168 |
global_udev = pyudev.Context()
|
|
|
755168 |
log = logging.getLogger("blivet")
|
|
|
755168 |
|
|
|
755168 |
-ignored_device_names = []
|
|
|
755168 |
+device_name_blacklist = []
|
|
|
755168 |
""" device name regexes to ignore; this should be empty by default """
|
|
|
755168 |
|
|
|
755168 |
|
|
|
755168 |
@@ -77,7 +77,7 @@ def get_devices(subsystem="block"):
|
|
|
755168 |
|
|
|
755168 |
result = []
|
|
|
755168 |
for device in global_udev.list_devices(subsystem=subsystem):
|
|
|
755168 |
- if not __is_ignored_blockdev(device.sys_name):
|
|
|
755168 |
+ if not __is_blacklisted_blockdev(device.sys_name):
|
|
|
755168 |
dev = device_to_dict(device)
|
|
|
755168 |
result.append(dev)
|
|
|
755168 |
|
|
|
755168 |
@@ -176,13 +176,13 @@ def resolve_glob(glob):
|
|
|
755168 |
return ret
|
|
|
755168 |
|
|
|
755168 |
|
|
|
755168 |
-def __is_ignored_blockdev(dev_name):
|
|
|
755168 |
+def __is_blacklisted_blockdev(dev_name):
|
|
|
755168 |
"""Is this a blockdev we never want for an install?"""
|
|
|
755168 |
if dev_name.startswith("ram") or dev_name.startswith("fd"):
|
|
|
755168 |
return True
|
|
|
755168 |
|
|
|
755168 |
- if ignored_device_names:
|
|
|
755168 |
- if any(re.search(expr, dev_name) for expr in ignored_device_names):
|
|
|
755168 |
+ if device_name_blacklist:
|
|
|
755168 |
+ if any(re.search(expr, dev_name) for expr in device_name_blacklist):
|
|
|
755168 |
return True
|
|
|
755168 |
|
|
|
755168 |
dev_path = "/sys/class/block/%s" % dev_name
|
|
|
93a1d2 |
@@ -375,7 +375,7 @@ def device_is_disk(info):
|
|
|
755168 |
device_is_dm_crypt(info) or
|
|
|
93a1d2 |
device_is_dm_stratis(info) or
|
|
|
755168 |
(device_is_md(info) and
|
|
|
755168 |
- (not device_get_md_container(info) and not all(device_is_disk(d) for d in device_get_parents(info))))))
|
|
|
755168 |
+ (not device_get_md_container(info) and not all(device_is_disk(d) for d in device_get_slaves(info))))))
|
|
|
755168 |
|
|
|
755168 |
|
|
|
755168 |
def device_is_partition(info):
|
|
|
93a1d2 |
@@ -454,18 +454,18 @@ def device_get_devname(info):
|
|
|
755168 |
return info.get('DEVNAME')
|
|
|
755168 |
|
|
|
755168 |
|
|
|
755168 |
-def device_get_parents(info):
|
|
|
755168 |
- """ Return a list of udev device objects representing this device's parents. """
|
|
|
755168 |
- parents_dir = device_get_sysfs_path(info) + "/slaves/"
|
|
|
755168 |
+def device_get_slaves(info):
|
|
|
755168 |
+ """ Return a list of udev device objects representing this device's slaves. """
|
|
|
755168 |
+ slaves_dir = device_get_sysfs_path(info) + "/slaves/"
|
|
|
755168 |
names = list()
|
|
|
755168 |
- if os.path.isdir(parents_dir):
|
|
|
755168 |
- names = os.listdir(parents_dir)
|
|
|
755168 |
+ if os.path.isdir(slaves_dir):
|
|
|
755168 |
+ names = os.listdir(slaves_dir)
|
|
|
755168 |
|
|
|
755168 |
- parents = list()
|
|
|
755168 |
+ slaves = list()
|
|
|
755168 |
for name in names:
|
|
|
755168 |
- parents.append(get_device(device_node="/dev/" + name))
|
|
|
755168 |
+ slaves.append(get_device(device_node="/dev/" + name))
|
|
|
755168 |
|
|
|
755168 |
- return parents
|
|
|
755168 |
+ return slaves
|
|
|
755168 |
|
|
|
755168 |
|
|
|
755168 |
def device_get_holders(info):
|
|
|
93a1d2 |
@@ -742,7 +742,7 @@ def device_get_partition_disk(info):
|
|
|
755168 |
disk = None
|
|
|
755168 |
majorminor = info.get("ID_PART_ENTRY_DISK")
|
|
|
755168 |
sysfs_path = device_get_sysfs_path(info)
|
|
|
755168 |
- parents_dir = "%s/slaves" % sysfs_path
|
|
|
755168 |
+ slaves_dir = "%s/slaves" % sysfs_path
|
|
|
755168 |
if majorminor:
|
|
|
755168 |
major, minor = majorminor.split(":")
|
|
|
755168 |
for device in get_devices():
|
|
|
93a1d2 |
@@ -750,8 +750,8 @@ def device_get_partition_disk(info):
|
|
|
755168 |
disk = device_get_name(device)
|
|
|
755168 |
break
|
|
|
755168 |
elif device_is_dm_partition(info):
|
|
|
755168 |
- if os.path.isdir(parents_dir):
|
|
|
755168 |
- parents = os.listdir(parents_dir)
|
|
|
755168 |
+ if os.path.isdir(slaves_dir):
|
|
|
755168 |
+ parents = os.listdir(slaves_dir)
|
|
|
755168 |
if len(parents) == 1:
|
|
|
755168 |
disk = resolve_devspec(parents[0].replace('!', '/'))
|
|
|
755168 |
else:
|
|
|
93a1d2 |
diff --git a/tests/unit_tests/devicefactory_test.py b/tests/unit_tests/devicefactory_test.py
|
|
|
93a1d2 |
index ff6bcb9e..552aadc1 100644
|
|
|
93a1d2 |
--- a/tests/unit_tests/devicefactory_test.py
|
|
|
93a1d2 |
+++ b/tests/unit_tests/devicefactory_test.py
|
|
|
93a1d2 |
@@ -115,9 +115,9 @@ class DeviceFactoryTestCase(unittest.TestCase):
|
|
|
755168 |
kwargs.get("encrypted", False) or
|
|
|
755168 |
kwargs.get("container_encrypted", False))
|
|
|
755168 |
if kwargs.get("encrypted", False):
|
|
|
755168 |
- self.assertEqual(device.parents[0].format.luks_version,
|
|
|
755168 |
+ self.assertEqual(device.slave.format.luks_version,
|
|
|
755168 |
kwargs.get("luks_version", crypto.DEFAULT_LUKS_VERSION))
|
|
|
755168 |
- self.assertEqual(device.raw_device.format.luks_sector_size,
|
|
|
755168 |
+ self.assertEqual(device.slave.format.luks_sector_size,
|
|
|
755168 |
kwargs.get("luks_sector_size", 0))
|
|
|
755168 |
|
|
|
755168 |
self.assertTrue(set(device.disks).issubset(kwargs["disks"]))
|
|
|
93a1d2 |
@@ -357,7 +357,7 @@ class LVMFactoryTestCase(DeviceFactoryTestCase):
|
|
|
755168 |
device = args[0]
|
|
|
755168 |
|
|
|
755168 |
if kwargs.get("encrypted"):
|
|
|
755168 |
- container = device.parents[0].container
|
|
|
755168 |
+ container = device.slave.container
|
|
|
755168 |
else:
|
|
|
755168 |
container = device.container
|
|
|
755168 |
|
|
|
93a1d2 |
@@ -376,7 +376,7 @@ class LVMFactoryTestCase(DeviceFactoryTestCase):
|
|
|
755168 |
self.assertIsInstance(pv, member_class)
|
|
|
755168 |
|
|
|
755168 |
if pv.encrypted:
|
|
|
755168 |
- self.assertEqual(pv.parents[0].format.luks_version,
|
|
|
755168 |
+ self.assertEqual(pv.slave.format.luks_version,
|
|
|
755168 |
kwargs.get("luks_version", crypto.DEFAULT_LUKS_VERSION))
|
|
|
755168 |
|
|
|
755168 |
@patch("blivet.formats.lvmpv.LVMPhysicalVolume.formattable", return_value=True)
|
|
|
93a1d2 |
@@ -592,7 +592,7 @@ class LVMThinPFactoryTestCase(LVMFactoryTestCase):
|
|
|
755168 |
device = args[0]
|
|
|
755168 |
|
|
|
755168 |
if kwargs.get("encrypted", False):
|
|
|
755168 |
- thinlv = device.parents[0]
|
|
|
755168 |
+ thinlv = device.slave
|
|
|
755168 |
else:
|
|
|
755168 |
thinlv = device
|
|
|
755168 |
|
|
|
93a1d2 |
diff --git a/tests/unit_tests/devices_test/device_size_test.py b/tests/unit_tests/devices_test/device_size_test.py
|
|
|
755168 |
index d0c0a3f4..a1efa86d 100644
|
|
|
93a1d2 |
--- a/tests/unit_tests/devices_test/device_size_test.py
|
|
|
93a1d2 |
+++ b/tests/unit_tests/devices_test/device_size_test.py
|
|
|
755168 |
@@ -107,8 +107,8 @@ class LUKSDeviceSizeTest(StorageDeviceSizeTest):
|
|
|
755168 |
|
|
|
755168 |
def _get_device(self, *args, **kwargs):
|
|
|
755168 |
exists = kwargs.get("exists", False)
|
|
|
755168 |
- parent = StorageDevice(*args, size=kwargs["size"] + crypto.LUKS_METADATA_SIZE, exists=exists)
|
|
|
755168 |
- return LUKSDevice(*args, **kwargs, parents=[parent])
|
|
|
755168 |
+ slave = StorageDevice(*args, size=kwargs["size"] + crypto.LUKS_METADATA_SIZE, exists=exists)
|
|
|
755168 |
+ return LUKSDevice(*args, **kwargs, parents=[slave])
|
|
|
755168 |
|
|
|
755168 |
def test_size_getter(self):
|
|
|
755168 |
initial_size = Size("10 GiB")
|
|
|
755168 |
@@ -116,4 +116,4 @@ class LUKSDeviceSizeTest(StorageDeviceSizeTest):
|
|
|
755168 |
|
|
|
755168 |
# for LUKS size depends on the backing device size
|
|
|
755168 |
self.assertEqual(dev.size, initial_size)
|
|
|
755168 |
- self.assertEqual(dev.raw_device.size, initial_size + crypto.LUKS_METADATA_SIZE)
|
|
|
755168 |
+ self.assertEqual(dev.slave.size, initial_size + crypto.LUKS_METADATA_SIZE)
|
|
|
93a1d2 |
diff --git a/tests/unit_tests/populator_test.py b/tests/unit_tests/populator_test.py
|
|
|
93a1d2 |
index 369fe878..7ba04bac 100644
|
|
|
93a1d2 |
--- a/tests/unit_tests/populator_test.py
|
|
|
93a1d2 |
+++ b/tests/unit_tests/populator_test.py
|
|
|
93a1d2 |
@@ -86,7 +86,7 @@ class DMDevicePopulatorTestCase(PopulatorHelperTestCase):
|
|
|
755168 |
@patch.object(DeviceTree, "get_device_by_name")
|
|
|
755168 |
@patch.object(DMDevice, "status", return_value=True)
|
|
|
755168 |
@patch.object(DMDevice, "update_sysfs_path")
|
|
|
755168 |
- @patch.object(DeviceTree, "_add_parent_devices")
|
|
|
755168 |
+ @patch.object(DeviceTree, "_add_slave_devices")
|
|
|
755168 |
@patch("blivet.udev.device_get_name")
|
|
|
755168 |
@patch("blivet.udev.device_get_sysfs_path", return_value=sentinel.sysfs_path)
|
|
|
755168 |
def test_run(self, *args):
|
|
|
93a1d2 |
@@ -95,7 +95,7 @@ class DMDevicePopulatorTestCase(PopulatorHelperTestCase):
|
|
|
755168 |
|
|
|
755168 |
devicetree = DeviceTree()
|
|
|
755168 |
|
|
|
755168 |
- # The general case for dm devices is that adding the parent devices
|
|
|
755168 |
+ # The general case for dm devices is that adding the slave/parent devices
|
|
|
755168 |
# will result in the dm device itself being in the tree.
|
|
|
755168 |
device = Mock()
|
|
|
93a1d2 |
device.id = 0
|
|
|
93a1d2 |
@@ -106,7 +106,7 @@ class DMDevicePopulatorTestCase(PopulatorHelperTestCase):
|
|
|
755168 |
parent = Mock()
|
|
|
93a1d2 |
parent.id = 0
|
|
|
755168 |
parent.parents = []
|
|
|
755168 |
- devicetree._add_parent_devices.return_value = [parent]
|
|
|
755168 |
+ devicetree._add_slave_devices.return_value = [parent]
|
|
|
755168 |
devicetree._add_device(parent)
|
|
|
755168 |
devicetree.get_device_by_name.return_value = None
|
|
|
755168 |
device_name = "dmdevice"
|
|
|
93a1d2 |
@@ -235,7 +235,7 @@ class LVMDevicePopulatorTestCase(PopulatorHelperTestCase):
|
|
|
755168 |
# could be the first helper class checked.
|
|
|
755168 |
|
|
|
755168 |
@patch.object(DeviceTree, "get_device_by_name")
|
|
|
755168 |
- @patch.object(DeviceTree, "_add_parent_devices")
|
|
|
755168 |
+ @patch.object(DeviceTree, "_add_slave_devices")
|
|
|
755168 |
@patch("blivet.udev.device_get_name")
|
|
|
755168 |
@patch("blivet.udev.device_get_lv_vg_name")
|
|
|
755168 |
def test_run(self, *args):
|
|
|
93a1d2 |
@@ -247,7 +247,7 @@ class LVMDevicePopulatorTestCase(PopulatorHelperTestCase):
|
|
|
755168 |
devicetree = DeviceTree()
|
|
|
755168 |
data = Mock()
|
|
|
755168 |
|
|
|
755168 |
- # Add parent devices and then look up the device.
|
|
|
755168 |
+ # Add slave/parent devices and then look up the device.
|
|
|
755168 |
device_get_name.return_value = sentinel.lv_name
|
|
|
755168 |
devicetree.get_device_by_name.return_value = None
|
|
|
755168 |
|
|
|
93a1d2 |
@@ -267,7 +267,7 @@ class LVMDevicePopulatorTestCase(PopulatorHelperTestCase):
|
|
|
755168 |
call(sentinel.vg_name),
|
|
|
755168 |
call(sentinel.lv_name)])
|
|
|
755168 |
|
|
|
755168 |
- # Add parent devices, but the device is still not in the tree
|
|
|
755168 |
+ # Add slave/parent devices, but the device is still not in the tree
|
|
|
755168 |
get_device_by_name.side_effect = None
|
|
|
755168 |
get_device_by_name.return_value = None
|
|
|
755168 |
self.assertEqual(helper.run(), None)
|
|
|
93a1d2 |
@@ -639,7 +639,7 @@ class MDDevicePopulatorTestCase(PopulatorHelperTestCase):
|
|
|
755168 |
# could be the first helper class checked.
|
|
|
755168 |
|
|
|
755168 |
@patch.object(DeviceTree, "get_device_by_name")
|
|
|
755168 |
- @patch.object(DeviceTree, "_add_parent_devices")
|
|
|
755168 |
+ @patch.object(DeviceTree, "_add_slave_devices")
|
|
|
755168 |
@patch("blivet.udev.device_get_name")
|
|
|
755168 |
@patch("blivet.udev.device_get_md_uuid")
|
|
|
755168 |
@patch("blivet.udev.device_get_md_name")
|
|
|
93a1d2 |
@@ -650,7 +650,7 @@ class MDDevicePopulatorTestCase(PopulatorHelperTestCase):
|
|
|
755168 |
|
|
|
755168 |
devicetree = DeviceTree()
|
|
|
755168 |
|
|
|
755168 |
- # base case: _add_parent_devices gets the array into the tree
|
|
|
755168 |
+ # base case: _add_slave_devices gets the array into the tree
|
|
|
755168 |
data = Mock()
|
|
|
755168 |
device = Mock()
|
|
|
755168 |
device.parents = []
|
|
|
93a1d2 |
@@ -713,12 +713,12 @@ class MultipathDevicePopulatorTestCase(PopulatorHelperTestCase):
|
|
|
755168 |
# could be the first helper class checked.
|
|
|
755168 |
|
|
|
755168 |
@patch("blivet.udev.device_get_sysfs_path")
|
|
|
755168 |
- @patch.object(DeviceTree, "_add_parent_devices")
|
|
|
755168 |
+ @patch.object(DeviceTree, "_add_slave_devices")
|
|
|
755168 |
@patch("blivet.udev.device_get_name")
|
|
|
755168 |
def test_run(self, *args):
|
|
|
755168 |
"""Test multipath device populator."""
|
|
|
755168 |
device_get_name = args[0]
|
|
|
755168 |
- add_parent_devices = args[1]
|
|
|
755168 |
+ add_slave_devices = args[1]
|
|
|
755168 |
|
|
|
755168 |
devicetree = DeviceTree()
|
|
|
755168 |
# set up some fake udev data to verify handling of specific entries
|
|
|
93a1d2 |
@@ -733,13 +733,13 @@ class MultipathDevicePopulatorTestCase(PopulatorHelperTestCase):
|
|
|
755168 |
|
|
|
755168 |
device_name = "mpathtest"
|
|
|
755168 |
device_get_name.return_value = device_name
|
|
|
93a1d2 |
- parent_1 = Mock(tags=set(), wwn=wwn[2:], id=0)
|
|
|
755168 |
- parent_1.parents = []
|
|
|
93a1d2 |
- parent_2 = Mock(tags=set(), wwn=wwn[2:], id=0)
|
|
|
755168 |
- parent_2.parents = []
|
|
|
755168 |
- devicetree._add_device(parent_1)
|
|
|
755168 |
- devicetree._add_device(parent_2)
|
|
|
755168 |
- add_parent_devices.return_value = [parent_1, parent_2]
|
|
|
93a1d2 |
+ slave_1 = Mock(tags=set(), wwn=wwn[2:], id=0)
|
|
|
755168 |
+ slave_1.parents = []
|
|
|
93a1d2 |
+ slave_2 = Mock(tags=set(), wwn=wwn[2:], id=0)
|
|
|
755168 |
+ slave_2.parents = []
|
|
|
755168 |
+ devicetree._add_device(slave_1)
|
|
|
755168 |
+ devicetree._add_device(slave_2)
|
|
|
755168 |
+ add_slave_devices.return_value = [slave_1, slave_2]
|
|
|
755168 |
|
|
|
755168 |
helper = self.helper_class(devicetree, data)
|
|
|
755168 |
|
|
|
93a1d2 |
diff --git a/tests/unit_tests/udev_test.py b/tests/unit_tests/udev_test.py
|
|
|
93a1d2 |
index b208efa8..ebcd59e2 100644
|
|
|
93a1d2 |
--- a/tests/unit_tests/udev_test.py
|
|
|
93a1d2 |
+++ b/tests/unit_tests/udev_test.py
|
|
|
93a1d2 |
@@ -49,11 +49,11 @@ class UdevTest(unittest.TestCase):
|
|
|
755168 |
@mock.patch('blivet.udev.device_is_dm_crypt', return_value=False)
|
|
|
755168 |
@mock.patch('blivet.udev.device_is_md')
|
|
|
755168 |
@mock.patch('blivet.udev.device_get_md_container')
|
|
|
755168 |
- @mock.patch('blivet.udev.device_get_parents')
|
|
|
755168 |
+ @mock.patch('blivet.udev.device_get_slaves')
|
|
|
755168 |
def test_udev_device_is_disk_md(self, *args):
|
|
|
755168 |
import blivet.udev
|
|
|
755168 |
info = dict(DEVTYPE='disk', SYS_PATH=mock.sentinel.md_path)
|
|
|
755168 |
- (device_get_parents, device_get_md_container, device_is_md) = args[:3] # pylint: disable=unbalanced-tuple-unpacking
|
|
|
755168 |
+ (device_get_slaves, device_get_md_container, device_is_md) = args[:3] # pylint: disable=unbalanced-tuple-unpacking
|
|
|
755168 |
|
|
|
755168 |
disk_parents = [dict(DEVTYPE="disk", SYS_PATH='/fake/path/2'),
|
|
|
755168 |
dict(DEVTYPE="disk", SYS_PATH='/fake/path/3')]
|
|
|
93a1d2 |
@@ -68,20 +68,20 @@ class UdevTest(unittest.TestCase):
|
|
|
755168 |
# Intel FW RAID (MD RAID w/ container layer)
|
|
|
755168 |
# device_get_container will return some mock value which will evaluate to True
|
|
|
755168 |
device_get_md_container.return_value = mock.sentinel.md_container
|
|
|
755168 |
- device_get_parents.side_effect = lambda info: list()
|
|
|
755168 |
+ device_get_slaves.side_effect = lambda info: list()
|
|
|
755168 |
self.assertTrue(blivet.udev.device_is_disk(info))
|
|
|
755168 |
|
|
|
755168 |
# Normal MD RAID
|
|
|
755168 |
- device_get_parents.side_effect = lambda info: partition_parents if info['SYS_PATH'] == mock.sentinel.md_path else list()
|
|
|
755168 |
+ device_get_slaves.side_effect = lambda info: partition_parents if info['SYS_PATH'] == mock.sentinel.md_path else list()
|
|
|
755168 |
device_get_md_container.return_value = None
|
|
|
755168 |
self.assertFalse(blivet.udev.device_is_disk(info))
|
|
|
755168 |
|
|
|
755168 |
# Dell FW RAID (MD RAID whose members are all whole disks)
|
|
|
755168 |
- device_get_parents.side_effect = lambda info: disk_parents if info['SYS_PATH'] == mock.sentinel.md_path else list()
|
|
|
755168 |
+ device_get_slaves.side_effect = lambda info: disk_parents if info['SYS_PATH'] == mock.sentinel.md_path else list()
|
|
|
755168 |
self.assertTrue(blivet.udev.device_is_disk(info))
|
|
|
755168 |
|
|
|
755168 |
# Normal MD RAID (w/ at least one non-disk member)
|
|
|
755168 |
- device_get_parents.side_effect = lambda info: mixed_parents if info['SYS_PATH'] == mock.sentinel.md_path else list()
|
|
|
755168 |
+ device_get_slaves.side_effect = lambda info: mixed_parents if info['SYS_PATH'] == mock.sentinel.md_path else list()
|
|
|
755168 |
self.assertFalse(blivet.udev.device_is_disk(info))
|
|
|
755168 |
|
|
|
755168 |
|
|
|
755168 |
diff --git a/tests/vmtests/vmbackedtestcase.py b/tests/vmtests/vmbackedtestcase.py
|
|
|
755168 |
index 797bac85..6255104f 100644
|
|
|
755168 |
--- a/tests/vmtests/vmbackedtestcase.py
|
|
|
755168 |
+++ b/tests/vmtests/vmbackedtestcase.py
|
|
|
755168 |
@@ -50,7 +50,7 @@ class VMBackedTestCase(unittest.TestCase):
|
|
|
755168 |
defined in set_up_disks.
|
|
|
755168 |
"""
|
|
|
755168 |
|
|
|
755168 |
- udev.ignored_device_names = [r'^zram']
|
|
|
755168 |
+ udev.device_name_blacklist = [r'^zram']
|
|
|
755168 |
|
|
|
755168 |
#
|
|
|
755168 |
# create disk images
|
|
|
755168 |
--
|
|
|
93a1d2 |
2.38.1
|
|
|
755168 |
|