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, then pkispawn will parse it and display the error message only. For other exceptions pkispawn will display the entire HTML message returned by Tomcat.
https://fedorahosted.org/pki/ticket/2399 -- Endi S. Dewata
>From 4ae1e846aa7e09281ecd48c3ba0943edf090dbe6 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" <[email protected]> Date: Mon, 8 Aug 2016 19:19:16 +0200 Subject: [PATCH] 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, then pkispawn will parse it and display the error message only. For other exceptions pkispawn will display the entire HTML message returned by Tomcat. https://fedorahosted.org/pki/ticket/2399 --- .../python/pki/server/deployment/pkihelper.py | 23 +--------------------- base/server/sbin/pkispawn | 17 ++++++++++++++-- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/base/server/python/pki/server/deployment/pkihelper.py b/base/server/python/pki/server/deployment/pkihelper.py index 8a1dbddb5615e81bfaa498615f4192e05fbc2b4a..b6eacf1cea121ede30795289d953baf496c5a22f 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 13139fa23fcae4b256e248fcd1b552448d4d039c..bebb2ed993f4a2aeca61f2be0ce47040600b3a64 100755 --- a/base/server/sbin/pkispawn +++ b/base/server/sbin/pkispawn @@ -527,8 +527,21 @@ 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(data['Message']) + else: + print(r.text) + + print() + sys.exit(1) + + except Exception as e: # pylint: disable=broad-except log_error_details() print() print("Installation failed: %s" % e) -- 2.5.5
_______________________________________________ Pki-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/pki-devel
