Skip to content

Commit

Permalink
Added utility in disk library which io scheduler available
Browse files Browse the repository at this point in the history
added a utility which Returns io scheduler available for the IO Device

Signed-off-by: Praveen K Pandey <[email protected]>
  • Loading branch information
PraveenPenguin committed May 13, 2024
1 parent 17dd26c commit 895f0d8
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions avocado/utils/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,32 @@ def get_disk_partitions(disk):
for line in partitions_op.split("\n")
if line.startswith(disk) and "Extended" not in line
]


def get_io_scheduler_list(device_name):
"""
Returns io scheduler available for the IO Device
:param device_name: Device name example like sda
:return: list of IO scheduler
"""
names = open(__sched_path(device_name), "r", encoding="utf-8").read()
return names.translate(str.maketrans("[]", " ")).split()


def get_io_scheduler(device_name):
"""
Return io scheduler name which is set currently for device
:param device_name: Device name example like sda
:return: IO scheduler
:rtype : str
"""
return re.split(
r"[\[\]]", open(__sched_path(device_name), "r", encoding="utf-8").read()
)[1]


def __sched_path(device_name):

file_path = f"/sys/block/{device_name}/queue/scheduler"
return file_path

0 comments on commit 895f0d8

Please sign in to comment.