aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2018-09-08 17:45:09 +0200
committerBryn M. Reeves <bmr@redhat.com>2018-12-14 11:18:29 +0000
commit036bbd0fa4c85f97da536717673ca0b668dd5276 (patch)
treede5b39cff72557f38880644378f78e63cc47b523
parent18ae45219c9aa5ed2340a21e9f0aacad62d69242 (diff)
downloadsos-036bbd0fa4c85f97da536717673ca0b668dd5276.tar.gz
[juju] catch exceptions when "juju status" command fails
Catch exceptions when "juju status" command: - does not exist (and generates empty output), or - does not generate valid/expected JSON output Resolves: #1422 Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
-rw-r--r--sos/plugins/juju.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/sos/plugins/juju.py b/sos/plugins/juju.py
index cbd4a17b..8d996041 100644
--- a/sos/plugins/juju.py
+++ b/sos/plugins/juju.py
@@ -51,7 +51,12 @@ class Juju(Plugin, UbuntuPlugin):
cmd = "juju status --format json"
status_json = self.call_ext_prog(cmd)['output']
self.add_string_as_file(status_json, "juju_status_json")
- return json_loads(status_json)['services'].keys()
+ # if status_json isn't in JSON format (i.e. 'juju' command not found),
+ # or if it does not contain 'services' key, return empty list
+ try:
+ return json_loads(status_json)['services'].keys()
+ except ValueError:
+ return []
@ensure_service_is_running("juju-db")
def export_mongodb(self):