diff options
author | astokes <astokes@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2009-05-01 21:28:46 +0000 |
---|---|---|
committer | astokes <astokes@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2009-05-01 21:28:46 +0000 |
commit | afa97386eb0e214032afe9d4a2b1759487900d19 (patch) | |
tree | f93effbdefcd8299783ed9184f442e18ae14d13c /src/lib | |
parent | e95c59b81a796386ae4ac5b09352276336dd7f5f (diff) | |
download | sos-afa97386eb0e214032afe9d4a2b1759487900d19.tar.gz |
- patches from rhbz498398
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@564 ef72aa8b-4018-0410-8976-d6e080ef94d8
Diffstat (limited to 'src/lib')
26 files changed, 53 insertions, 49 deletions
diff --git a/src/lib/sos/plugins/amd.py b/src/lib/sos/plugins/amd.py index a8e6ae13..d2e85f09 100644 --- a/src/lib/sos/plugins/amd.py +++ b/src/lib/sos/plugins/amd.py @@ -21,7 +21,7 @@ class amd(sos.plugintools.PluginBase): """Amd automounter information """ def checkenabled(self): - if self.cInfo["policy"].pkgByName("am-utils") or os.path.exists("/etc/rc.d/init.d/amd"): + if self.isInstalled("am-utils") or os.path.exists("/etc/rc.d/init.d/amd"): return True return False diff --git a/src/lib/sos/plugins/autofs.py b/src/lib/sos/plugins/autofs.py index 48dd57b4..bb7c6182 100644 --- a/src/lib/sos/plugins/autofs.py +++ b/src/lib/sos/plugins/autofs.py @@ -21,7 +21,7 @@ class autofs(sos.plugintools.PluginBase): """autofs server-related information """ def checkenabled(self): - if self.cInfo["policy"].runlevelDefault() in self.cInfo["policy"].runlevelByService("autofs"): + if self.policy().runlevelDefault() in self.policy().runlevelByService("autofs"): return True return False diff --git a/src/lib/sos/plugins/cluster.py b/src/lib/sos/plugins/cluster.py index 6d4de2a0..cd986d68 100644 --- a/src/lib/sos/plugins/cluster.py +++ b/src/lib/sos/plugins/cluster.py @@ -25,7 +25,7 @@ class cluster(sos.plugintools.PluginBase): ('taskdump', 'trigger 3 sysrq+t dumps every 5 seconds (dangerous)', 'slow', False)] def checkenabled(self): - rhelver = self.cInfo["policy"].rhelVersion() + rhelver = self.policy().rhelVersion() if rhelver == 4: self.packages = [ "ccs", "cman", "cman-kernel", "magma", "magma-plugins", "rgmanager", "fence", "dlm", "dlm-kernel", "gulm", @@ -45,7 +45,7 @@ class cluster(sos.plugintools.PluginBase): return False def diagnose(self): - rhelver = self.cInfo["policy"].rhelVersion() + rhelver = self.policy().rhelVersion() # check if the minimum set of packages is installed # for RHEL4 RHCS(ccs, cman, cman-kernel, magma, magma-plugins, (dlm, dlm-kernel) || gulm, perl-Net-Telnet, rgmanager, fence) @@ -78,7 +78,7 @@ class cluster(sos.plugintools.PluginBase): for modname in mods_check: found = 0 - if self.cInfo["policy"].allPkgsByNameRegex( "^" + modname ): + if self.policy().allPkgsByNameRegex( "^" + modname ): found = 1 status, output = commands.getstatusoutput('/sbin/modinfo -F vermagic ' + modname) @@ -97,12 +97,12 @@ class cluster(sos.plugintools.PluginBase): self.addDiagnose("required module is available but not loaded: %s" % modname) for pkg in pkgs_check: - if self.cInfo["policy"].pkgByName(pkg) == None: + if not self.isInstalled(pkg): self.addDiagnose("required package is missing: %s" % pkg) if rhelver == "4": # (dlm, dlm-kernel) || gulm - if not ((self.cInfo["policy"].pkgByName("dlm") and self.cInfo["policy"].pkgByName("dlm-kernel")) or self.cInfo["policy"].pkgByName("gulm")): + if not ((self.isInstalled("dlm") and self.isInstalled("dlm-kernel")) or self.isInstalled("gulm")): self.addDiagnose("required packages are missing: (dlm, dlm-kernel) || gulm") # check if all the needed daemons are active at sosreport time @@ -114,7 +114,7 @@ class cluster(sos.plugintools.PluginBase): if status != 0: self.addDiagnose("service %s is not running" % service) - if not self.cInfo["policy"].runlevelDefault() in self.cInfo["policy"].runlevelByService(service): + if not self.policy().runlevelDefault() in self.policy().runlevelByService(service): self.addDiagnose("service %s is not started in default runlevel" % service) # FIXME: missing important cman services @@ -161,7 +161,7 @@ class cluster(sos.plugintools.PluginBase): hostname = commands.getoutput("/bin/uname -n").split(".")[0] if len(xpathContext.xpathEval('/cluster/clusternodes/clusternode[@name = "%s" and /cluster/fencedevices/fencedevice[@agent="fence_rsa" or @agent="fence_drac"]/@name=fence/method/device/@name]' % hostname )): status, output = commands.getstatusoutput("/sbin/service acpid status") - if status == 0 or self.cInfo["policy"].runlevelDefault() in self.cInfo["policy"].runlevelByService("acpid"): + if status == 0 or self.policy().runlevelDefault() in self.policy().runlevelByService("acpid"): self.addDiagnose("acpid is enabled, this may cause problems with your fencing method.") # check for fs exported via nfs without nfsid attribute @@ -274,11 +274,9 @@ class cluster(sos.plugintools.PluginBase): try: if output[18:] == "Cluster-Member": return True - else: - return False except: pass - return None + return False def get_gfs_sb_field(self, device, field): for line in commands.getoutput("/sbin/gfs_tool sb %s all" % device).split("\n"): diff --git a/src/lib/sos/plugins/cs.py b/src/lib/sos/plugins/cs.py index 75803c0e..7f642df9 100644 --- a/src/lib/sos/plugins/cs.py +++ b/src/lib/sos/plugins/cs.py @@ -37,7 +37,7 @@ class cs(sos.plugintools.PluginBase): # /var/lib/rhpki-kra ect). def checkenabled(self): - if self.cInfo["policy"].pkgByName("rhpki-common") or os.path.exists("/var/lib/rhpki-*"): + if self.isInstalled("rhpki-common") or os.path.exists("/var/lib/rhpki-*"): return True return False diff --git a/src/lib/sos/plugins/ds.py b/src/lib/sos/plugins/ds.py index 2c24beeb..6f24cb8c 100644 --- a/src/lib/sos/plugins/ds.py +++ b/src/lib/sos/plugins/ds.py @@ -22,19 +22,19 @@ class ds(sos.plugintools.PluginBase): """ def check_version(self): - if self.cInfo["policy"].pkgByName("redhat-ds-base") or \ + if self.isInstalled("redhat-ds-base") or \ os.path.exists("/etc/dirsrv"): return "ds8" - elif self.cInfo["policy"].pkgByName("redhat-ds-7") or \ + elif self.isInstalled("redhat-ds-7") or \ os.path.exists("/opt/redhat-ds"): return "ds7" return False def checkenabled(self): - if self.cInfo["policy"].pkgByName("redhat-ds-base") or \ + if self.isInstalled("redhat-ds-base") or \ os.path.exists("/etc/dirsrv"): return True - elif self.cInfo["policy"].pkgByName("redhat-ds-7") or \ + elif self.isInstalled("redhat-ds-7") or \ os.path.exists("/opt/redhat-ds"): return True return False diff --git a/src/lib/sos/plugins/ftp.py b/src/lib/sos/plugins/ftp.py index c3b8f5c4..5bed5667 100644 --- a/src/lib/sos/plugins/ftp.py +++ b/src/lib/sos/plugins/ftp.py @@ -19,7 +19,7 @@ class ftp(sos.plugintools.PluginBase): """FTP server related information """ def checkenabled(self): - if self.cInfo["policy"].pkgByName("vsftpd") or os.path.exists("/etc/vsftpd"): + if self.isInstalled("vsftpd") or os.path.exists("/etc/vsftpd"): return True return False diff --git a/src/lib/sos/plugins/hardware.py b/src/lib/sos/plugins/hardware.py index 3920a8db..97e51fd2 100644 --- a/src/lib/sos/plugins/hardware.py +++ b/src/lib/sos/plugins/hardware.py @@ -39,7 +39,7 @@ class hardware(sos.plugintools.PluginBase): self.collectExtOutput("/usr/sbin/dmidecode", root_symlink = "dmidecode") - if self.cInfo["policy"].getArch().endswith("386"): + if self.policy().getArch().endswith("386"): self.collectExtOutput("/usr/sbin/x86info -a") self.collectExtOutput("/sbin/lsusb") diff --git a/src/lib/sos/plugins/ipa.py b/src/lib/sos/plugins/ipa.py index a6257966..af8a2c5a 100644 --- a/src/lib/sos/plugins/ipa.py +++ b/src/lib/sos/plugins/ipa.py @@ -24,7 +24,7 @@ class ipa(sos.plugintools.PluginBase): # need to get kerberos and ipa specific addons. def checkenabled(self): - if self.cInfo["policy"].pkgByName("ipa-server") or os.path.exists("/etc/ipa"): + if self.isInstalled("ipa-server") or os.path.exists("/etc/ipa"): return True return False diff --git a/src/lib/sos/plugins/ipsec.py b/src/lib/sos/plugins/ipsec.py index bba33173..87671b87 100644 --- a/src/lib/sos/plugins/ipsec.py +++ b/src/lib/sos/plugins/ipsec.py @@ -21,7 +21,7 @@ class ipsec(sos.plugintools.PluginBase): """ipsec related information """ def checkenabled(self): - if self.cInfo["policy"].pkgByName("ipsec-tools") or exists("/etc/racoon/racoon.conf"): + if self.isInstalled("ipsec-tools") or exists("/etc/racoon/racoon.conf"): return True return False diff --git a/src/lib/sos/plugins/kdump.py b/src/lib/sos/plugins/kdump.py index f93414da..cc10d08a 100644 --- a/src/lib/sos/plugins/kdump.py +++ b/src/lib/sos/plugins/kdump.py @@ -19,7 +19,7 @@ class kdump(sos.plugintools.PluginBase): """Kdump related information """ def checkenabled(self): - if self.cInfo["policy"].pkgByName("kexec-tools") or exists("/etc/kdump.conf"): + if self.isInstalled("kexec-tools") or exists("/etc/kdump.conf"): return True return False diff --git a/src/lib/sos/plugins/kernel.py b/src/lib/sos/plugins/kernel.py index 604d42f2..14b13b20 100644 --- a/src/lib/sos/plugins/kernel.py +++ b/src/lib/sos/plugins/kernel.py @@ -62,7 +62,7 @@ class kernel(sos.plugintools.PluginBase): self.addCopySpec("/proc/filesystems") self.addCopySpec("/proc/ksyms") self.addCopySpec("/proc/slabinfo") - self.addCopySpec("/lib/modules/%s/modules.dep" % self.cInfo["policy"].kernelVersion()) + self.addCopySpec("/lib/modules/%s/modules.dep" % self.policy().kernelVersion()) self.addCopySpec("/etc/conf.modules") self.addCopySpec("/etc/modules.conf") self.addCopySpec("/etc/modprobe.conf") diff --git a/src/lib/sos/plugins/netdump.py b/src/lib/sos/plugins/netdump.py index 987d06ed..d57431b8 100644 --- a/src/lib/sos/plugins/netdump.py +++ b/src/lib/sos/plugins/netdump.py @@ -19,7 +19,7 @@ class netdump(sos.plugintools.PluginBase): """Netdump Configuration Information """ def checkenabled(self): - if self.cInfo["policy"].pkgByName("netdump") or exists("/etc/sysconfig/netdump*"): + if self.isInstalled("netdump") or exists("/etc/sysconfig/netdump*"): return True return False diff --git a/src/lib/sos/plugins/nfsserver.py b/src/lib/sos/plugins/nfsserver.py index 1e352032..53391463 100644 --- a/src/lib/sos/plugins/nfsserver.py +++ b/src/lib/sos/plugins/nfsserver.py @@ -22,7 +22,7 @@ class nfsserver(sos.plugintools.PluginBase): """NFS server-related information """ def checkenabled(self): - if self.cInfo["policy"].runlevelDefault() in self.cInfo["policy"].runlevelByService("nfs"): + if self.policy().runlevelDefault() in self.policy().runlevelByService("nfs"): return True try: diff --git a/src/lib/sos/plugins/openswan.py b/src/lib/sos/plugins/openswan.py index 4a9f8ff7..4c119807 100644 --- a/src/lib/sos/plugins/openswan.py +++ b/src/lib/sos/plugins/openswan.py @@ -21,7 +21,7 @@ class openswan(sos.plugintools.PluginBase): """ipsec related information """ def checkenabled(self): - if self.cInfo["policy"].pkgByName("openswan") or os.path.exists("/etc/ipsec.conf"): + if self.isInstalled("openswan") or os.path.exists("/etc/ipsec.conf"): return True return False diff --git a/src/lib/sos/plugins/postfix.py b/src/lib/sos/plugins/postfix.py index 8d2d06b5..9ab78b2a 100644 --- a/src/lib/sos/plugins/postfix.py +++ b/src/lib/sos/plugins/postfix.py @@ -19,7 +19,7 @@ class postfix(sos.plugintools.PluginBase): """mail server related information """ def checkenabled(self): - if self.cInfo["policy"].pkgByName("postfix") or exists("/etc/rc.d/init.d/postfix"): + if self.isInstalled("postfix") or exists("/etc/rc.d/init.d/postfix"): return True return False diff --git a/src/lib/sos/plugins/radius.py b/src/lib/sos/plugins/radius.py index 8c1786e3..b5015c71 100644 --- a/src/lib/sos/plugins/radius.py +++ b/src/lib/sos/plugins/radius.py @@ -21,7 +21,7 @@ class radius(sos.plugintools.PluginBase): """radius related information """ def checkenabled(self): - if self.cInfo["policy"].pkgByName("freeradius") or os.path.exists("/etc/raddb"): + if self.isInstalled("freeradius") or os.path.exists("/etc/raddb"): return True return False diff --git a/src/lib/sos/plugins/rhn.py b/src/lib/sos/plugins/rhn.py index 482aa143..450d8f1d 100644 --- a/src/lib/sos/plugins/rhn.py +++ b/src/lib/sos/plugins/rhn.py @@ -26,8 +26,8 @@ class rhn(sos.plugintools.PluginBase): def checkenabled(self): # enable if any related package is installed - self.satellite = self.cInfo["policy"].pkgByName("rhns-satellite-tools") - self.proxy = self.cInfo["policy"].pkgByName("rhns-proxy-tools") + self.satellite = self.isInstalled("rhns-satellite-tools") + self.proxy = self.isInstalled("rhns-proxy-tools") if self.satellite or self.proxy: return True @@ -68,7 +68,7 @@ class rhn(sos.plugintools.PluginBase): self.addCopySpec("/etc/jabberd") # tomcat (4.x and newer satellites only) - if not self.cInfo["policy"].pkgNVRA(satellite)[1].startswith("3."): + if not self.policy().pkgNVRA(satellite)[1].startswith("3."): self.addCopySpec("/etc/tomcat5") self.addCopySpec("/var/log/tomcat5") diff --git a/src/lib/sos/plugins/s390.py b/src/lib/sos/plugins/s390.py index 6fe2d179..005be111 100644 --- a/src/lib/sos/plugins/s390.py +++ b/src/lib/sos/plugins/s390.py @@ -26,7 +26,7 @@ class s390(sos.plugintools.PluginBase): ### Check for s390 arch goes here def checkenabled(self): - sysArch = self.cInfo["policy"].getArch() + sysArch = self.policy().getArch() if "s390" in sysArch: return True return False @@ -68,7 +68,7 @@ class s390(sos.plugintools.PluginBase): self.collectExtOutput("/sbin/dasdview -x -i -j -l -f %s" % (x,)) self.collectExtOutput("/sbin/fdasd -p %s" % (x,)) try: - rhelver = self.cInfo["policy"].pkgByName("redhat-release")[1] + rhelver = self.policy().pkgByName("redhat-release")[1] except: rhelver = None if rhelver.startswith("5"): diff --git a/src/lib/sos/plugins/selinux.py b/src/lib/sos/plugins/selinux.py index 5f0c1f40..62def4fd 100644 --- a/src/lib/sos/plugins/selinux.py +++ b/src/lib/sos/plugins/selinux.py @@ -40,7 +40,7 @@ class selinux(sos.plugintools.PluginBase): def analyze(self): # Check for SELinux denials and capture raw output from sealert - if self.cInfo["policy"].runlevelDefault() in self.cInfo["policy"].runlevelByService("setroubleshoot"): + if self.policy().runlevelDefault() in self.policy().runlevelByService("setroubleshoot"): # TODO: fixup regex for more precise matching sealert=doRegexFindAll(r"^.*setroubleshoot:.*(sealert\s-l\s.*)","/var/log/messages") if sealert: diff --git a/src/lib/sos/plugins/sendmail.py b/src/lib/sos/plugins/sendmail.py index 76b40905..56ea2e7a 100644 --- a/src/lib/sos/plugins/sendmail.py +++ b/src/lib/sos/plugins/sendmail.py @@ -21,7 +21,7 @@ class sendmail(sos.plugintools.PluginBase): """sendmail information """ def checkenabled(self): - if self.cInfo["policy"].pkgByName("sendmail") or os.path.exists("/etc/rc.d/init.d/sendmail"): + if self.isInstalled("sendmail") or os.path.exists("/etc/rc.d/init.d/sendmail"): return True return False diff --git a/src/lib/sos/plugins/smartcard.py b/src/lib/sos/plugins/smartcard.py index aa9cedd2..1ce57bac 100644 --- a/src/lib/sos/plugins/smartcard.py +++ b/src/lib/sos/plugins/smartcard.py @@ -22,7 +22,7 @@ class smartcard(sos.plugintools.PluginBase): """ def checkenabled(self): - if self.cInfo["policy"].pkgByName("pam_pkcs11") or os.path.exists("/etc/pam_pkcs11/pam_pkcs11.conf"): + if self.isInstalled("pam_pkcs11") or os.path.exists("/etc/pam_pkcs11/pam_pkcs11.conf"): return True return False diff --git a/src/lib/sos/plugins/veritas.py b/src/lib/sos/plugins/veritas.py index a041c81b..6090627a 100644 --- a/src/lib/sos/plugins/veritas.py +++ b/src/lib/sos/plugins/veritas.py @@ -71,7 +71,7 @@ class veritas(sos.plugintools.PluginBase): def checkenabled(self): for pkgname in self.package_list: - if self.cInfo["policy"].allPkgsByName(pkgname): + if self.policy().allPkgsByName(pkgname): return True return False @@ -213,9 +213,9 @@ class veritas(sos.plugintools.PluginBase): # TODO: Do necessary checks for different archs, i.e. z-series and ia64 self.collectExtOutput("/bin/rpm -qa | /bin/grep -i VRTS | /bin/grep -v doc | /bin/grep -v man") # Determine what information to collect based on installed packages - if self.cInfo["policy"].pkgByName("VRTSvxfs"): get_vxfs() - if self.cInfo["policy"].pkgByName("VRTSvxfs"): get_vxvm() + if self.isInstalled("VRTSvxfs"): get_vxfs() + if self.isInstalled("VRTSvxfs"): get_vxvm() # I think if one of these is present it is assumed that VCS is installed - if self.cInfo["policy"].pkgByName("VRTSvmpro") or self.cInfo["policy"].pkgByName("VRTSfspro"): get_vcs() + if self.isInstalled("VRTSvmpro") or self.isInstalled("VRTSfspro"): get_vcs() return diff --git a/src/lib/sos/plugins/xinetd.py b/src/lib/sos/plugins/xinetd.py index f5292fb5..b131f165 100644 --- a/src/lib/sos/plugins/xinetd.py +++ b/src/lib/sos/plugins/xinetd.py @@ -21,7 +21,7 @@ class xinetd(sos.plugintools.PluginBase): """xinetd information """ def checkenabled(self): - if self.cInfo["policy"].pkgByName("xinetd") or os.path.exists("/etc/xinetd.conf"): + if self.isInstalled("xinetd") or os.path.exists("/etc/xinetd.conf"): return True return False diff --git a/src/lib/sos/plugins/yum.py b/src/lib/sos/plugins/yum.py index 672451ee..60665dd6 100644 --- a/src/lib/sos/plugins/yum.py +++ b/src/lib/sos/plugins/yum.py @@ -30,7 +30,7 @@ class yum(sos.plugintools.PluginBase): # repo sanity checking # TODO: elaborate/validate actual repo files, however this directory should # be empty on RHEL 5+ systems. - if self.cInfo["policy"].rhelVersion() == 5: + if self.policy().rhelVersion() == 5: if len(os.listdir("/etc/yum.repos.d/")): self.addAlert("/etc/yum.repos.d/ contains additional repository "+ "information and can cause rpm conflicts.") diff --git a/src/lib/sos/plugintools.py b/src/lib/sos/plugintools.py index f9e10ae1..60253c05 100644 --- a/src/lib/sos/plugintools.py +++ b/src/lib/sos/plugintools.py @@ -97,6 +97,14 @@ class PluginBase: self.optNames.append(opt[0]) self.optParms.append({'desc':opt[1], 'speed':opt[2], 'enabled':opt[3]}) + def policy(self): + return self.cInfo["policy"] + + def isInstalled(self, package_name): + '''Is the package $package_name installed? + ''' + return (self.policy().pkgByName(package_name) != {}) + # Method for applying regexp substitutions def doRegexSub(self, srcpath, regexp, subst): '''Apply a regexp substitution to a file archived by sosreport. @@ -212,6 +220,7 @@ class PluginBase: return except: self.soslog.log(logging.VERBOSE2, "error copying file %s (SOMETHING HAPPENED)" % (srcpath)) + return self.copiedFiles.append({'srcpath':srcpath, 'dstpath':tdstpath, 'symlink':"no"}) # save in our list @@ -533,7 +542,7 @@ class PluginBase: if os.path.exists(fname): return True for pkgname in self.packages: - if self.cInfo["policy"].pkgByName(pkgname): + if self.isInstalled(pkgname): return True return False diff --git a/src/lib/sos/policyredhat.py b/src/lib/sos/policyredhat.py index a10e7dfb..e1c0c5c4 100755 --- a/src/lib/sos/policyredhat.py +++ b/src/lib/sos/policyredhat.py @@ -65,7 +65,6 @@ class SosPolicy: self.report_md5 = "" self.reportName = "" self.ticketNumber = "" - return def setCommons(self, commons): self.cInfo = commons @@ -79,12 +78,10 @@ class SosPolicy: return True def pkgProvides(self, name): - pkg = self.pkgByName(name) - return pkg['providename'] + return self.pkgByName(name).get('providename') def pkgRequires(self, name): - pkg = self.pkgByName(name) - return pkg['requirename'] + return self.pkgByName(name).get('requirename') def allPkgsByName(self, name): return self.allPkgs("name", name) @@ -100,7 +97,7 @@ class SosPolicy: return self.allPkgsByName(name)[-1] except: pass - return None + return {} def allPkgs(self, ds = None, value = None): # if possible return the cached values |