aboutsummaryrefslogtreecommitdiffstats
path: root/src/sosreport
diff options
context:
space:
mode:
authorshnavid <shnavid@ef72aa8b-4018-0410-8976-d6e080ef94d8>2007-07-10 15:05:19 +0000
committershnavid <shnavid@ef72aa8b-4018-0410-8976-d6e080ef94d8>2007-07-10 15:05:19 +0000
commit7b96b045c9b18efe8513453f1d0344eebe776715 (patch)
tree85a5b824f3a985129ec20473e7714451a523eddd /src/sosreport
parent108b5395ea73f717c59dd3da72e952a97d29c89c (diff)
downloadsos-7b96b045c9b18efe8513453f1d0344eebe776715.tar.gz
* added --enableplugin (-e) option to enable plugins which were inactive
* cleaned up plugin activation conditions * added ability to suggest a name for output file in sos_report instead of auto-generated from command-line * added root_symlink option to create a symbolic link in sos_report root (and mimic sysreport's structure) git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@187 ef72aa8b-4018-0410-8976-d6e080ef94d8
Diffstat (limited to 'src/sosreport')
-rwxr-xr-xsrc/sosreport71
1 files changed, 47 insertions, 24 deletions
diff --git a/src/sosreport b/src/sosreport
index 10cab38a..dbfd368d 100755
--- a/src/sosreport
+++ b/src/sosreport
@@ -115,6 +115,9 @@ __cmdParser__.add_option("-n", "--noplugin", action="extend", \
__cmdParser__.add_option("-o", "--onlyplugin", action="extend", \
dest="onlyplugins", type="string", \
help="list of plugins to load")
+__cmdParser__.add_option("-e", "--enableplugin", action="extend", \
+ dest="enableplugins", type="string", \
+ help="list of plugins to enable")
__cmdParser__.add_option("-k", "--pluginopts", action="extend", \
dest="plugopts", type="string", \
help="plugin options in plugin_name.option=value format")
@@ -374,40 +377,60 @@ def sosreport():
for plug in plugins:
try:
if ((plug[-3:] == '.py') and (plug != "__init__.py")):
- sys.stdout.write(plug[:-3] + " ")
+ plugbase = plug[:-3]
+ if policy.validatePlugin(pluginpath + plug):
+ pluginClass = importPlugin("sos.plugins." + plugbase, plugbase)
+ else:
+ soslog.warning("plugin %s does not validate, skipping" % plug)
+ continue
+ if not pluginClass(plugbase, commons).checkenabled():
+ print "* %s (inactive)" % plugbase
+ continue
+ if not pluginClass(plugbase, commons).defaultenabled():
+ print "* %s (disabled by default)" % plugbase
+ continue
+ print " " + plugbase
except:
print "ouch"
print
- print
sys.exit()
# validate and load plugins
for plug in plugins:
- if ((plug[-3:] == '.py') and (plug != "__init__.py") and (not __cmdLineOpts__.noplugins or (plug[:-3] not in __cmdLineOpts__.noplugins)) and (not __cmdLineOpts__.onlyplugins or (plug[:-3] in __cmdLineOpts__.onlyplugins)) ):
+ plugbase = plug[:-3]
+ if not plug[-3:] == '.py' or plugbase == "__init__":
+ continue
+ if __cmdLineOpts__.noplugins and plugbase not in __cmdLineOpts__.noplugins:
+ soslog.log(logging.VERBOSE, "plug %s skipped" % plugbase)
+ continue
+ if __cmdLineOpts__.onlyplugins and not plugbase in __cmdLineOpts__.onlyplugins:
+ soslog.log(logging.VERBOSE, "plug %s skipped" % plugbase)
+ continue
+ try:
+ #print "importing plugin: %s" % plugbase
try:
- plugbase = plug[:-3]
- pidot = "sos.plugins." + plugbase
- #print "importing plugin: %s" % plugbase
- try:
- if policy.validatePlugin(pluginpath + plug):
- pluginClass = importPlugin(pidot, plugbase)
+ if policy.validatePlugin(pluginpath + plug):
+ pluginClass = importPlugin("sos.plugins." + plugbase, plugbase)
+ else:
+ soslog.warning("Plugin %s does not validate, skipping" % plug)
+ continue
+ if not __cmdLineOpts__.onlyplugins and not pluginClass(plugbase, commons).defaultenabled():
+ if __cmdLineOpts__.enableplugins and plugbase in __cmdLineOpts__.enableplugins:
+ soslog.log(logging.VERBOSE, "plugin %s manually activated" % plugbase)
else:
- soslog.warning("Plugin %s does not validate, skipping" % plug)
- continue
- if not __cmdLineOpts__.onlyplugins and not pluginClass(plugbase, commons).defaultenabled():
- soslog.log(logging.VERBOSE, "Plugin %s not loaded by default." % plug)
- continue
- if not pluginClass(plugbase, commons).checkenabled():
- soslog.log(logging.VERBOSE, "Plugin %s is inactive." % plug)
- continue
- loadedplugins.append((plugbase, pluginClass(plugbase, commons)))
- except:
- soslog.warning("Plugin %s does not install, skipping" % plug)
- raise
+ soslog.log(logging.VERBOSE, "Plugin %s not loaded by default." % plug)
+ continue
+ if not pluginClass(plugbase, commons).checkenabled():
+ soslog.log(logging.VERBOSE, "Plugin %s is inactive." % plug)
+ continue
+ loadedplugins.append((plugbase, pluginClass(plugbase, commons)))
except:
- if __raisePlugins__:
- raise
- soslog.warning("plugin load failed for %s" % plug)
+ soslog.warning("Plugin %s does not install, skipping" % plug)
+ raise
+ except:
+ if __raisePlugins__:
+ raise
+ soslog.warning("plugin load failed for %s" % plug)
if not len(loadedplugins):
soslog.error("no valid plugins were enabled")