diff options
author | pmoravec <pmoravec@redhat.com> | 2019-08-26 17:06:54 +0200 |
---|---|---|
committer | pmoravec <pmoravec@redhat.com> | 2019-08-26 17:06:54 +0200 |
commit | e1d54dd9076c91977ecb84298868c0b02f5f5f81 (patch) | |
tree | 856c62df6214000dd31df2232ab8c3784b14b388 | |
parent | ecc1f757343b936cc6ba5f088d76a3c28dfc05a3 (diff) | |
download | sos-e1d54dd9076c91977ecb84298868c0b02f5f5f81.tar.gz |
[policies/amazon] Handle missing /etc/os-release properly
Catch use cases when /etc/os-release is missing by returning
Amazon policy as disabled.
Resolves: #1763
Signed-off-by: pmoravec <pmoravec@redhat.com>
-rw-r--r-- | sos/policies/amazon.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/sos/policies/amazon.py b/sos/policies/amazon.py index e1bfe1df..ce60c5e3 100644 --- a/sos/policies/amazon.py +++ b/sos/policies/amazon.py @@ -12,6 +12,7 @@ from __future__ import print_function from sos.policies.redhat import RedHatPolicy, OS_RELEASE +import os class AmazonPolicy(RedHatPolicy): @@ -25,6 +26,9 @@ class AmazonPolicy(RedHatPolicy): @classmethod def check(cls): + if not os.path.exists(OS_RELEASE): + return False + with open(OS_RELEASE, 'r') as f: for line in f: if line.startswith('NAME'): |