From f7e3a2380f9bd1dc919102e41ea2a79c2dd62f51 Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Wed, 6 Sep 2023 10:51:26 +0100 Subject: [PATCH] [landscape] Add landscape-api command collection If the relevant environment variables are set, then we collect some useful information to debug landscape-server further Signed-off-by: Arif Ali Signed-off-by: Mark Cunningham --- sos/report/plugins/landscape.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/sos/report/plugins/landscape.py b/sos/report/plugins/landscape.py index 55e08a2010..1fd53ceb90 100644 --- a/sos/report/plugins/landscape.py +++ b/sos/report/plugins/landscape.py @@ -7,6 +7,7 @@ # See the LICENSE file in the source distribution for further information. from sos.report.plugins import Plugin, UbuntuPlugin +import os class Landscape(Plugin, UbuntuPlugin): @@ -19,6 +20,33 @@ class Landscape(Plugin, UbuntuPlugin): packages = ('landscape-client', 'landscape-server') def setup(self): + + vars_all = [p in os.environ for p in [ + 'LANDSCAPE_API_KEY', + 'LANDSCAPE_API_SECRET', + 'LANDSCAPE_API_URI', + ]] + + if not (all(vars_all)): + self.soslog.warning("Not all environment variables set. " + "Source the environment file for the user " + "intended to connect to the Landscape " + "environment so that the landscape-api " + "commands can be used.") + else: + self.add_cmd_output([ + "landscape-api get-distributions", + "landscape-api get-apt-sources", + "landscape-api get-repository-profiles", + "landscape-api get activites --limit 100", + ]) + self.add_cmd_output([ + "landscape-api --json get-distributions", + "landscape-api --json get-apt-sources", + "landscape-api --json get-repository-profiles", + "landscape-api --json get activites --limit 100", + ]) + self.add_copy_spec([ "/etc/default/landscape-client", "/etc/default/landscape-server",