Blame SOURCES/sos-bz1669045-rhcos-policy-and-plugins.patch

03853b
From fa06bc09c95c52565e29173535c7422608e9a29b Mon Sep 17 00:00:00 2001
03853b
From: Jake Hunsaker <jhunsake@redhat.com>
03853b
Date: Fri, 4 Jan 2019 13:35:34 -0500
03853b
Subject: [PATCH 1/4] [redhat] Add RHCOS policy
03853b
03853b
Adds a policy for Red Hat CoreOS.
03853b
03853b
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
03853b
---
03853b
 sos/policies/redhat.py | 42 ++++++++++++++++++++++++++++++++++++++++++
03853b
 1 file changed, 42 insertions(+)
03853b
03853b
diff --git a/sos/policies/redhat.py b/sos/policies/redhat.py
03853b
index e1e417f3..ea80704f 100644
03853b
--- a/sos/policies/redhat.py
03853b
+++ b/sos/policies/redhat.py
03853b
@@ -379,6 +379,48 @@ organization before being passed to any third party.
03853b
         return self.find_preset(ATOMIC)
03853b
 
03853b
 
03853b
+class RedHatCoreOSPolicy(RHELPolicy):
03853b
+    distro = "Red Hat CoreOS"
03853b
+    msg = _("""\
03853b
+This command will collect diagnostic and configuration \
03853b
+information from this %(distro)s system.
03853b
+
03853b
+An archive containing the collected information will be \
03853b
+generated in %(tmpdir)s and may be provided to a %(vendor)s \
03853b
+support representative.
03853b
+
03853b
+Any information provided to %(vendor)s will be treated in \
03853b
+accordance with the published support policies at:\n
03853b
+  %(vendor_url)s
03853b
+
03853b
+The generated archive may contain data considered sensitive \
03853b
+and its content should be reviewed by the originating \
03853b
+organization before being passed to any third party.
03853b
+%(vendor_text)s
03853b
+""")
03853b
+
03853b
+    def __init__(self, sysroot=None):
03853b
+        super(RedHatCoreOSPolicy, self).__init__(sysroot=sysroot)
03853b
+
03853b
+    @classmethod
03853b
+    def check(cls):
03853b
+        coreos = False
03853b
+        if ENV_HOST_SYSROOT not in os.environ:
03853b
+            return coreos
03853b
+        host_release = os.environ[ENV_HOST_SYSROOT] + cls._redhat_release
03853b
+        try:
03853b
+            for line in open(host_release, 'r').read().splitlines():
03853b
+                coreos |= 'Red Hat CoreOS' in line
03853b
+        except IOError:
03853b
+            pass
03853b
+        return coreos
03853b
+
03853b
+    def probe_preset(self):
03853b
+        # As of the creation of this policy, RHCOS is only available for
03853b
+        # RH OCP environments.
03853b
+        return self.find_preset(RHOCP)
03853b
+
03853b
+
03853b
 class FedoraPolicy(RedHatPolicy):
03853b
 
03853b
     distro = "Fedora"
03853b
-- 
03853b
2.17.2
03853b
03853b
03853b
From 3335f265213d7457d17139ee172bf21f1a66c229 Mon Sep 17 00:00:00 2001
03853b
From: "Bryn M. Reeves" <bmr@redhat.com>
03853b
Date: Fri, 18 Jan 2019 18:03:21 +0000
03853b
Subject: [PATCH 2/4] [policies] factor out Red Hat disclaimer text
03853b
03853b
Rather than repeating the same boilerplate disclaimer text in each
03853b
Red Hat policy class, define it once as a string, and then cat it
03853b
into each policy that requires a distinct preamble.
03853b
03853b
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
03853b
---
03853b
 sos/policies/redhat.py | 48 ++++++++++++++----------------------------
03853b
 1 file changed, 16 insertions(+), 32 deletions(-)
03853b
03853b
diff --git a/sos/policies/redhat.py b/sos/policies/redhat.py
03853b
index ea80704f..1d1606b6 100644
03853b
--- a/sos/policies/redhat.py
03853b
+++ b/sos/policies/redhat.py
03853b
@@ -229,6 +229,19 @@ rhel_presets = {
03853b
                                  note=NOTE_TIME, opts=_opts_verify),
03853b
 }
03853b
 
03853b
+# Legal disclaimer text for Red Hat products
03853b
+disclaimer_text = """
03853b
+Any information provided to %(vendor)s will be treated in \
03853b
+accordance with the published support policies at:\n
03853b
+  %(vendor_url)s
03853b
+
03853b
+The generated archive may contain data considered sensitive \
03853b
+and its content should be reviewed by the originating \
03853b
+organization before being passed to any third party.
03853b
+
03853b
+No changes will be made to system configuration.
03853b
+"""
03853b
+
03853b
 
