Support syspurpose role matching in recommend.conf
Resolves: rhbz#1565598 Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
This commit is contained in:
parent
469a862501
commit
9efd6d7728
2 changed files with 25 additions and 0 deletions
|
|
@ -67,6 +67,9 @@ Requires: util-linux, dbus, polkit
|
|||
%if 0%{?fedora} > 22 || 0%{?rhel} > 7
|
||||
Recommends: kernel-tools
|
||||
%endif
|
||||
%if 0%{?rhel} > 7
|
||||
Requires: python3-syspurpose
|
||||
%endif
|
||||
|
||||
%description
|
||||
The tuned package contains a daemon that tunes system settings dynamically.
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ import procfs
|
|||
from subprocess import *
|
||||
from tuned.exceptions import TunedException
|
||||
import dmidecode
|
||||
try:
|
||||
import syspurpose.files
|
||||
have_syspurpose = True
|
||||
except:
|
||||
have_syspurpose = False
|
||||
|
||||
log = tuned.logs.get()
|
||||
|
||||
|
|
@ -421,6 +426,23 @@ class commands:
|
|||
break
|
||||
else:
|
||||
match = False
|
||||
elif option == "syspurpose_role":
|
||||
if have_syspurpose:
|
||||
s = syspurpose.files.SyspurposeStore(
|
||||
syspurpose.files.USER_SYSPURPOSE,
|
||||
raise_on_error = True)
|
||||
role = ""
|
||||
try:
|
||||
s.read_file()
|
||||
role = s.contents["role"]
|
||||
except (IOError, OSError, KeyError) as e:
|
||||
if hasattr(e, "errno") and e.errno != errno.ENOENT:
|
||||
log.error("Failed to load the syspurpose file: %s" % e)
|
||||
if re.match(value, role, re.IGNORECASE) is None:
|
||||
match = False
|
||||
else:
|
||||
log.error("Failed to process 'syspurpose_role' in '%s', the syspurpose module is not available" % fname)
|
||||
|
||||
if match:
|
||||
# remove the ",.*" suffix
|
||||
r = re.compile(r",[^,]*$")
|
||||
|
|
|
|||
Loading…
Reference in a new issue