aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sos/archive.py22
-rw-r--r--sos/plugins/foreman.py21
-rw-r--r--sos/plugins/katello.py21
-rw-r--r--sos/plugins/nfs.py31
-rw-r--r--sos/plugins/openhpi.py8
-rw-r--r--sos/plugins/sar.py8
-rw-r--r--sos/plugins/yum.py4
-rw-r--r--sos/policies/__init__.py8
-rw-r--r--sos/sosreport.py50
9 files changed, 110 insertions, 63 deletions
diff --git a/sos/archive.py b/sos/archive.py
index 7e193de1..4c8cceb1 100644
--- a/sos/archive.py
+++ b/sos/archive.py
@@ -63,6 +63,15 @@ class Archive(object):
to be included in the generated archive."""
raise NotImplementedError
+ def get_archive_path(self):
+ """Return a string representing the path to the temporary
+ archive. For archive classes that implement in-line handling
+ this will be the archive file itself. Archives that use a
+ directory based cache prior to packaging should return the
+ path to the temporary directory where the report content is
+ located"""
+ pass
+
def cleanup(self):
"""Clean up any temporary resources used by an Archive class."""
pass
@@ -80,7 +89,7 @@ class FileCacheArchive(Archive):
_tmp_dir = ""
_archive_root = ""
- _archive_path = ""
+ _archive_name = ""
def __init__(self, name, tmpdir):
self._name = name
@@ -145,6 +154,9 @@ class FileCacheArchive(Archive):
def get_tmp_dir(self):
return self._archive_root
+ def get_archive_path(self):
+ return self._archive_root
+
def makedirs(self, path, mode=0o700):
self._makedirs(self.dest_path(path))
self.log.debug("created directory at %s in FileCacheArchive %s"
@@ -161,8 +173,8 @@ class FileCacheArchive(Archive):
self.log.debug("finalizing archive %s" % self._archive_root)
self._build_archive()
self.cleanup()
- self.log.debug("built archive at %s (size=%d)" % (self._archive_path,
- os.stat(self._archive_path).st_size))
+ self.log.debug("built archive at %s (size=%d)" % (self._archive_name,
+ os.stat(self._archive_name).st_size))
return self._compress()
@@ -174,7 +186,7 @@ class TarFileArchive(FileCacheArchive):
def __init__(self, name, tmpdir):
super(TarFileArchive, self).__init__(name, tmpdir)
self._suffix = "tar"
- self._archive_path = os.path.join(tmpdir, self.name())
+ self._archive_name = os.path.join(tmpdir, self.name())
def set_tarinfo_from_stat(self, tar_info, fstat, mode=None):
tar_info.mtime = fstat.st_mtime
@@ -218,7 +230,7 @@ class TarFileArchive(FileCacheArchive):
old_pwd = os.getcwd()
old_umask = os.umask(0o077)
os.chdir(self._tmp_dir)
- tar = tarfile.open(self._archive_path, mode="w")
+ tar = tarfile.open(self._archive_name, mode="w")
tar.add(os.path.split(self._name)[1],
filter=self.copy_permissions_filter)
tar.close()
diff --git a/sos/plugins/foreman.py b/sos/plugins/foreman.py
index 60ec34df..28ea6a24 100644
--- a/sos/plugins/foreman.py
+++ b/sos/plugins/foreman.py
@@ -14,23 +14,18 @@
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-import sos.plugintools
import os
+from sos.plugins import Plugin, RedHatPlugin
-class foreman(sos.plugintools.PluginBase):
+class Foreman(Plugin, RedHatPlugin):
"""Foreman project related information
"""
- def defaultenabled(self):
- return True
-
- def checkenabled(self):
- self.packages = ["foreman"]
- self.files = ["/usr/sbin/foreman-debug"]
- return sos.plugintools.PluginBase.checkenabled(self)
+ plugin_name = 'foreman'
+ packages = ('foreman')
def setup(self):
- foreman_debug = "/usr/sbin/foreman-debug"
- if os.path.isfile(foreman_debug):
- foreman_debug_path = os.path.join(self.cInfo['dstroot'],"foreman-debug")
- self.collectExtOutput("%s -a -d %s" % (foreman_debug, foreman_debug_path))
+ foreman_debug_path = os.path.join(
+ self.get_cmd_path(),"foreman-debug")
+ self.add_cmd_output("%s -a -d %s"
+ % ("foreman-debug", foreman_debug_path))
diff --git a/sos/plugins/katello.py b/sos/plugins/katello.py
index 54b30fac..19993884 100644
--- a/sos/plugins/katello.py
+++ b/sos/plugins/katello.py
@@ -14,23 +14,18 @@
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-import sos.plugintools
import os
+from sos.plugins import Plugin, RedHatPlugin
-class katello(sos.plugintools.PluginBase):
+class Katello(Plugin, RedHatPlugin):
"""Katello project related information
"""
- def defaultenabled(self):
- return True
-
- def checkenabled(self):
- self.packages = ["katello", "katello-common", "katello-headpin"]
- self.files = ["/usr/bin/katello-debug"]
- return sos.plugintools.PluginBase.checkenabled(self)
+ plugin_name = 'katello'
+ packages = ('katello', 'katello-common', 'katello-headpin')
def setup(self):
- katello_debug = "/usr/bin/katello-debug"
- if os.path.isfile(katello_debug):
- katello_debug_path = os.path.join(self.cInfo['dstroot'],"katello-debug")
- self.collectExtOutput("%s --notar -d %s" % (katello_debug, katello_debug_path))
+ katello_debug_path = os.path.join(
+ self.get_cmd_path(),"katello-debug")
+ self.add_cmd_output("%s --notar -d %s"
+ % ("katello-debug", katello_debug_path))
diff --git a/sos/plugins/nfs.py b/sos/plugins/nfs.py
new file mode 100644
index 00000000..4acbe38e
--- /dev/null
+++ b/sos/plugins/nfs.py
@@ -0,0 +1,31 @@
+### This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
+
+class Nfs(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
+ """NFS related information
+ """
+ plugin_name = 'nfs'
+ packages = ['nfs-utils']
+
+ def setup(self):
+ self.add_copy_specs([
+ "/etc/nfsmount.conf",
+ "/etc/idmapd.conf",
+ "/proc/fs/nfsfs/servers",
+ "/proc/fs/nfsfs/volumes"
+ ])
+ return
+
diff --git a/sos/plugins/openhpi.py b/sos/plugins/openhpi.py
index a75f016d..dbe004d4 100644
--- a/sos/plugins/openhpi.py
+++ b/sos/plugins/openhpi.py
@@ -28,10 +28,6 @@ class OpenHPI(Plugin, RedHatPlugin):
])
def postproc(self):
- self.do_file_sub("/etc/openhpi/openhpi.conf"
- r'([Pp]assw(or)?d|[Pp]assphrase)[[:space:]]+\=[[:space:]]"(.*)"',
- r"\1******")
- self.do_file_sub("/etc/openhpi/openhpiclient.conf"
- r'([Pp]assw(or)?d|[Pp]assphrase)[[:space:]]+\=[[:space:]]"(.*)"',
- r"\1******")
+ self.do_file_sub("/etc/openhpi/openhpi.conf",
+ r'(\s*[Pp]ass.*\s*=\s*).*', r'\1********')
diff --git a/sos/plugins/sar.py b/sos/plugins/sar.py
index 4f89b533..570262a4 100644
--- a/sos/plugins/sar.py
+++ b/sos/plugins/sar.py
@@ -43,8 +43,12 @@ class Sar(Plugin,):
self.add_copy_spec_limit("/var/log/sa/sar[0-9]*",
sizelimit = self.sa_size)
self.add_copy_spec_limit("/var/log/sa/sa[0-9]*",
- sizelimit = self.sa_size)
- dirList = os.listdir(self.sa_path)
+ sizelimit = self.sa_size)
+ try:
+ dirList = os.listdir(self.sa_path)
+ except:
+ self.soslog.error("sar: could not list /var/log/sa")
+ return
# find all the sa file that don't have an existing sar file
for fname in dirList:
if fname[0:2] == 'sa' and fname[2] != 'r':
diff --git a/sos/plugins/yum.py b/sos/plugins/yum.py
index 6d473c90..5abf06f6 100644
--- a/sos/plugins/yum.py
+++ b/sos/plugins/yum.py
@@ -39,8 +39,8 @@ class Yum(Plugin, RedHatPlugin):
self.add_cmd_output("yum -C repolist")
# candlepin info
- self.add_forbidden_path("/etc/pki/entitlements/key.pem")
- self.add_forbidden_path("/etc/pki/entitlements/*-key.pem")
+ self.add_forbidden_path("/etc/pki/entitlement/key.pem")
+ self.add_forbidden_path("/etc/pki/entitlement/*-key.pem")
self.add_copy_specs([
"/etc/pki/product/*.pem",
"/etc/pki/consumer/cert.pem",
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py
index 69d310db..e666f0c7 100644
--- a/sos/policies/__init__.py
+++ b/sos/policies/__init__.py
@@ -206,12 +206,6 @@ No changes will be made to system configuration.
"""
pass
- def package_results(self, package_name):
- """
- This function is called prior to packaging.
- """
- pass
-
def post_work(self):
"""
This function is called after the sosreport has been generated.
@@ -477,5 +471,3 @@ class LinuxPolicy(Policy):
return
- def package_results(self, archive_filename):
- self._print(_("Creating compressed archive..."))
diff --git a/sos/sosreport.py b/sos/sosreport.py
index 40183ad4..04035a92 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -327,6 +327,19 @@ class SoSOptions(object):
self._batch = value
@property
+ def build(self):
+ if self._options != None:
+ return self._options.build
+ return self._build
+
+ @build.setter
+ def build(self):
+ self._check_options_initialized()
+ if not isinstance(value, bool):
+ raise TypeError("SoSOptions.build expects a boolean")
+ self._build = value
+
+ @property
def verbosity(self):
if self._options != None:
return self._options.verbosity
@@ -476,6 +489,9 @@ class SoSOptions(object):
parser.add_option("--batch", action="store_true",
dest="batch", default=False,
help="batch mode - do not prompt interactively")
+ parser.add_option("--build", action="store_true", \
+ dest="build", default=False, \
+ help="keep sos tree available and dont package results")
parser.add_option("-v", "--verbose", action="count",
dest="verbosity",
help="increase verbosity")
@@ -534,7 +550,8 @@ class SoSReport(object):
self._read_config()
self.policy = sos.policies.load()
self._is_root = self.policy.is_root()
- self.tmpdir = self.policy.get_tmp_dir(self.opts.tmp_dir)
+ self.tmpdir = os.path.abspath(
+ self.policy.get_tmp_dir(self.opts.tmp_dir))
if not os.path.isdir(self.tmpdir) \
or not os.access(self.tmpdir, os.W_OK):
# write directly to stderr as logging is not initialised yet
@@ -1096,24 +1113,29 @@ class SoSReport(object):
def final_work(self):
# package up the results for the support organization
- self.policy.package_results(self.archive.name())
+ if not self.opts.build:
+ self.ui_log.info(_("Creating compressed archive..."))
- self._finish_logging()
+ # compression could fail for a number of reasons
+ try:
+ final_filename = self.archive.finalize(self.opts.compression_type)
+ except:
+ if self.opts.debug:
+ raise
+ else:
+ return False
- # compression could fail for a number of reasons
- try:
- final_filename = self.archive.finalize(self.opts.compression_type)
- except:
- if self.opts.debug:
- raise
+ # automated submission will go here
+ if not self.opts.upload:
+ self.policy.display_results(final_filename)
else:
- return False
+ self.policy.upload_results(final_filename)
- # automated submission will go here
- if not self.opts.upload:
- self.policy.display_results(final_filename)
else:
- self.policy.upload_results(final_filename)
+ self.ui_log.info(_("\n sosreport build tree is located at : %s\n"
+ % self.archive.get_archive_path()))
+
+ self._finish_logging()
self.tempfile_util.clean()