Skip to content

Commit

Permalink
[landscape] Add landscape-api command collection
Browse files Browse the repository at this point in the history
If the relevant environment variables are set, then we collect some
useful information to debug landscape-server further

Signed-off-by: Arif Ali <[email protected]>
Signed-off-by: Mark Cunningham <[email protected]>
  • Loading branch information
arif-ali committed Sep 12, 2023
1 parent 7cd6f61 commit f7e3a23
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions sos/report/plugins/landscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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",
Expand Down

0 comments on commit f7e3a23

Please sign in to comment.