diff --git a/tuned/profiles/functions/function_cpulist_unpack.py b/tuned/profiles/functions/function_cpulist_unpack.py new file mode 100644 index 0000000..f44f9c9 --- /dev/null +++ b/tuned/profiles/functions/function_cpulist_unpack.py @@ -0,0 +1,19 @@ +import os +import tuned.logs +import base +from tuned.utils.commands import commands + +log = tuned.logs.get() + +class cpulist_unpack(base.Function): + """ + Conversion function: unpacks CPU list in form 1-3,4 to 1,2,3,4 + """ + def __init__(self): + # arbitrary number of arguments + super(self.__class__, self).__init__("cpulist_unpack", 0) + + def execute(self, args): + if not super(self.__class__, self).execute(args): + return None + return ",".join(str(v) for v in self._cmd.cpulist_unpack(",".join(args))) diff --git a/tuned/utils/commands.py b/tuned/utils/commands.py index ec3f648..e279d1c 100644 --- a/tuned/utils/commands.py +++ b/tuned/utils/commands.py @@ -136,7 +136,7 @@ class commands: return cpus # Unpacks CPU list, i.e. 1-3 will be converted to 1, 2, 3 - def unpack_cpulist(self, l): + def cpulist_unpack(self, l): rl = [] if l is None: return l @@ -157,10 +157,10 @@ class commands: if l is None: return None m = 0 - ul = self.unpack_cpulist(l) + ul = self.cpulist_unpack(l) if ul is None: return None - for v in self.unpack_cpulist(l): + for v in ul: m |= pow(2, v) return "0x%08x" % m