From f91892a4bf72ce618bb0d4f5db6d7fb2dc3a4134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= Date: Thu, 16 Jun 2016 17:39:17 +0200 Subject: [PATCH] functions: added cpulist_present MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This function filters the input cpulist against CPUs present on the system. It returns unpacked list. Signed-off-by: Jaroslav Škarvada --- .../functions/function_cpulist_present.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tuned/profiles/functions/function_cpulist_present.py diff --git a/tuned/profiles/functions/function_cpulist_present.py b/tuned/profiles/functions/function_cpulist_present.py new file mode 100644 index 0000000..5b77230 --- /dev/null +++ b/tuned/profiles/functions/function_cpulist_present.py @@ -0,0 +1,22 @@ +import os +import tuned.logs +import base +from tuned.utils.commands import commands + +log = tuned.logs.get() + +class cpulist_online(base.Function): + """ + Checks whether CPUs from list are present, returns list containing + only present CPUs + """ + def __init__(self): + # arbitrary number of arguments + super(self.__class__, self).__init__("cpulist_present", 0) + + def execute(self, args): + if not super(self.__class__, self).execute(args): + return None + cpus = self._cmd.cpulist_unpack(",,".join(args)) + present = self._cmd.cpulist_unpack(self._cmd.read_file("/sys/devices/system/cpu/present")) + return ",".join(str(v) for v in set(cpus).intersection(set(present)))