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