Skip to content

Commit

Permalink
Add default Plugin.setup() method
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bmr-cymru committed Apr 14, 2014
1 parent eefc895 commit f1c643d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
7 changes: 4 additions & 3 deletions sos/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,10 +647,11 @@ def default_enabled(self):
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):
"""
Expand Down
3 changes: 0 additions & 3 deletions sos/plugins/anacron.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions sos/plugins/distupgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ class DistUpgrade(Plugin):

files = None

def setup(self):
self.add_copy_specs(list(self.files))

class RedHatDistUpgrade(DistUpgrade, RedHatPlugin):

Expand Down

0 comments on commit f1c643d

Please sign in to comment.