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

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