Add detection for partitions on devices.#37
Draft
Kamoppl wants to merge 1 commit intoOpen-CAS:masterfrom
Draft
Conversation
2f25721 to
b930a50
Compare
Signed-off-by: Kamil Gierszewski <kamil.gierszewski@huawei.com>
b930a50 to
b229326
Compare
Deixx
reviewed
Mar 28, 2025
Comment on lines
+61
to
+72
| cmd = ( | ||
| f"lsblk -ln -o NAME,TYPE {device.path} " + r"""| awk '$2 == "part" { print "/dev/" $1 }'""" | ||
| ) | ||
|
|
||
| output = TestRun.executor.run(cmd).stdout | ||
| partition_list = [line for line in output.split("\n") if line] | ||
| if not partition_list: | ||
| return [] | ||
|
|
||
| device_name = re.search(r"^(/dev/\S+)(?=\d+)", partition_list[0]).group() | ||
| if "nvme" in partition_list[0]: | ||
| device_name = device_name[:-1] |
|
|
||
| partitions_on_device_list = [] | ||
|
|
||
| cmd = f"fdisk -l --bytes {device_name}" + r"| grep -E '^/dev/[a-z]+[0-9]+'" |
Contributor
There was a problem hiding this comment.
Suggested change
| cmd = f"fdisk -l --bytes {device_name}" + r"| grep -E '^/dev/[a-z]+[0-9]+'" | |
| cmd = f"fdisk -l --bytes {device.path} | grep ^/dev/" |
| partitions_on_device_list = [] | ||
|
|
||
| cmd = f"fdisk -l --bytes {device_name}" + r"| grep -E '^/dev/[a-z]+[0-9]+'" | ||
| output = TestRun.executor.run(cmd).stdout.split("\n") |
Contributor
There was a problem hiding this comment.
check here if stdout is empty (and return if so)
Comment on lines
+83
to
+85
| disk_params = [ | ||
| x for x in next(param for param in output if partition in param).split(" ") if x | ||
| ] |
Contributor
There was a problem hiding this comment.
part_params = re.split("\s+", line)
| disk_params = [ | ||
| x for x in next(param for param in output if partition in param).split(" ") if x | ||
| ] | ||
| partition_number = int(re.search(r"(\d+)(?!.*\d)", disk_params[0]).group()) |
Contributor
There was a problem hiding this comment.
Suggested change
| partition_number = int(re.search(r"(\d+)(?!.*\d)", disk_params[0]).group()) | |
| partition_number = int(re.search(r"(\d+)$", disk_params[0]).group()) |
| ] | ||
| partition_number = int(re.search(r"(\d+)(?!.*\d)", disk_params[0]).group()) | ||
|
|
||
| part_number = int(partition_number) |
| part_number = int(partition_number) | ||
| begin = Size(int(disk_params[1]), Unit.Byte) | ||
| end = Size( | ||
| (int(disk_params[2])), |
Contributor
There was a problem hiding this comment.
Suggested change
| (int(disk_params[2])), | |
| int(disk_params[2]), |
| ) | ||
| ) | ||
|
|
||
| return partitions_on_device_list |
Contributor
There was a problem hiding this comment.
maybe set device.partitions instead of returning the list?
Contributor
|
Update the description as it is no longer relevant |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add detection for partitions.