Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DMDevice hard dependency on kpartx #1165

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion blivet/devices/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class MultipathDevice(DMDevice):
_packages = ["device-mapper-multipath"]
_partitionable = True
_is_disk = True
_external_dependencies = [availability.MULTIPATH_APP]
_external_dependencies = [availability.MULTIPATH_APP, availability.KPARTX_APP]

def __init__(self, name, fmt=None, size=None, wwn=None,
parents=None, sysfs_path=''):
Expand Down
12 changes: 8 additions & 4 deletions blivet/devices/dm.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ class DMDevice(StorageDevice):
""" A device-mapper device """
_type = "dm"
_dev_dir = "/dev/mapper"
_external_dependencies = [
availability.KPARTX_APP,
availability.BLOCKDEV_DM_PLUGIN
]
_external_dependencies = [availability.BLOCKDEV_DM_PLUGIN]

def __init__(self, name, fmt=None, size=None, dm_uuid=None, uuid=None,
target=None, exists=False, parents=None, sysfs_path=''):
Expand Down Expand Up @@ -130,13 +127,20 @@ def get_dm_node(self):

def setup_partitions(self):
log_method_call(self, name=self.name)
if not availability.KPARTX_APP.available:
log.warning("'kpartx' not available, not activating partitions on %s", self.path)
return

rc = util.run_program(["kpartx", "-a", "-s", self.path])
if rc:
raise errors.DMError("partition activation failed for '%s'" % self.name)
udev.settle()

def teardown_partitions(self):
log_method_call(self, name=self.name)
if not availability.KPARTX_APP.available:
log.warning("'kpartx' not available, not deactivating partitions on %s", self.path)
return
rc = util.run_program(["kpartx", "-d", "-s", self.path])
if rc:
raise errors.DMError("partition deactivation failed for '%s'" % self.name)
Expand Down
8 changes: 3 additions & 5 deletions tests/unit_tests/devices_test/lvm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,10 +904,9 @@ def test_vdo_dependencies(self):
size=blivet.size.Size("40 GiB"))

# Dependencies check: for VDO types these should be combination of "normal"
# LVM dependencies (LVM libblockdev plugin + kpartx and DM plugin from DMDevice)
# LVM dependencies (LVM libblockdev plugin and DM plugin from DMDevice)
# and LVM VDO technology from the LVM plugin
lvm_vdo_dependencies = ["kpartx",
"libblockdev dm plugin",
lvm_vdo_dependencies = ["libblockdev dm plugin",
"libblockdev lvm plugin",
"libblockdev lvm plugin (vdo technology)"]
pool_deps = [d.name for d in vdopool.external_dependencies]
Expand All @@ -930,8 +929,7 @@ def test_vdo_dependencies(self):
size=blivet.size.Size("1 GiB"))

normalvl_deps = [d.name for d in normallv.external_dependencies]
six.assertCountEqual(self, normalvl_deps, ["kpartx",
"libblockdev dm plugin",
six.assertCountEqual(self, normalvl_deps, ["libblockdev dm plugin",
"libblockdev lvm plugin"])

with patch("blivet.devices.lvm.LVMVDOPoolMixin._external_dependencies",
Expand Down
Loading