03853b
 class RHELPolicy(RedHatPolicy):
03853b
     distro = RHEL_RELEASE_STR
03853b
@@ -242,18 +255,7 @@ applications.
03853b
 An archive containing the collected information will be \
03853b
 generated in %(tmpdir)s and may be provided to a %(vendor)s \
03853b
 support representative.
03853b
-
03853b
-Any information provided to %(vendor)s will be treated in \
03853b
-accordance with the published support policies at:\n
03853b
-  %(vendor_url)s
03853b
-
03853b
-The generated archive may contain data considered sensitive \
03853b
-and its content should be reviewed by the originating \
03853b
-organization before being passed to any third party.
03853b
-
03853b
-No changes will be made to system configuration.
03853b
-%(vendor_text)s
03853b
-""")
03853b
+""" + disclaimer_text + "%(vendor_text)s\n")
03853b
 
03853b
     def __init__(self, sysroot=None):
03853b
         super(RHELPolicy, self).__init__(sysroot=sysroot)
03853b
@@ -342,16 +344,7 @@ information from this %(distro)s system.
03853b
 An archive containing the collected information will be \
03853b
 generated in %(tmpdir)s and may be provided to a %(vendor)s \
03853b
 support representative.
03853b
-
03853b
-Any information provided to %(vendor)s will be treated in \
03853b
-accordance with the published support policies at:\n
03853b
-  %(vendor_url)s
03853b
-
03853b
-The generated archive may contain data considered sensitive \
03853b
-and its content should be reviewed by the originating \
03853b
-organization before being passed to any third party.
03853b
-%(vendor_text)s
03853b
-""")
03853b
+""" + disclaimer_text + "%(vendor_text)s\n")
03853b
 
03853b
     def __init__(self, sysroot=None):
03853b
         super(RedHatAtomicPolicy, self).__init__(sysroot=sysroot)
03853b
@@ -388,16 +381,7 @@ information from this %(distro)s system.
03853b
 An archive containing the collected information will be \
03853b
 generated in %(tmpdir)s and may be provided to a %(vendor)s \
03853b
 support representative.
03853b
-
03853b
-Any information provided to %(vendor)s will be treated in \
03853b
-accordance with the published support policies at:\n
03853b
-  %(vendor_url)s
03853b
-
03853b
-The generated archive may contain data considered sensitive \
03853b
-and its content should be reviewed by the originating \
03853b
-organization before being passed to any third party.
03853b
-%(vendor_text)s
03853b
-""")
03853b
+""" + disclaimer_text + "%(vendor_text)s\n")
03853b
 
03853b
     def __init__(self, sysroot=None):
03853b
         super(RedHatCoreOSPolicy, self).__init__(sysroot=sysroot)
03853b
-- 
03853b
2.17.2
03853b
03853b
03853b
From ff9b64ffb383b5b57cbba6de665d2b7794849be7 Mon Sep 17 00:00:00 2001
03853b
From: Jake Hunsaker <jhunsake@redhat.com>
03853b
Date: Fri, 4 Jan 2019 14:43:05 -0500
03853b
Subject: [PATCH 3/4] [rhcos] Add new plugin
03853b
03853b
Adds a new plugin for Red Hat CoreOS
03853b
03853b
Resolves: #1528
03853b
03853b
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
03853b
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
03853b
---
03853b
 sos/plugins/rhcos.py | 30 ++++++++++++++++++++++++++++++
03853b
 1 file changed, 30 insertions(+)
03853b
 create mode 100644 sos/plugins/rhcos.py
