From 0501e1461e04c984e2dade1e492e7aef98537344 Mon Sep 17 00:00:00 2001 From: Jan Vcelak Date: Tue, 27 Nov 2012 17:11:13 +0100 Subject: [PATCH] refs #21, disk: fix scheduler reading and applying --- tuned/plugins/plugin_disk.py | 10 ++++++++-- tuned/utils/commands.py | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tuned/plugins/plugin_disk.py b/tuned/plugins/plugin_disk.py index d62a3b6..ddd63e4 100644 --- a/tuned/plugins/plugin_disk.py +++ b/tuned/plugins/plugin_disk.py @@ -1,6 +1,7 @@ import base from decorators import * import tuned.logs +import tuned.utils.commands import os @@ -139,9 +140,14 @@ class DiskPlugin(base.Plugin): @command_get("elevator") def _get_elevator(self, device): - # TODO: ticket #21, does not work sys_file = self._elevator_file(device) - return tuned.utils.commands.read_file(sys_file) + # example of scheduler file content: + # noop deadline [cfq] + schedulers = tuned.utils.commands.read_file(sys_file).split() + for scheduler in schedulers: + if scheduler[0] == "[" and scheduler[-1] == "]": + return scheduler[1:-1] + return schedulers[0] def _alpm_policy_files(self): policy_files = [] diff --git a/tuned/utils/commands.py b/tuned/utils/commands.py index bdd88fd..fb1ad5b 100644 --- a/tuned/utils/commands.py +++ b/tuned/utils/commands.py @@ -1,9 +1,10 @@ import tuned.logs - import copy import os from subprocess import * +__all__ = ["write_to_file", "read_file", "execute"] + log = tuned.logs.get() def write_to_file(f, data):