提交 b38a3851 编写于 作者: H hanxinke

atune: support the case of the same key in the same section in the profile

上级 40bc70ed
......@@ -20,7 +20,7 @@ import os
import subprocess
import random
from analysis.plugin.public import GetConfigError
from analysis.plugin.public import GetConfigError, SetConfigError
from ..common import Configurator
LOGGER = logging.getLogger(__name__)
......@@ -30,6 +30,7 @@ class Script(Configurator):
"""The script extention of CPI"""
_module = "SCRIPT"
_submod = "SCRIPT"
cmd_delimiter = "|"
def __init__(self, user=None):
Configurator.__init__(self, user)
......@@ -37,19 +38,13 @@ class Script(Configurator):
def _set(self, key, value):
name = os.path.basename(key)
script = "{}/set.sh".format(key)
output = subprocess.run(
"{script} {val}".format(
script=script,
val=value).split(),
stdout=subprocess.DEVNULL,
stderr=subprocess.PIPE,
shell=False,
check=True)
if len(output.stderr) != 0:
err = UserWarning(name + ": " + output.stderr.decode())
LOGGER.error("%s.%s: %s", self.__class__.__name__,
inspect.stack()[0][3], str(err))
raise err
if not os.path.exists(script):
raise SetConfigError("script {} not implement".format(script))
if value is not None:
for command in value.split(self.cmd_delimiter):
self.run_script(name, script, command, subprocess.DEVNULL)
else:
self.run_script(name, script, value, subprocess.DEVNULL)
return 0
def _get(self, key, value):
......@@ -57,12 +52,35 @@ class Script(Configurator):
script = "{}/get.sh".format(key)
if not os.path.exists(script):
raise GetConfigError("script {} not implement".format(script))
output_list = []
if value is not None:
for command in value.split(self.cmd_delimiter):
out = self.run_script(name, script, command, subprocess.PIPE)
output_list.append(out.stdout.decode().strip())
output = self.cmd_delimiter.join(output_list)
else:
out = self.run_script(name, script, value, subprocess.PIPE)
output = out.stdout.decode()
LOGGER.info("get script: %s %s", name, output)
return output
def run_script(self, name, script, value, stdout):
"""
run specified script.
:param name: The path name of script
:param script: The absolute path of script
:param value: The script parameter
:param stdout: The type of stdout
:return output: The result of running the script
:raise Exception: Failed to run script
"""
LOGGER.info("exec %s %s", script, value)
output = subprocess.run(
"{script} {val}".format(
script=script,
val=value).split(),
stdout=subprocess.PIPE,
stdout=stdout,
stderr=subprocess.PIPE,
shell=False,
check=True)
......@@ -71,7 +89,7 @@ class Script(Configurator):
LOGGER.error("%s.%s: %s", self.__class__.__name__,
inspect.stack()[0][3], str(err))
raise err
return output.stdout.decode()
return output
@staticmethod
def check(_, __):
......
......@@ -283,10 +283,7 @@ irqbalance=stop
[script]
prefetch = off
ethtool = -K {network} gro on
ethtool = -K {network} gso on
ethtool = -K {network} tso on
ethtool = -X {network} hfunc toeplitz
ethtool = -K {network} gro on | -K {network} gso on | -K {network} tso on | -X {network} hfunc toeplitz
swap = -a off
[tip]
......@@ -655,11 +652,7 @@ bind network interrupts to its affinity numa node = affinity
[script]
prefetch = off
ifconfig = {network} mtu 1500
ethtool = -C {network} adaptive-rx on
ethtool = -K {network} gro on
ethtool = -K {network} gso on
ethtool = -K {network} tso on
#ethtool = -K {network} lro on
ethtool = -C {network} adaptive-rx on | -K {network} gro on | -K {network} gso on | -K {network} tso on
[ulimit]
{user}.hard.nofile = 102400
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册