aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2014-04-14 20:09:19 +0100
committerBryn M. Reeves <bmr@redhat.com>2014-04-14 20:09:19 +0100
commitf1c643ddea69c526a1040c9768a4efd36a86e574 (patch)
tree371d2781eb75120feb0c53452bb85794ffec0625
parenteefc895b1cbfcb347d2f35828e92e606bf8dc457 (diff)
downloadsos-f1c643ddea69c526a1040c9768a4efd36a86e574.tar.gz
Add default Plugin.setup() method
Adding a default setup() method to the base Plugin class allows useful plugins to be written declaratively by setting the 'files' and 'packages' members of the subclass, e.g.: class FooPlugin(Plugin): plugin_name = 'foo' packages = ('foo',) files = ('/etc/foo.conf',) Creates a plugin class named 'foo' that will run whenever the 'foo' package is installed or the '/etc/foo.conf' file exists. The method calls self.add_copy_specs() with the plugin's files list. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/__init__.py7
-rw-r--r--sos/plugins/anacron.py3
-rw-r--r--sos/plugins/distupgrade.py2
3 files changed, 4 insertions, 8 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index a599c714..6cac31c4 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -647,10 +647,11 @@ class Plugin(object):
return True
def setup(self):
- """This method must be overridden to add the copy_specs, forbidden_paths,
- and external programs to be collected at a minimum.
+ """Collect the list of files declared by the plugin. This method
+ may be overridden to add further copy_specs, forbidden_paths, and
+ external programs if required.
"""
- pass
+ self.add_copy_specs(list(self.files))
def postproc(self):
"""
diff --git a/sos/plugins/anacron.py b/sos/plugins/anacron.py
index 60efa27b..a5635355 100644
--- a/sos/plugins/anacron.py
+++ b/sos/plugins/anacron.py
@@ -25,7 +25,4 @@ class Anacron(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
# just look for the configuration file which is common
files = ('/etc/anacrontab',)
- def setup(self):
- self.add_copy_specs(list(self.files))
-
# vim: et ts=4 sw=4
diff --git a/sos/plugins/distupgrade.py b/sos/plugins/distupgrade.py
index d618dfc6..8bc44c23 100644
--- a/sos/plugins/distupgrade.py
+++ b/sos/plugins/distupgrade.py
@@ -24,8 +24,6 @@ class DistUpgrade(Plugin):
files = None
- def setup(self):
- self.add_copy_specs(list(self.files))
class RedHatDistUpgrade(DistUpgrade, RedHatPlugin):