Skip to content
Open
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
8 changes: 6 additions & 2 deletions coriolis/osmorphing/osmount/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

MAJOR_COLUMN_INDEX = 4

# lsblk TYPE values that represent migration volumes.
_VOLUME_BLOCK_DEVICE_TYPES = frozenset({"disk"})


class BaseOSMountTools(object, with_metaclass(abc.ABCMeta)):

Expand Down Expand Up @@ -443,11 +446,12 @@ def _get_volume_block_devices(self):
raw = self._exec_cmd("lsblk -lnao KNAME,TYPE")
LOG.debug("All block devices: %s", raw)

# Exclude partitions; each line is "<kname> <type>".
# Include top-level disk devices only.
volume_devs = []
for line in raw.splitlines():
parts = line.split()
if len(parts) >= 2 and parts[1] != "part":
if (len(parts) >= 2
and parts[1] in _VOLUME_BLOCK_DEVICE_TYPES):
volume_devs.append("/dev/%s" % parts[0])

LOG.debug("Ignoring block devices: %s", self._ignore_devices)
Expand Down
2 changes: 2 additions & 0 deletions coriolis/tests/osmorphing/osmount/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@ def test__get_volume_block_devices(self, mock_exec_cmd, _mock_test_path):
"sdb disk\n"
"sdb1 part\n"
"sdb2 part\n"
"sr0 rom\n"
"loop0 loop\n"
)
mock_exec_cmd.return_value = lsblk_output
self.base_os_mount_tools._ignore_devices = ["/dev/sda1"]
Expand Down
Loading