03853b
03853b
diff --git a/sos/plugins/rhcos.py b/sos/plugins/rhcos.py
03853b
new file mode 100644
03853b
index 00000000..de9af9df
03853b
--- /dev/null
03853b
+++ b/sos/plugins/rhcos.py
03853b
@@ -0,0 +1,30 @@
03853b
+# Copyright (C) 2019 Red Hat, Inc., Jake Hunsaker <jhunsake@redhat.com>
03853b
+
03853b
+# This file is part of the sos project: https://github.com/sosreport/sos
03853b
+#
03853b
+# This copyrighted material is made available to anyone wishing to use,
03853b
+# modify, copy, or redistribute it subject to the terms and conditions of
03853b
+# version 2 of the GNU General Public License.
03853b
+#
03853b
+# See the LICENSE file in the source distribution for further information.
03853b
+
03853b
+from sos.plugins import Plugin, RedHatPlugin
03853b
+
03853b
+
03853b
+class RHCoreOS(Plugin, RedHatPlugin):
03853b
+    """Red Hat CoreOS"""
03853b
+
03853b
+    plugin_name = 'rhcos'
03853b
+    packages = ('redhat-release-coreos', 'coreos-metadata')
03853b
+
03853b
+    def setup(self):
03853b
+        units = ['coreos-growpart', 'coreos-firstboot-complete']
03853b
+        for unit in units:
03853b
+            self.add_journal(unit)
03853b
+
03853b
+        self.add_cmd_output(
03853b
+            'coreos-metadata --cmdline --attributes /dev/stdout',
03853b
+            timeout=60
03853b
+        )
03853b
+
03853b
+# vim: set et ts=4 sw=4 :
03853b
-- 
03853b
2.17.2
03853b
03853b
03853b
From 12f12d490866587b254cdf182585529714b7e5bc Mon Sep 17 00:00:00 2001
03853b
From: Jake Hunsaker <jhunsake@redhat.com>
03853b
Date: Fri, 4 Jan 2019 15:02:55 -0500
03853b
Subject: [PATCH 4/4] [rpmostree] Add new plugin
03853b
03853b
Adds a new plugin for rpm-ostree, which is no longer limited to use in
03853b
Atomic Host.
03853b
03853b
Resolves: #1529
03853b
03853b
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
03853b
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
03853b
---
03853b
 sos/plugins/atomichost.py |  1 -
03853b
 sos/plugins/rpmostree.py  | 40 +++++++++++++++++++++++++++++++++++++++
03853b
 2 files changed, 40 insertions(+), 1 deletion(-)
03853b
 create mode 100644 sos/plugins/rpmostree.py
03853b
03853b
diff --git a/sos/plugins/atomichost.py b/sos/plugins/atomichost.py
03853b
index deecba87..0c1f4026 100644
03853b
--- a/sos/plugins/atomichost.py
03853b
+++ b/sos/plugins/atomichost.py
03853b
@@ -25,7 +25,6 @@ class AtomicHost(Plugin, RedHatPlugin):
03853b
         return self.policy.in_container()
03853b
 
03853b
     def setup(self):
03853b
-        self.add_copy_spec("/etc/ostree/remotes.d")
03853b
         self.add_cmd_output("atomic host status")
03853b
 
03853b
         if self.get_option('info'):
03853b
diff --git a/sos/plugins/rpmostree.py b/sos/plugins/rpmostree.py
03853b
new file mode 100644
03853b
index 00000000..3c6872c2
03853b
--- /dev/null
03853b
+++ b/sos/plugins/rpmostree.py
03853b
@@ -0,0 +1,40 @@
03853b
+# Copyright (C) 2019 Red Hat, Inc., Jake Hunsaker <jhunsake@redhat.com>
03853b
+
03853b
+# This file is part of the sos project: https://github.com/sosreport/sos
03853b
+#
03853b
+# This copyrighted material is made available to anyone wishing to use,
03853b
+# modify, copy, or redistribute it subject to the terms and conditions of
03853b
+# version 2 of the GNU General Public License.
03853b
+#
03853b
+# See the LICENSE file in the source distribution for further information.
03853b
+
03853b
+from sos.plugins import Plugin, RedHatPlugin
03853b
+
03853b
+
03853b
+class Rpmostree(Plugin, RedHatPlugin):
03853b
+    """rpm-ostree image/package system"""
03853b
+
03853b
+    plugin_name = 'rpmostree'
03853b
+    packages = ('rpm-ostree',)
03853b
+
03853b
+    def setup(self):
03853b
+        self.add_copy_spec('/etc/ostree/remotes.d/')
03853b
+
03853b
+        subcmds = [
03853b
+            'status',
03853b
+            'db list',
03853b
+            'db diff',
03853b
+            '--version'
03853b
+        ]
03853b
+
03853b
+        self.add_cmd_output(["rpm-ostree %s" % subcmd for subcmd in subcmds])
03853b
+
03853b
+        units = [
03853b
+            'rpm-ostreed',
03853b
+            'rpm-ostreed-automatic',
03853b
+            'rpm-ostree-bootstatus'
03853b
+        ]
03853b
+        for unit in units:
03853b
+            self.add_journal(unit)
03853b
+
03853b
+# vim: set et ts=4 sw=4 :
03853b
-- 
03853b
2.17.2
03853b