aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2020-03-06 12:51:07 -0500
committerJake Hunsaker <jhunsake@redhat.com>2020-03-18 09:38:42 -0400
commitab1f4aafb3e06612f3a2c3b4630d288f5c7d7637 (patch)
tree3ccf01e5d813226a0308df166ec9395a3d4b362f
parented735dd6491bc33f707af4a18333b40eee354115 (diff)
downloadsos-ab1f4aafb3e06612f3a2c3b4630d288f5c7d7637.tar.gz
[Plugin] Add enablement check based on architecture
Plugins may now set an 'architectures' tuple when instantiating a Plugin to restrict that plugin from enabling only on those architectures provided any other enablement checks pass as well. By default, a plugin is considered to be runnable on any architecture. Related: #1975 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--sos/plugins/__init__.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index ba1accf2..86534fec 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -424,6 +424,7 @@ class Plugin(object):
commands = ()
kernel_mods = ()
services = ()
+ architectures = None
archive = None
profiles = ()
sysroot = '/'
@@ -1618,7 +1619,7 @@ class Plugin(object):
"""
# some files or packages have been specified for this package
if any([self.files, self.packages, self.commands, self.kernel_mods,
- self.services]):
+ self.services, self.architectures]):
if isinstance(self.files, six.string_types):
self.files = [self.files]
@@ -1661,12 +1662,22 @@ class Plugin(object):
return True
def _check_plugin_triggers(self, files, packages, commands, services):
-
- return (any(os.path.exists(fname) for fname in files) or
+ return ((any(os.path.exists(fname) for fname in files) or
any(self.is_installed(pkg) for pkg in packages) or
any(is_executable(cmd) for cmd in commands) or
any(self.is_module_loaded(mod) for mod in self.kernel_mods) or
- any(self.is_service(svc) for svc in services))
+ any(self.is_service(svc) for svc in services)) and
+ self.check_is_architecture())
+
+ def check_is_architecture(self):
+ """Checks whether or not the system is running on an architecture that
+ the plugin allows. If not architecture is set, assume plugin can run
+ on all arches.
+ """
+ if self.architectures is None:
+ return True
+ regex = '(?:%s)' % '|'.join(self.architectures)
+ return re.match(regex, self.policy.get_arch())
def default_enabled(self):
"""This decides whether a plugin should be automatically loaded or