Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[landscape] Add landscape-api command collection #3354

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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