From 469a86250168ab51287b2e2c3d88efc1c8edec7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= Date: Tue, 7 Aug 2018 17:07:49 +0200 Subject: [PATCH 1/2] Support chassis type matching in recommend.conf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves: rhbz#1565598 Signed-off-by: Ondřej Lysoněk --- Makefile | 4 +++- tuned.spec | 2 ++ tuned/utils/commands.py | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f302db1..816fcb1 100644 --- a/Makefile +++ b/Makefile @@ -212,6 +212,8 @@ test: $(PYTHON) -m unittest discover tests lint: - $(PYLINT) -E -f parseable tuned *.py + # --ignore commands.py is a workaround for + # https://bugzilla.redhat.com/show_bug.cgi?id=1613466 + $(PYLINT) --ignore commands.py -E -f parseable tuned *.py .PHONY: clean archive srpm tag test lint diff --git a/tuned.spec b/tuned.spec index ed4c4f0..2b4f039 100644 --- a/tuned.spec +++ b/tuned.spec @@ -57,8 +57,10 @@ Requires: %{_py}-schedutils, %{_py}-linux-procfs, %{_py}-perf # requires for packages with inconsistent python2/3 names %if %{with python3} Requires: python3-dbus, python3-gobject-base +Requires: python3-dmidecode %else Requires: dbus-python, pygobject3-base +Requires: python-dmidecode %endif Requires: virt-what, ethtool, gawk, hdparm Requires: util-linux, dbus, polkit diff --git a/tuned/utils/commands.py b/tuned/utils/commands.py index 41d6d99..8bb31a3 100644 --- a/tuned/utils/commands.py +++ b/tuned/utils/commands.py @@ -9,6 +9,7 @@ import re import procfs from subprocess import * from tuned.exceptions import TunedException +import dmidecode log = tuned.logs.get() @@ -413,6 +414,13 @@ class commands: ps.reload_threads() if len(ps.find_by_regex(re.compile(value))) == 0: match = False + elif option == "chassis_type": + for chassis in dmidecode.chassis().values(): + chassis_type = chassis["data"]["Type"].decode("ascii") + if re.match(value, chassis_type, re.IGNORECASE): + break + else: + match = False if match: # remove the ",.*" suffix r = re.compile(r",[^,]*$") -- 2.17.1