Skip to content

Commit

Permalink
Added utility in disk library help to Set io scheduler to a device
Browse files Browse the repository at this point in the history
Added utility in disk library help to Set io scheduler to a device

Signed-off-by: Praveen K Pandey <praveen@linux.vnet.ibm.com>
  • Loading branch information
PraveenPenguin committed May 13, 2024
1 parent 895f0d8 commit d22bae0
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion avocado/utils/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,19 @@ def get_io_scheduler(device_name):


def __sched_path(device_name):
file_path = f"/sys/block/{device_name}/queue/scheduler"
return file_path


def set_io_scheduler(device_name, name):
"""
Set io scheduler to a device
:param device_name: Device name example like sda
:param name: io scheduler name
"""
if name not in get_io_scheduler_list(device_name):
raise DiskError(f"No such IO scheduler: {name}")

with open(__sched_path(device_name), "w", encoding="utf-8") as fp:
fp.write(name)

0 comments on commit d22bae0

Please sign in to comment.