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