functions: added cpulist_present
This function filters the input cpulist against CPUs present on the system. It returns unpacked list. Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
This commit is contained in:
parent
7c221de3a0
commit
f91892a4bf
1 changed files with 22 additions and 0 deletions
22
tuned/profiles/functions/function_cpulist_present.py
Normal file
22
tuned/profiles/functions/function_cpulist_present.py
Normal file
|
|
@ -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)))
|
||||||
Loading…
Reference in a new issue