From 99398ea80140bda152a397a3e6317eab9923751d Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Tue, 27 Jan 2015 13:53:34 -0500 Subject: [PATCH 89/93] [policies/redhat] add Red Hat Atomic Host policy Add a new policy for the Red Hat Atomic Host. Signed-off-by: Bryn M. Reeves --- sos/policies/redhat.py | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/sos/policies/redhat.py b/sos/policies/redhat.py index c057e6e..b982431 100644 --- a/sos/policies/redhat.py +++ b/sos/policies/redhat.py @@ -36,6 +36,7 @@ class RedHatPolicy(LinuxPolicy): distro = "Red Hat" vendor = "Red Hat" vendor_url = "http://www.redhat.com/" + _redhat_release = '/etc/redhat-release' _tmp_dir = "/var/tmp" _rpmq_cmd = 'rpm -qa --queryformat "%{NAME}|%{VERSION}\\n"' _in_container = False @@ -151,7 +152,7 @@ No changes will be made to system configuration. 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') + return (os.path.isfile(self._redhat_release) and not os.path.isfile('/etc/fedora-release')) def dist_version(self): @@ -185,6 +186,42 @@ No changes will be made to system configuration. return self.rhn_username() or self.host_name() +class RedHatAtomicPolicy(RHELPolicy): + distro = "Red Hat Atomic Host" + msg = _("""\ +This command will collect diagnostic and configuration \ +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. + +Any information provided to %(vendor)s will be treated in \ +accordance with the published support policies at:\n + %(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. +%(vendor_text)s +""") + + @classmethod + def check(self): + atomic = False + if ENV_HOST_SYSROOT not in os.environ: + return atomic + host_release = os.environ[ENV_HOST_SYSROOT] + self._redhat_release + if not os.path.exists(host_release): + return False + try: + for line in open(host_release, "r").read().splitlines(): + atomic |= 'Atomic' in line + except: + pass + return atomic + + class FedoraPolicy(RedHatPolicy): distro = "Fedora" -- 1.9.3