__pycache__/function_assertion_non_equal.cpython-36.pyc000064400000002377147205255750017404 0ustar003 s     __pycache__/function_calc_isolated_cores.cpython-36.opt-1.pyc000064400000003462147205255750020250 0ustar003 s    __pycache__/function_calc_isolated_cores.cpython-36.pyc000064400000003462147205255750017311 0ustar003 s    __pycache__/function_check_net_queue_count.cpython-36.opt-1.pyc000064400000002124147205255750020620 0ustar003 s  __pycache__/function_check_net_queue_count.cpython-36.pyc000064400000002124147205255750017661 0ustar003 s  __pycache__/function_cpuinfo_check.cpython-36.opt-1.pyc000064400000002643147205255750017067 0ustar003 s  __pycache__/function_cpuinfo_check.cpython-36.pyc000064400000002643147205255750016130 0ustar003 s  __pycache__/function_cpulist2devs.cpython-36.opt-1.pyc000064400000001614147205255750016713 0ustar003 s  __pycache__/function_cpulist2devs.cpython-36.pyc000064400000001614147205255750015754 0ustar003 s  __pycache__/function_cpulist2hex.cpython-36.opt-1.pyc000064400000001627147205255750016542 0ustar003 s    __pycache__/function_cpulist2hex.cpython-36.pyc000064400000001627147205255750015603 0ustar003 s    __pycache__/function_cpulist2hex_invert.cpython-36.opt-1.pyc000064400000002174147205255750020127 0ustar003 tt|j|sdS|jjdjdd|jjdj|DS)N,css|]}t|VqdS)N)str).0vr r r sz-cpulist2hex_invert.execute..z,,)rrexecuteZ_cmdZ cpulist2hexjoinZcpulist_invert)rargs)r r r rszcpulist2hex_invert.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZlogsgetlogZFunctionrr r r r s    __pycache__/function_cpulist2hex_invert.cpython-36.pyc000064400000002174147205255750017170 0ustar003 tt|j|sdS|jjdjdd|jjdj|DS)N,css|]}t|VqdS)N)str).0vr r r sz-cpulist2hex_invert.execute..z,,)rrexecuteZ_cmdZ cpulist2hexjoinZcpulist_invert)rargs)r r r rszcpulist2hex_invert.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZlogsgetlogZFunctionrr r r r s    __pycache__/function_cpulist_invert.cpython-36.opt-1.pyc000064400000002335147205255750017337 0ustar003 sz)cpulist_invert.execute..z,,)rrexecutejoinZ_cmd)rargs)r r r rszcpulist_invert.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZlogsgetlogZFunctionrr r r r s    __pycache__/function_cpulist_invert.cpython-36.pyc000064400000002335147205255750016400 0ustar003 sz)cpulist_invert.execute..z,,)rrexecutejoinZ_cmd)rargs)r r r rszcpulist_invert.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZlogsgetlogZFunctionrr r r r s    __pycache__/function_cpulist_online.cpython-36.opt-1.pyc000064400000002312147205255750017307 0ustar003 sz)cpulist_online.execute..)rrexecuteZ_cmdZcpulist_unpackjoinZ read_file)rargsZcpus)r )rr rs zcpulist_online.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZlogsgetlogZFunctionrr r r r s    __pycache__/function_cpulist_online.cpython-36.pyc000064400000002312147205255750016350 0ustar003 sz)cpulist_online.execute..)rrexecuteZ_cmdZcpulist_unpackjoinZ read_file)rargsZcpus)r )rr rs zcpulist_online.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZlogsgetlogZFunctionrr r r r s    __pycache__/function_cpulist_pack.cpython-36.opt-1.pyc000064400000002307147205255750016745 0ustar003 sz'cpulist_pack.execute..z,,)rrexecutejoinZ_cmd)rargs)r r r rszcpulist_pack.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZlogsgetlogZFunctionrr r r r s    __pycache__/function_cpulist_pack.cpython-36.pyc000064400000002307147205255750016006 0ustar003 sz'cpulist_pack.execute..z,,)rrexecutejoinZ_cmd)rargs)r r r rszcpulist_pack.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZlogsgetlogZFunctionrr r r r s    __pycache__/function_cpulist_present.cpython-36.opt-1.pyc000064400000002403147205255750017504 0ustar003 sz*cpulist_present.execute..) rrexecuteZ_cmdZcpulist_unpackjoinZ read_filesortedlistset intersection)rargsZcpusZpresent)r r r rs zcpulist_present.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZlogsgetlogZFunctionrr r r r s    __pycache__/function_cpulist_present.cpython-36.pyc000064400000002403147205255750016545 0ustar003 sz*cpulist_present.execute..) rrexecuteZ_cmdZcpulist_unpackjoinZ read_filesortedlistset intersection)rargsZcpusZpresent)r r r rs zcpulist_present.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZlogsgetlogZFunctionrr r r r s    __pycache__/function_cpulist_unpack.cpython-36.opt-1.pyc000064400000002111147205255750017301 0ustar003 sz)cpulist_unpack.execute..z,,)rrexecutejoinZ_cmd)rargs)r r r rszcpulist_unpack.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZlogsgetlogZFunctionrr r r r s    __pycache__/function_cpulist_unpack.cpython-36.pyc000064400000002111147205255750016342 0ustar003 sz)cpulist_unpack.execute..z,,)rrexecutejoinZ_cmd)rargs)r r r rszcpulist_unpack.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZlogsgetlogZFunctionrr r r r s    __pycache__/function_exec.cpython-36.opt-1.pyc000064400000001556147205255750015215 0ustar003 ddlZddlZddlmZddlmZGdddejZdS)N)base)commandscs,eZdZdZfddZfddZZS)executez0 Executes process and substitutes its output. cstt|jddddS)Nexecrr)superr__init__)self) __class__#/usr/lib/python3.6/function_exec.pyr szexecute.__init__cs4tt|j|sdS|jj|\}}|dkr0|SdS)Nr)rrZ_cmd)r argsretout)r r r rs zexecute.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZFunctionrr r r r s  __pycache__/function_exec.cpython-36.pyc000064400000001556147205255750014256 0ustar003 ddlZddlZddlmZddlmZGdddejZdS)N)base)commandscs,eZdZdZfddZfddZZS)executez0 Executes process and substitutes its output. cstt|jddddS)Nexecrr)superr__init__)self) __class__#/usr/lib/python3.6/function_exec.pyr szexecute.__init__cs4tt|j|sdS|jj|\}}|dkr0|SdS)Nr)rrZ_cmd)r argsretout)r r r rs zexecute.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZFunctionrr r r r s  __pycache__/function_hex2cpulist.cpython-36.opt-1.pyc000064400000002073147205255750016536 0ustar003 sz&hex2cpulist.execute..r)rrexecutejoinZ_cmd)rargs)r r r rszhex2cpulist.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZlogsgetlogZFunctionrr r r r s    __pycache__/function_hex2cpulist.cpython-36.pyc000064400000002073147205255750015577 0ustar003 sz&hex2cpulist.execute..r)rrexecutejoinZ_cmd)rargs)r r r rszhex2cpulist.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZlogsgetlogZFunctionrr r r r s    __pycache__/function_kb2s.cpython-36.opt-1.pyc000064400000001573147205255750015131 0ustar003 ddlZddlZddlmZddlmZGdddejZdS)N)base)commandscs,eZdZdZfddZfddZZS)kb2sz* Conversion function: kbytes to sectors cstt|jddddS)Nrr)superr__init__)self) __class__#/usr/lib/python3.6/function_kb2s.pyr sz kb2s.__init__c sBtt|j|sdSytt|ddStk r<dSXdS)Nr)rrexecutestrint ValueError)rargs)r r r r s z kb2s.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZFunctionrr r r r s  __pycache__/function_kb2s.cpython-36.pyc000064400000001573147205255750014172 0ustar003 ddlZddlZddlmZddlmZGdddejZdS)N)base)commandscs,eZdZdZfddZfddZZS)kb2sz* Conversion function: kbytes to sectors cstt|jddddS)Nrr)superr__init__)self) __class__#/usr/lib/python3.6/function_kb2s.pyr sz kb2s.__init__c sBtt|j|sdSytt|ddStk r<dSXdS)Nr)rrexecutestrint ValueError)rargs)r r r r s z kb2s.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZFunctionrr r r r s  __pycache__/function_regex_search_ternary.cpython-36.opt-1.pyc000064400000001757147205255750020477 0ustar003 s __pycache__/function_regex_search_ternary.cpython-36.pyc000064400000001757147205255750017540 0ustar003 s __pycache__/function_s2kb.cpython-36.opt-1.pyc000064400000001612147205255750015123 0ustar003 ddlZddlZddlmZddlmZGdddejZdS)N)base)commandscs,eZdZdZfddZfddZZS)s2kbz* Conversion function: sectors to kbytes cstt|jddddS)Nrr)superr__init__)self) __class__#/usr/lib/python3.6/function_s2kb.pyr sz s2kb.__init__c sJtt|j|sdSytttt|ddStk rDdSXdS)Nr)rrexecutestrintround ValueError)rargs)r r r r s z s2kb.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZFunctionrr r r r s  __pycache__/function_s2kb.cpython-36.pyc000064400000001612147205255750014164 0ustar003 ddlZddlZddlmZddlmZGdddejZdS)N)base)commandscs,eZdZdZfddZfddZZS)s2kbz* Conversion function: sectors to kbytes cstt|jddddS)Nrr)superr__init__)self) __class__#/usr/lib/python3.6/function_s2kb.pyr sz s2kb.__init__c sJtt|j|sdSytttt|ddStk rDdSXdS)Nr)rrexecutestrintround ValueError)rargs)r r r r s z s2kb.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZFunctionrr r r r s  __pycache__/function_strip.cpython-36.opt-1.pyc000064400000001517147205255750015427 0ustar003 ddlZddlZddlmZddlmZGdddejZdS)N)base)commandscs,eZdZdZfddZfddZZS)stripz0 Makes string from all arguments and strip it cstt|jddddS)Nrrr)superr__init__)self) __class__$/usr/lib/python3.6/function_strip.pyr szstrip.__init__cs"tt|j|sdSdj|jS)N)rrexecutejoin)rargs)r r r r sz strip.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedr rZtuned.utils.commandsrZFunctionrr r r r s  __pycache__/function_strip.cpython-36.pyc000064400000001517147205255750014470 0ustar003 ddlZddlZddlmZddlmZGdddejZdS)N)base)commandscs,eZdZdZfddZfddZZS)stripz0 Makes string from all arguments and strip it cstt|jddddS)Nrrr)superr__init__)self) __class__$/usr/lib/python3.6/function_strip.pyr szstrip.__init__cs"tt|j|sdSdj|jS)N)rrexecutejoin)rargs)r r r r sz strip.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedr rZtuned.utils.commandsrZFunctionrr r r r s  __pycache__/function_virt_check.cpython-36.opt-1.pyc000064400000002042147205255750016401 0ustar003 ddlZddlZddlmZddlmZGdddejZdS)N)base)commandscs,eZdZdZfddZfddZZS) virt_checkz Checks whether running inside virtual machine (VM) or on bare metal. If running inside VM expands to argument 1, otherwise expands to argument 2 (even on error). cstt|jddddS)Nr)superr__init__)self) __class__)/usr/lib/python3.6/function_virt_check.pyr szvirt_check.__init__csJtt|j|sdS|jjdg\}}|dkrBt|dkrB|dS|dS)Nz virt-whatrr)rrexecuteZ_cmdlen)r argsretout)r r r r s zvirt_check.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZFunctionrr r r r s  __pycache__/function_virt_check.cpython-36.pyc000064400000002042147205255750015442 0ustar003 ddlZddlZddlmZddlmZGdddejZdS)N)base)commandscs,eZdZdZfddZfddZZS) virt_checkz Checks whether running inside virtual machine (VM) or on bare metal. If running inside VM expands to argument 1, otherwise expands to argument 2 (even on error). cstt|jddddS)Nr)superr__init__)self) __class__)/usr/lib/python3.6/function_virt_check.pyr szvirt_check.__init__csJtt|j|sdS|jjdg\}}|dkrBt|dkrB|dS|dS)Nz virt-whatrr)rrexecuteZ_cmdlen)r argsretout)r r r r s zvirt_check.execute)__name__ __module__ __qualname____doc__rr __classcell__r r )r r rs r) osZ tuned.logsZtunedrZtuned.utils.commandsrZFunctionrr r r r s  __pycache__/functions.cpython-36.opt-1.pyc000064400000006102147205255750014364 0ustar003 1sz+Functions._process_func..z\w+$rzinvalid function name '%s'zfunction '%s' not implemented) resplitrr matchlogerrorrZ load_func ImportErrorZexecuter)rZ_fromZslfrr r r _process_func-s  zFunctions._process_funcc Cs|j|x|j|jkr|jdkrpy|jj}Wn$tk rVtjd||j SX|ds|j |dn|j ddkr|j |j |jdkrd|_ nd |_ |jd7_q Wt|jrtjd ||j S) N}z.invalid variable syntax, non pair '}' in: '%s'rrr"z${\TFz.invalid variable syntax, non pair '{' in: '%s')rr rrrpop IndexErrorr&r'rr*rrrr)rrZsir r r _process?s&     zFunctions._processcCs(|dks|dkr|Stjdd|j|S)Nr z \\(\${f:.*})z\1)r#subr/)rrr r r expandVszFunctions.expandN)r ) __name__ __module__ __qualname____doc__r rrrrrr*r/r1r r r r r s r)osr#Zglobr rZ tuned.logsZtunedZ tuned.constsZconstsZtuned.utils.commandsrZlogsgetr&cmdrr r r r s    __pycache__/functions.cpython-36.pyc000064400000006102147205255750013425 0ustar003 1sz+Functions._process_func..z\w+$rzinvalid function name '%s'zfunction '%s' not implemented) resplitrr matchlogerrorrZ load_func ImportErrorZexecuter)rZ_fromZslfrr r r _process_func-s  zFunctions._process_funcc Cs|j|x|j|jkr|jdkrpy|jj}Wn$tk rVtjd||j SX|ds|j |dn|j ddkr|j |j |jdkrd|_ nd |_ |jd7_q Wt|jrtjd ||j S) N}z.invalid variable syntax, non pair '}' in: '%s'rrr"z${\TFz.invalid variable syntax, non pair '{' in: '%s')rr rrrpop IndexErrorr&r'rr*rrrr)rrZsir r r _process?s&     zFunctions._processcCs(|dks|dkr|Stjdd|j|S)Nr z \\(\${f:.*})z\1)r#subr/)rrr r r expandVszFunctions.expandN)r ) __name__ __module__ __qualname____doc__r rrrrrr*r/r1r r r r r s r)osr#Zglobr rZ tuned.logsZtunedZ tuned.constsZconstsZtuned.utils.commandsrZlogsgetr&cmdrr r r r s    __pycache__/repository.cpython-36.opt-1.pyc000064400000003400147205255750014571 0ustar003 tjd|x*t|jjD]\}}||kr|j|=qWdS)Nzremoving function %s)rrlistr items)r Zfunctionkvr r r delete&szRepository.delete) __name__ __module__ __qualname__rpropertyrrrrr __classcell__r r )r r r s    r)Ztuned.utils.plugin_loaderrrZ tuned.logsrZ tuned.constsrZtuned.utils.commandsrZlogsgetrrr r r r s     __pycache__/repository.cpython-36.pyc000064400000003463147205255750013643 0ustar003 s     __pycache__/__init__.cpython-36.opt-1.pyc000064400000000236147205255750014115 0ustar003 s__pycache__/__init__.cpython-36.pyc000064400000000236147205255750013156 0ustar003 s__pycache__/base.cpython-36.opt-1.pyc000064400000002155147205255750013272 0ustar003 s  __pycache__/base.cpython-36.pyc000064400000002155147205255750012333 0ustar003 s  __pycache__/function_assertion.cpython-36.opt-1.pyc000064400000002323147205255750016271 0ustar003 s     __pycache__/function_assertion.cpython-36.pyc000064400000002323147205255750015332 0ustar003 s     __pycache__/function_assertion_non_equal.cpython-36.opt-1.pyc000064400000002377147205255750020343 0ustar003 s     __init__.py000064400000000043147205255750006666 0ustar00from .repository import Repository base.py000064400000002020147205255750006036 0ustar00import os import tuned.logs from tuned.utils.commands import commands log = tuned.logs.get() class Function(object): """ Built-in function """ def __init__(self, name, nargs_max, nargs_min = None): self._name = name self._nargs_max = nargs_max self._nargs_min = nargs_min self._cmd = commands() # checks arguments # nargs_max - maximal number of arguments, there mustn't be more arguments, # if nargs_max is 0, number of arguments is unlimited # nargs_min - minimal number of arguments, if not None there must # be the same number of arguments or more @classmethod def _check_args(cls, args, nargs_max, nargs_min = None): if args is None or nargs_max is None: return False la = len(args) return (nargs_max == 0 or nargs_max >= la) and (nargs_min is None or nargs_min <= la) def execute(self, args): if self._check_args(args, self._nargs_max, self._nargs_min): return True else: log.error("invalid number of arguments for builtin function '%s'" % self._name) return False function_assertion.py000064400000001377147205255750011056 0ustar00import os import tuned.logs from . import base from tuned.utils.commands import commands from tuned.profiles.exceptions import InvalidProfileException log = tuned.logs.get() class assertion(base.Function): """ Assertion: compares argument 2 with argument 3. If they don't match it logs text from argument 1 and throws InvalidProfileException. This exception will abort profile loading. """ def __init__(self): # 3 arguments super(assertion, self).__init__("assertion", 3, 3) def execute(self, args): if not super(assertion, self).execute(args): return None if args[1] != args[2]: log.error("assertion '%s' failed: '%s' != '%s'" % (args[0], args[1], args[2])) raise InvalidProfileException("Assertion '%s' failed." % args[0]) return None function_assertion_non_equal.py000064400000001453147205255750013112 0ustar00import os import tuned.logs from . import base from tuned.utils.commands import commands from tuned.profiles.exceptions import InvalidProfileException log = tuned.logs.get() class assertion_non_equal(base.Function): """ Assertion non equal: compares argument 2 with argument 3. If they match it logs text from argument 1 and throws InvalidProfileException. This exception will abort profile loading. """ def __init__(self): # 3 arguments super(assertion_non_equal, self).__init__("assertion_non_equal", 3, 3) def execute(self, args): if not super(assertion_non_equal, self).execute(args): return None if args[1] == args[2]: log.error("assertion '%s' failed: '%s' == '%s'" % (args[0], args[1], args[2])) raise InvalidProfileException("Assertion '%s' failed." % args[0]) return None function_calc_isolated_cores.py000064400000003153147205255750013022 0ustar00import os import glob import tuned.logs from . import base import tuned.consts as consts log = tuned.logs.get() class calc_isolated_cores(base.Function): """ Calculates and returns isolated cores. The argument specifies how many cores per socket reserve for housekeeping. If not specified, 1 core per socket is reserved for housekeeping and the rest is isolated. """ def __init__(self): # max 1 argument super(calc_isolated_cores, self).__init__("calc_isolated_cores", 1) def execute(self, args): if not super(calc_isolated_cores, self).execute(args): return None cpus_reserve = 1 if len(args) > 0: if not args[0].isdecimal() or int(args[0]) < 0: log.error("invalid argument '%s' for builtin function '%s', it must be non-negative integer" % (args[0], self._name)) return None else: cpus_reserve = int(args[0]) topo = {} for cpu in glob.iglob(os.path.join(consts.SYSFS_CPUS_PATH, "cpu*")): cpuid = os.path.basename(cpu)[3:] if cpuid.isdecimal(): physical_package_id = os.path.join(cpu, "topology/physical_package_id") # Show no errors when the physical_package_id file does not exist -- the CPU may be offline. if not os.path.exists(physical_package_id): log.debug("file '%s' does not exist, cpu%s offline?" % (physical_package_id, cpuid)) continue socket = self._cmd.read_file(physical_package_id).strip() if socket.isdecimal(): topo[socket] = topo.get(socket, []) + [cpuid] isol_cpus = [] for cpus in topo.values(): cpus.sort(key = int) isol_cpus = isol_cpus + cpus[cpus_reserve:] isol_cpus.sort(key = int) return ",".join(isol_cpus) function_check_net_queue_count.py000064400000001212147205255750013372 0ustar00import tuned.logs from . import base log = tuned.logs.get() class check_net_queue_count(base.Function): """ Checks whether the user has specified a queue count for net devices. If not, return the number of housekeeping CPUs. """ def __init__(self): # 1 argument super(check_net_queue_count, self).__init__("check_net_queue_count", 1, 1) def execute(self, args): if not super(check_net_queue_count, self).execute(args): return None if args[0].isdigit(): return args[0] (ret, out) = self._cmd.execute(["nproc"]) log.warn("net-dev queue count is not correctly specified, setting it to HK CPUs %s" % (out)) return out function_cpuinfo_check.py000064400000001763147205255750011646 0ustar00import re import tuned.logs from . import base log = tuned.logs.get() class cpuinfo_check(base.Function): """ Checks regexes against /proc/cpuinfo. Accepts arguments in the following form: REGEX1, STR1, REGEX2, STR2, ...[, STR_FALLBACK] If REGEX1 matches something in /proc/cpuinfo it expands to STR1, if REGEX2 matches it expands to STR2. It stops on the first match, i.e. if REGEX1 matches, no more regexes are processed. If none regex matches it expands to STR_FALLBACK. If there is no fallback, it expands to empty string. """ def __init__(self): # unlimited number of arguments, min 2 arguments super(cpuinfo_check, self).__init__("cpuinfo_check", 0, 2) def execute(self, args): if not super(cpuinfo_check, self).execute(args): return None cpuinfo = self._cmd.read_file("/proc/cpuinfo") for i in range(0, len(args), 2): if i + 1 < len(args): if re.search(args[i], cpuinfo, re.MULTILINE): return args[i + 1] if len(args) % 2: return args[-1] else: return "" function_cpulist2devs.py000064400000000714147205255750011470 0ustar00import tuned.logs from . import base log = tuned.logs.get() class cpulist2devs(base.Function): """ Conversion function: converts CPU list to device strings """ def __init__(self): # arbitrary number of arguments super(cpulist2devs, self).__init__("cpulist2devs", 0) def execute(self, args): if not super(cpulist2devs, self).execute(args): return None return self._cmd.cpulist2string(self._cmd.cpulist_unpack(",".join(args)), prefix = "cpu") function_cpulist2hex.py000064400000000726147205255750011316 0ustar00import os import tuned.logs from . import base from tuned.utils.commands import commands log = tuned.logs.get() class cpulist2hex(base.Function): """ Conversion function: converts CPU list to hexadecimal CPU mask """ def __init__(self): # arbitrary number of arguments super(cpulist2hex, self).__init__("cpulist2hex", 0) def execute(self, args): if not super(cpulist2hex, self).execute(args): return None return self._cmd.cpulist2hex(",,".join(args)) function_cpulist2hex_invert.py000064400000001160147205255750012676 0ustar00import os import tuned.logs from . import base from tuned.utils.commands import commands log = tuned.logs.get() class cpulist2hex_invert(base.Function): """ Converts CPU list to hexadecimal CPU mask and inverts it """ def __init__(self): # arbitrary number of arguments super(cpulist2hex_invert, self).__init__("cpulist2hex_invert", 0) def execute(self, args): if not super(cpulist2hex_invert, self).execute(args): return None # current implementation inverts the CPU list and then converts it to hexmask return self._cmd.cpulist2hex(",".join(str(v) for v in self._cmd.cpulist_invert(",,".join(args)))) function_cpulist_invert.py000064400000001223147205255750012107 0ustar00import os import tuned.logs from . import base from tuned.utils.commands import commands log = tuned.logs.get() class cpulist_invert(base.Function): """ Inverts list of CPUs (makes its complement). For the complement it gets number of online CPUs from the /sys/devices/system/cpu/online, e.g. system with 4 CPUs (0-3), the inversion of list "0,2,3" will be "1" """ def __init__(self): # arbitrary number of arguments super(cpulist_invert, self).__init__("cpulist_invert", 0) def execute(self, args): if not super(cpulist_invert, self).execute(args): return None return ",".join(str(v) for v in self._cmd.cpulist_invert(",,".join(args))) function_cpulist_online.py000064400000001213147205255750012063 0ustar00import os import tuned.logs from . import base from tuned.utils.commands import commands log = tuned.logs.get() class cpulist_online(base.Function): """ Checks whether CPUs from list are online, returns list containing only online CPUs """ def __init__(self): # arbitrary number of arguments super(cpulist_online, self).__init__("cpulist_online", 0) def execute(self, args): if not super(cpulist_online, self).execute(args): return None cpus = self._cmd.cpulist_unpack(",".join(args)) online = self._cmd.cpulist_unpack(self._cmd.read_file("/sys/devices/system/cpu/online")) return ",".join(str(v) for v in cpus if v in online) function_cpulist_pack.py000064400000001175147205255750011524 0ustar00import os import tuned.logs from . import base from tuned.utils.commands import commands log = tuned.logs.get() class cpulist_pack(base.Function): """ Conversion function: packs CPU list in form 1,2,3,5 to 1-3,5. The cpulist_unpack is used as a preprocessor, so it always returns optimal results. For details about input syntax see cpulist_unpack. """ def __init__(self): # arbitrary number of arguments super(cpulist_pack, self).__init__("cpulist_pack", 0) def execute(self, args): if not super(cpulist_pack, self).execute(args): return None return ",".join(str(v) for v in self._cmd.cpulist_pack(",,".join(args))) function_cpulist_present.py000064400000001263147205255750012264 0ustar00import os import tuned.logs from . import base from tuned.utils.commands import commands log = tuned.logs.get() class cpulist_present(base.Function): """ Checks whether CPUs from list are present, returns list containing only present CPUs """ def __init__(self): # arbitrary number of arguments super(cpulist_present, self).__init__("cpulist_present", 0) def execute(self, args): if not super(cpulist_present, 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 sorted(list(set(cpus).intersection(set(present))))) function_cpulist_unpack.py000064400000000777147205255750012076 0ustar00import os import tuned.logs from . 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(cpulist_unpack, self).__init__("cpulist_unpack", 0) def execute(self, args): if not super(cpulist_unpack, self).execute(args): return None return ",".join(str(v) for v in self._cmd.cpulist_unpack(",,".join(args))) function_exec.py000064400000000747147205255750007773 0ustar00import os import tuned.logs from . import base from tuned.utils.commands import commands class execute(base.Function): """ Executes process and substitutes its output. """ def __init__(self): # unlimited number of arguments, min 1 argument (the name of executable) super(execute, self).__init__("exec", 0, 1) def execute(self, args): if not super(execute, self).execute(args): return None (ret, out) = self._cmd.execute(args) if ret == 0: return out return None function_hex2cpulist.py000064400000000730147205255750011311 0ustar00import os import tuned.logs from . import base from tuned.utils.commands import commands log = tuned.logs.get() class hex2cpulist(base.Function): """ Conversion function: converts hexadecimal CPU mask to CPU list """ def __init__(self): # 1 argument super(hex2cpulist, self).__init__("hex2cpulist", 1, 1) def execute(self, args): if not super(hex2cpulist, self).execute(args): return None return ",".join(str(v) for v in self._cmd.hex2cpulist(args[0])) function_kb2s.py000064400000000625147205255750007703 0ustar00import os import tuned.logs from . import base from tuned.utils.commands import commands class kb2s(base.Function): """ Conversion function: kbytes to sectors """ def __init__(self): # 1 argument super(kb2s, self).__init__("kb2s", 1, 1) def execute(self, args): if not super(kb2s, self).execute(args): return None try: return str(int(args[0]) * 2) except ValueError: return None function_regex_search_ternary.py000064400000001052147205255750013240 0ustar00import re from . import base class regex_search_ternary(base.Function): """ Ternary regex operator, it takes arguments in the following form STR1, REGEX, STR2, STR3 If REGEX matches STR1 (re.search is used), STR2 is returned, otherwise STR3 is returned """ def __init__(self): # 4 arguments super(regex_search_ternary, self).__init__("regex_search_ternary", 4, 4) def execute(self, args): if not super(regex_search_ternary, self).execute(args): return None if re.search(args[1], args[0]): return args[2] else: return args[3] function_s2kb.py000064400000000641147205255750007701 0ustar00import os import tuned.logs from . import base from tuned.utils.commands import commands class s2kb(base.Function): """ Conversion function: sectors to kbytes """ def __init__(self): # 1 argument super(s2kb, self).__init__("s2kb", 1, 1) def execute(self, args): if not super(s2kb, self).execute(args): return None try: return str(int(round(int(args[0]) / 2))) except ValueError: return None function_strip.py000064400000000626147205255750010204 0ustar00import os import tuned.logs from . import base from tuned.utils.commands import commands class strip(base.Function): """ Makes string from all arguments and strip it """ def __init__(self): # unlimited number of arguments, min 1 argument super(strip, self).__init__("strip", 0, 1) def execute(self, args): if not super(strip, self).execute(args): return None return "".join(args).strip() function_virt_check.py000064400000001123147205255750011155 0ustar00import os import tuned.logs from . import base from tuned.utils.commands import commands class virt_check(base.Function): """ Checks whether running inside virtual machine (VM) or on bare metal. If running inside VM expands to argument 1, otherwise expands to argument 2 (even on error). """ def __init__(self): # 2 arguments super(virt_check, self).__init__("virt_check", 2, 2) def execute(self, args): if not super(virt_check, self).execute(args): return None (ret, out) = self._cmd.execute(["virt-what"]) if ret == 0 and len(out) > 0: return args[0] return args[1] functions.py000064400000004142147205255750007143 0ustar00import os import re import glob from . import repository import tuned.logs import tuned.consts as consts from tuned.utils.commands import commands log = tuned.logs.get() cmd = commands() class Functions(): """ Built-in functions """ def __init__(self): self._repository = repository.Repository() self._parse_init() def _parse_init(self, s = ""): self._cnt = 0 self._str = s self._len = len(s) self._stack = [] self._esc = False def _curr_char(self): return self._str[self._cnt] if self._cnt < self._len else "" def _curr_substr(self, _len): return self._str[self._cnt:self._cnt + _len] def _push_pos(self, esc): self._stack.append((esc, self._cnt)) def _sub(self, a, b, s): self._str = self._str[:a] + s + self._str[b + 1:] self._len = len(self._str) self._cnt += len(s) - (b - a + 1) if self._cnt < 0: self._cnt = 0 def _process_func(self, _from): sl = re.split(r'(?