aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArif Ali <arif.ali@canonical.com>2023-09-06 10:51:26 +0100
committerJake Hunsaker <jacob.r.hunsaker@gmail.com>2023-09-12 08:56:44 -0400
commit0b1d919ea1fd4c3e7e66218f5269ea4cf920c2fe (patch)
tree53d3256f533d7b4b97cb6104eff156c889b995b0
parent78edc1e59664b70988c86b051a20d7e603e32ec5 (diff)
downloadsos-0b1d919ea1fd4c3e7e66218f5269ea4cf920c2fe.tar.gz
[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 <arif.ali@canonical.com> Signed-off-by: Mark Cunningham <mark.cunningham@canonical.com>
-rw-r--r--sos/report/plugins/landscape.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/sos/report/plugins/landscape.py b/sos/report/plugins/landscape.py
index 55e08a20..1fd53ceb 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",