diff options
author | Endi S. Dewata <edewata@redhat.com> | 2016-08-08 19:19:16 +0200 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2016-08-08 21:48:14 +0200 |
commit | a808013629d4b4de886ec1563daebf6ea5138f0c (patch) | |
tree | 40154b474e1439630c433bb7497d18a1f97aef85 | |
parent | a38b8b875e40d0d8551752af7aa2567d2891384a (diff) | |
download | pki-a808013629d4b4de886ec1563daebf6ea5138f0c.tar.gz pki-a808013629d4b4de886ec1563daebf6ea5138f0c.tar.xz pki-a808013629d4b4de886ec1563daebf6ea5138f0c.zip |
Improved SystemConfigService.configure() error message.
The pkispawn has been modified to improve the way it displays the
error message returned by SystemConfigService.configure(). If the
method throws a PKIException, the response is returned as a JSON
message, so pkispawn will parse it and display the actual error
message. For other exceptions pkispawn will display the entire
HTML message returned by Tomcat.
https://fedorahosted.org/pki/ticket/2399
-rw-r--r-- | base/server/python/pki/server/deployment/pkihelper.py | 23 | ||||
-rwxr-xr-x | base/server/sbin/pkispawn | 20 |
2 files changed, 19 insertions, 24 deletions
diff --git a/base/server/python/pki/server/deployment/pkihelper.py b/base/server/python/pki/server/deployment/pkihelper.py index 8a1dbddb5..b6eacf1ce 100644 --- a/base/server/python/pki/server/deployment/pkihelper.py +++ b/base/server/python/pki/server/deployment/pkihelper.py @@ -3959,28 +3959,7 @@ class ConfigClient: admin_cert = response['adminCert']['cert'] self.process_admin_cert(admin_cert) - except Exception as e: - config.pki_log.error( - log.PKI_CONFIG_JAVA_CONFIGURATION_EXCEPTION + " " + str(e), - extra=config.PKI_INDENTATION_LEVEL_2) - - if hasattr(e, 'response'): - text = e.response.text # pylint: disable=E1101 - try: - root = ET.fromstring(text) - except ET.ParseError as pe: - config.pki_log.error( - "ParseError: %s: %s " % (pe, text), - extra=config.PKI_INDENTATION_LEVEL_2) - raise - - if root.tag == 'PKIException': - message = root.findall('.//Message')[0].text - if message is not None: - config.pki_log.error( - log.PKI_CONFIG_JAVA_CONFIGURATION_EXCEPTION + " " + - message, - extra=config.PKI_INDENTATION_LEVEL_2) + except: raise diff --git a/base/server/sbin/pkispawn b/base/server/sbin/pkispawn index 13139fa23..c87c49a3d 100755 --- a/base/server/sbin/pkispawn +++ b/base/server/sbin/pkispawn @@ -527,8 +527,24 @@ def main(argv): scriptlet.spawn(deployer) - # pylint: disable=W0703 - except Exception as e: + except requests.HTTPError as e: + r = e.response + print() + + print('Installation failed:') + if r.headers['content-type'] == 'application/json': + data = r.json() + print('%s: %s' % (data['ClassName'], data['Message'])) + else: + print(r.text) + + print() + print('Please check the %s logs in %s.' % + (config.pki_subsystem, deployer.mdict['pki_subsystem_log_path'])) + + sys.exit(1) + + except Exception as e: # pylint: disable=broad-except log_error_details() print() print("Installation failed: %s" % e) |