Blob Blame History Raw
From 9135d767e6244d370d8cbd59a75e1a56b928d4a3 Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Wed, 12 Dec 2018 10:36:09 +0000
Subject: [PATCH] [composer] avoid running 'blueprints list' twice

Use get_cmd_output_now() to store the first call to composer-cli's
'blueprints list' command in the report, and then use that file to
find the list of available blueprints.

Related: #1447

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

diff --git a/sos/plugins/composer.py b/sos/plugins/composer.py
index 34901bcee..ff3aa49bf 100644
--- a/sos/plugins/composer.py
+++ b/sos/plugins/composer.py
@@ -12,11 +12,11 @@ class Composer(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
 
     def _get_blueprints(self):
         blueprints = []
-        bp_result = self.get_command_output("composer-cli blueprints list")
-        if bp_result['status'] != 0:
-            return blueprints
-        for line in bp_result['output'].splitlines():
-            blueprints.append(line)
+        bp_file = self.get_cmd_output_now("composer-cli blueprints list")
+        if bp_file:
+            with open(bp_file, "r") as bps:
+                for line in bps.read().splitlines():
+                    blueprints.append(line)
         return blueprints
 
     def setup(self):
@@ -31,9 +31,6 @@ def setup(self):
         for blueprint in blueprints:
             self.add_cmd_output("composer-cli blueprints show %s" % blueprint)
 
-        self.add_cmd_output([
-            "composer-cli blueprints list",
-            "composer-cli sources list"
-        ])
+        self.add_cmd_output("composer-cli sources list")
 
 # vim: set et ts=4 sw=4 :
From e456ae4f23e49c36d5efe6b0584c5ec29be21ba5 Mon Sep 17 00:00:00 2001
From: Jake Hunsaker <jhunsake@redhat.com>
Date: Mon, 18 Feb 2019 12:32:11 -0500
Subject: [PATCH] [composer] Collect sources info for all sources

Adds collection of info on each source found by composer-cli. The
_get_blueprints() method has been made more generic to accomodate both
blueprints and sources.

Resolves: #1571

Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
 sos/plugins/composer.py | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/sos/plugins/composer.py b/sos/plugins/composer.py
index 0f926398b..e4f30f5f0 100644
--- a/sos/plugins/composer.py
+++ b/sos/plugins/composer.py
@@ -10,14 +10,14 @@ class Composer(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
 
     packages = ('composer-cli',)
 
-    def _get_blueprints(self):
-        blueprints = []
-        bp_file = self.get_cmd_output_now("composer-cli blueprints list")
-        if bp_file:
-            with open(bp_file, "r") as bps:
-                for line in bps.read().splitlines():
-                    blueprints.append(line)
-        return blueprints
+    def _get_entries(self, cmd):
+        entries = []
+        ent_file = self.get_cmd_output_now(cmd)
+        if ent_file:
+            with open(ent_file, "r") as ents:
+                for line in ents.read().splitlines():
+                    entries.append(line)
+        return entries
 
     def setup(self):
         self.add_copy_spec([
@@ -27,10 +27,12 @@ def setup(self):
             "/var/log/lorax-composer/program.log",
             "/var/log/lorax-composer/server.log",
         ])
-        blueprints = self._get_blueprints()
+        blueprints = self._get_entries("composer-cli blueprints list")
         for blueprint in blueprints:
             self.add_cmd_output("composer-cli blueprints show %s" % blueprint)
 
-        self.add_cmd_output("composer-cli sources list")
+        sources = self._get_entries("composer-cli sources list")
+        for src in sources:
+            self.add_cmd_output("composer-cli sources info %s" % src)
 
 # vim: set et ts=4 sw=4 :