diff options
author | Pavel Moravec <pmoravec@redhat.com> | 2017-12-05 12:44:42 +0100 |
---|---|---|
committer | Pavel Moravec <pmoravec@redhat.com> | 2017-12-05 12:44:42 +0100 |
commit | ae56ea578fe6f7443d2dce73e2b8fcf2bd5542d1 (patch) | |
tree | 353f274886f181ab68b3252866aaa46de8027843 | |
parent | c4866ffa89e3ea007a0c8556aaebd319ca346764 (diff) | |
download | sos-ae56ea578fe6f7443d2dce73e2b8fcf2bd5542d1.tar.gz |
[etcd] dont traceback when etcd package isnt installed
catch exception when etcd package isnt installed and we inspect its
version
Resolves: #1159
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
-rw-r--r-- | sos/plugins/etcd.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/sos/plugins/etcd.py b/sos/plugins/etcd.py index bd5d10d8..d80bbeeb 100644 --- a/sos/plugins/etcd.py +++ b/sos/plugins/etcd.py @@ -61,11 +61,16 @@ class etcd(Plugin, RedHatPlugin): return line.split('=')[1].replace('"', '').strip() # If we can't read etcd.conf, assume defaults by etcd version except: - ver = self.policy().package_manager.get_pkg_list()['etcd'] - ver = ver['version'][0] - if ver == '2': - return 'http://localhost:4001' - if ver == '3': - return 'http://localhost:2379' + # assume v3 is the default + url = 'http://localhost:2379' + try: + ver = self.policy().package_manager.get_pkg_list()['etcd'] + ver = ver['version'][0] + if ver == '2': + url = 'http://localhost:4001' + except: + # fallback when etcd is not installed + pass + return url # vim: et ts=5 sw=4 |