Blob Blame History Raw
From ff2820775597e6fc47bada2ce57b01f8cfd81af6 Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Wed, 13 Jul 2016 12:45:36 +0100
Subject: [PATCH 1/3] [atomichost] fix option list style

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
 sos/plugins/atomichost.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sos/plugins/atomichost.py b/sos/plugins/atomichost.py
index 46d12e3..ce30ac7 100644
--- a/sos/plugins/atomichost.py
+++ b/sos/plugins/atomichost.py
@@ -22,8 +22,9 @@ class AtomicHost(Plugin, RedHatPlugin):
     """ Atomic Host """
 
     plugin_name = "atomichost"
-    option_list = [("info", "gather atomic info for each image",
-                    "fast", False)]
+    option_list = [
+        ("info", "gather atomic info for each image", "fast", False)
+    ]
 
     def check_enabled(self):
         if not os.path.exists("/host/etc/system-release-cpe"):
-- 
2.4.11

From 46da5439bb79f294dca8019293eecf3096e5b999 Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Wed, 13 Jul 2016 12:47:06 +0100
Subject: [PATCH 2/3] [atomichost] replace custom logic with
 Policy.in_container()

Don't reinvent the wheel by inspecting file system paths: rely on
the existing policy class in_container() method.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
 sos/plugins/atomichost.py | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/sos/plugins/atomichost.py b/sos/plugins/atomichost.py
index ce30ac7..a339557 100644
--- a/sos/plugins/atomichost.py
+++ b/sos/plugins/atomichost.py
@@ -27,10 +27,7 @@ class AtomicHost(Plugin, RedHatPlugin):
     ]
 
     def check_enabled(self):
-        if not os.path.exists("/host/etc/system-release-cpe"):
-            return False
-        cpe = open("/host/etc/system-release-cpe", "r").readlines()
-        return ':atomic-host' in cpe[0]
+        return self.policy().in_container()
 
     def setup(self):
         self.add_copy_spec("/etc/ostree/remotes.d")
-- 
2.4.11

From e2d85366ef5b6f02e12e0ce353a0ccaa22ae8bbc Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Wed, 13 Jul 2016 15:13:35 +0100
Subject: [PATCH 3/3] [atomichost] improve 'atomic info' collection loop

Remove redundant code from the loop that drives 'atomic info'
collection and make the bracketing and indenting style match
other plugins.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
 sos/plugins/atomichost.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/sos/plugins/atomichost.py b/sos/plugins/atomichost.py
index a339557..9b53d56 100644
--- a/sos/plugins/atomichost.py
+++ b/sos/plugins/atomichost.py
@@ -34,8 +34,9 @@ class AtomicHost(Plugin, RedHatPlugin):
         self.add_cmd_output("atomic host status")
 
         if self.get_option('info'):
-            images = self.get_command_output("docker images -q")
-            for image in set(
-                    images['output'].splitlines()):
-                if image:
-                    self.add_cmd_output("atomic info {0}".format(image))
+            # images output may have trailing whitespace
+            images = self.get_command_output("docker images -q").strip()
+            for image in set(images['output'].splitlines()):
+                self.add_cmd_output("atomic info {0}".format(image))
+
+# vim: set et ts=4 sw=4 :
-- 
2.4.11

From b5e0e80ad784054fd2f4cdb8c6867982c0dd1c25 Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Fri, 19 Aug 2016 15:33:34 +0100
Subject: [PATCH] [atomichost] fix collection of 'docker info' output

The loop that drives collection of 'docker info' output for each
discovered Image ID incorrectly attempted to call strip() on the
dictionary returned by get_command_output().

Since the docker command does not produce leading or trailing
whitespace this is redundant anyway: discard the other entries
in the command dictionary and just split the result into distinct
lines.

Resolves: #853.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
 sos/plugins/atomichost.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/sos/plugins/atomichost.py b/sos/plugins/atomichost.py
index 9b53d56..7091a45 100644
--- a/sos/plugins/atomichost.py
+++ b/sos/plugins/atomichost.py
@@ -34,9 +34,12 @@ class AtomicHost(Plugin, RedHatPlugin):
         self.add_cmd_output("atomic host status")
 
         if self.get_option('info'):
-            # images output may have trailing whitespace
-            images = self.get_command_output("docker images -q").strip()
-            for image in set(images['output'].splitlines()):
+            # The 'docker images' command may include duplicate rows of
+            # output (repeated "IMAGE ID" values). Use a set to filter
+            # these out and only obtain 'docker info' data once per image
+            # identifier.
+            images = self.get_command_output("docker images -q")['output']
+            for image in set(images.splitlines()):
                 self.add_cmd_output("atomic info {0}".format(image))
 
 # vim: set et ts=4 sw=4 :
-- 
2.4.11