aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2013-03-25 05:06:13 -0700
committerBryn M. Reeves <bmr@redhat.com>2013-03-25 05:06:13 -0700
commit183d503016c44981ebe6090f07f73fbea7b1b019 (patch)
treef20f6d7c0d860f402cc09645cf022e40bbaaaee9
parentfd69211e321b33a84855a38b305a4d7125fbc53b (diff)
parent9b64bea8fa7f169af4ee31bb99052a190c6dc0ec (diff)
downloadsos-183d503016c44981ebe6090f07f73fbea7b1b019.tar.gz
Merge pull request #102 from sosreport/bmr-template-text-fixes
Fix UI text templating
-rw-r--r--sos/policies/__init__.py40
-rw-r--r--sos/policies/debian.py13
-rw-r--r--sos/policies/redhat.py79
-rw-r--r--sos/policies/ubuntu.py7
-rw-r--r--sos/sosreport.py1
5 files changed, 111 insertions, 29 deletions
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py
index 4a4623aa..1cea2970 100644
--- a/sos/policies/__init__.py
+++ b/sos/policies/__init__.py
@@ -13,6 +13,7 @@ from sos.utilities import ImporterHelper, \
from sos.plugins import IndependentPlugin
from sos import _sos as _
import hashlib
+from textwrap import fill
def import_policy(name):
policy_fqname = "sos.policies.%s" % name
@@ -111,19 +112,27 @@ class PackageManager(object):
class Policy(object):
- msg = _("""This utility will collect some detailed information about the
-hardware and setup of your %(distro)s system.
-The information is collected and an archive is packaged under
-/tmp, which you can send to a support representative.
-%(distro)s will use this information for diagnostic purposes ONLY
-and it will be considered confidential information.
+ msg = _("""\
+This command will collect system configuration and diagnostic information \
+from this %(distro)s system. An archive containing the collected information \
+will be generated in %(tmpdir)s.
-This process may take a while to complete.
-No changes will be made to your system.
+For more information on %(vendor)s visit:
+ %(vendor_url)s
+
+The generated archive may contain data considered sensitive and its content \
+should be reviewed by the originating organization before being passed to \
+any third party.
+
+No changes will be made to system configuration.
+%(vendor_text)s
""")
- distro = ""
+ distro = "Unknown"
+ vendor = "Unknown"
+ vendor_url = "http://www.example.com/"
+ vendor_text = ""
def __init__(self):
"""Subclasses that choose to override this initializer should call
@@ -343,7 +352,15 @@ No changes will be made to your system.
the user in non-batch mode. If your policy sets self.distro that
text will be substituted accordingly. You can also override this
method to do something more complicated."""
- return self.msg % {'distro': self.distro}
+ width = 60
+ _msg = self.msg % {'distro': self.distro, 'vendor': self.vendor,
+ 'vendor_url': self.vendor_url,
+ 'vendor_text': self.vendor_text,
+ 'tmpdir': self.commons['tmpdir']}
+ _fmt = ""
+ for line in _msg.splitlines():
+ _fmt = _fmt + fill(line, width, replace_whitespace = False) + '\n'
+ return _fmt
class GenericPolicy(Policy):
@@ -358,6 +375,9 @@ class LinuxPolicy(Policy):
"""This policy is meant to be an abc class that provides common implementations used
in Linux distros"""
+ distro = "Linux"
+ vendor = "None"
+
def __init__(self):
super(LinuxPolicy, self).__init__()
diff --git a/sos/policies/debian.py b/sos/policies/debian.py
index 5b7f2af2..98526e3a 100644
--- a/sos/policies/debian.py
+++ b/sos/policies/debian.py
@@ -4,13 +4,16 @@ from sos.policies import PackageManager, LinuxPolicy
import os
class DebianPolicy(LinuxPolicy):
+ distro = "Debian"
+ vendor = "the Debian project"
+ vendor_url = "http://www.debian.org/"
+ reportName = ""
+ ticketNumber = ""
+ package_manager = PackageManager("dpkg-query -W -f='${Package}|${Version}\\n' \*")
+ valid_subclasses = [DebianPlugin]
+
def __init__(self):
super(DebianPolicy, self).__init__()
- self.reportName = ""
- self.ticketNumber = ""
- self.package_manager = PackageManager("dpkg-query -W -f='${Package}|${Version}\\n' \*")
- self.valid_subclasses = [DebianPlugin]
- self.distro = "Debian"
@classmethod
def check(self):
diff --git a/sos/policies/redhat.py b/sos/policies/redhat.py
index c17e4420..399db6f7 100644
--- a/sos/policies/redhat.py
+++ b/sos/policies/redhat.py
@@ -20,6 +20,7 @@ import sys
from sos.plugins import RedHatPlugin
from sos.policies import LinuxPolicy, PackageManager
+from sos import _sos as _
sys.path.insert(0, "/usr/share/rhn/")
try:
@@ -30,11 +31,13 @@ except:
# might fail if non-RHEL
pass
-
-class RHELPolicy(LinuxPolicy):
+class RedHatPolicy(LinuxPolicy):
+ distro = "Red Hat"
+ vendor = "Red Hat"
+ vendor_url = "http://www.redhat.com/"
def __init__(self):
- super(RHELPolicy, self).__init__()
+ super(RedHatPolicy, self).__init__()
self.reportName = ""
self.ticketNumber = ""
self.package_manager = PackageManager('rpm -qa --queryformat "%{NAME}|%{VERSION}\\n"')
@@ -42,10 +45,10 @@ class RHELPolicy(LinuxPolicy):
@classmethod
def check(self):
- """This method checks to see if we are running on RHEL. It returns True
- or False."""
- return (os.path.isfile('/etc/redhat-release')
- or os.path.isfile('/etc/fedora-release'))
+ """This method checks to see if we are running on Red Hat. It must be overriden
+ by concrete subclasses to return True when running on a Fedora, RHEL or other
+ Red Hat distribution or False otherwise."""
+ return False
def runlevelByService(self, name):
from subprocess import Popen, PIPE
@@ -68,6 +71,44 @@ class RHELPolicy(LinuxPolicy):
ret.append(int(runlevel))
return ret
+ def getLocalName(self):
+ return self.hostName()
+
+class RHELPolicy(RedHatPolicy):
+
+ msg = _("""\
+This command will collect system configuration and diagnostic information \
+from this %(distro)s system. An archive containing the collected information \
+will be generated in %(tmpdir)s and may be provided to a %(vendor)s support \
+representative or used for local diagnostic or recording purposes.
+
+Any information provided to %(vendor)s will be treated in strict confidence \
+in accordance with the published support policies at:
+
+ %(vendor_url)s
+
+The generated archive may contain data considered sensitive and its content \
+should be reviewed by the originating organization before being passed to \
+any third party.
+
+No changes will be made to system configuration.
+%(vendor_text)s
+""")
+
+ distro = "Red Hat Enterprise Linux"
+ vendor = "Red Hat"
+ vendor_url = "https://access.redhat.com/support/"
+
+ def __init__(self):
+ super(RHELPolicy, self).__init__()
+
+ @classmethod
+ def check(self):
+ """This method checks to see if we are running on RHEL. It returns True
+ or False."""
+ return (os.path.isfile('/etc/redhat-release')
+ and not os.path.isfile('/etc/fedora-release'))
+
def rhelVersion(self):
try:
pkg = self.pkgByName("redhat-release") or \
@@ -95,10 +136,24 @@ class RHELPolicy(LinuxPolicy):
def getLocalName(self):
return self.rhnUsername() or self.hostName()
- def get_msg(self):
- msg_dict = {"distro": "Red Hat Enterprise Linux"}
- if os.path.isfile('/etc/fedora-release'):
- msg_dict['distro'] = 'Fedora'
- return self.msg % msg_dict
+class FedoraPolicy(RedHatPolicy):
+
+ distro = "Fedora"
+ vendor = "the Fedora Project"
+ vendor_url = "https://fedoraproject.org/"
+
+ def __init__(self):
+ super(FedoraPolicy, self).__init__()
+
+ @classmethod
+ def check(self):
+ """This method checks to see if we are running on Fedora. It returns True
+ or False."""
+ return os.path.isfile('/etc/fedora-release')
+
+ def fedoraVersion(self):
+ pkg = self.pkgByName("fedora-release") or \
+ self.allPkgsByNameRegex("fedora-release-.*")[-1]
+ return int(pkg["version"])
# vim: ts=4 sw=4 et
diff --git a/sos/policies/ubuntu.py b/sos/policies/ubuntu.py
index a5eea4da..97f2d14a 100644
--- a/sos/policies/ubuntu.py
+++ b/sos/policies/ubuntu.py
@@ -6,10 +6,13 @@ from sos.plugins import UbuntuPlugin, IndependentPlugin
from sos.policies.debian import DebianPolicy
class UbuntuPolicy(DebianPolicy):
+ distro = "Ubuntu"
+ vendor = "Ubuntu"
+ vendor_url = "http://www.ubuntu.com/"
+ valid_subclasses = [UbuntuPlugin]
+
def __init__(self):
super(UbuntuPolicy, self).__init__()
- self.distro = "Ubuntu"
- self.valid_subclasses = [UbuntuPlugin]
@classmethod
def check(self):
diff --git a/sos/sosreport.py b/sos/sosreport.py
index ec943988..ef49a09c 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -228,6 +228,7 @@ class SoSReport(object):
'cmddir': self.cmddir,
'logdir': self.logdir,
'rptdir': self.rptdir,
+ 'tmpdir': self.opts.tmp_dir,
'soslog': self.soslog,
'proflog' : self.proflog,
'policy': self.policy,