From 10242cd6c4fd4904e2db2084eb9445827bec716b Mon Sep 17 00:00:00 2001 From: "Christian M. Adams" Date: Thu, 22 Oct 2020 12:28:48 -0400 Subject: [PATCH] Add error handling for missing rhsm.conf --- awx/main/utils/licensing.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/awx/main/utils/licensing.py b/awx/main/utils/licensing.py index 08bddcf02d..a37861f018 100644 --- a/awx/main/utils/licensing.py +++ b/awx/main/utils/licensing.py @@ -42,8 +42,9 @@ logger = logging.getLogger(__name__) def rhsm_config(): + path = '/etc/rhsm/rhsm.conf' config = configparser.ConfigParser() - config.read('/etc/rhsm/rhsm.conf') + config.read(path) return config @@ -150,7 +151,10 @@ class Licenser(object): def validate_rh(self, user, pw): - host = 'https://' + str(self.config.get("server", "hostname")) + try: + host = 'https://' + str(self.config.get("server", "hostname")) + except: + raise OSError('Cannot access rhsm.conf, make sure subscription manager is installed and configured.') if not host: host = getattr(settings, 'REDHAT_CANDLEPIN_HOST', None)