Ticket #2622 If we get an error from dogtag we always did raise a CertificateOperationError exception with a message describing the problem. Unfortuanately that error message did not go into the log, just sent back to the caller. The fix is to format the error message and send the same message to both the log and use it to initialize the CertificateOperationError exception.
-- John Dennis <jden...@redhat.com> Looking to carve out IT costs? www.redhat.com/carveoutcosts/
From 9a8bfc30e044c837724160b7b6bb863a7d0d3e33 Mon Sep 17 00:00:00 2001 From: John Dennis <jden...@redhat.com> Date: Fri, 20 Apr 2012 13:56:25 -0400 Subject: [PATCH 75] log dogtag errors Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Ticket #2622 If we get an error from dogtag we always did raise a CertificateOperationError exception with a message describing the problem. Unfortuanately that error message did not go into the log, just sent back to the caller. The fix is to format the error message and send the same message to both the log and use it to initialize the CertificateOperationError exception. --- ipaserver/plugins/dogtag.py | 55 +++++++++++++++++++++++++++--------------- 1 files changed, 35 insertions(+), 20 deletions(-) diff --git a/ipaserver/plugins/dogtag.py b/ipaserver/plugins/dogtag.py index b56e04f..8ea5323 100644 --- a/ipaserver/plugins/dogtag.py +++ b/ipaserver/plugins/dogtag.py @@ -1372,14 +1372,17 @@ class ra(rabase.rabase): # Parse and handle errors if (http_status != 200): - raise CertificateOperationError(error=_('Unable to communicate with CMS (%s)') % \ - http_reason_phrase) + err_msg = _('Unable to communicate with CMS (%s)') % http_reason_phrase + self.error('%s.check_request_status(): %s', self.fullname, err_msg) + raise CertificateOperationError(error=err_msg) parse_result = self.get_parse_result_xml(http_body, parse_check_request_result_xml) request_status = parse_result['request_status'] if request_status != CMS_STATUS_SUCCESS: - raise CertificateOperationError(error='%s (%s)' % \ - (cms_request_status_to_string(request_status), parse_result.get('error_string'))) + err_msg = '%s (%s)' % \ + (cms_request_status_to_string(request_status), parse_result.get('error_string')) + self.error('%s.check_request_status(): %s', self.fullname, err_msg) + raise CertificateOperationError(error=err_msg) # Return command result cmd_result = {} @@ -1457,14 +1460,17 @@ class ra(rabase.rabase): # Parse and handle errors if (http_status != 200): - raise CertificateOperationError(error=_('Unable to communicate with CMS (%s)') % \ - http_reason_phrase) + err_msg = _('Unable to communicate with CMS (%s)') % http_reason_phrase + self.error('%s.get_certificate(): %s', self.fullname, err_msg) + raise CertificateOperationError(error=err_msg) parse_result = self.get_parse_result_xml(http_body, parse_display_cert_xml) request_status = parse_result['request_status'] if request_status != CMS_STATUS_SUCCESS: - raise CertificateOperationError(error='%s (%s)' % \ - (cms_request_status_to_string(request_status), parse_result.get('error_string'))) + err_msg = '%s (%s)' % \ + (cms_request_status_to_string(request_status), parse_result.get('error_string')) + self.error('%s.get_certificate(): %s', self.fullname, err_msg) + raise CertificateOperationError(error=err_msg) # Return command result cmd_result = {} @@ -1523,15 +1529,18 @@ class ra(rabase.rabase): xml='true') # Parse and handle errors if (http_status != 200): - raise CertificateOperationError(error=_('Unable to communicate with CMS (%s)') % \ - http_reason_phrase) + err_msg = _('Unable to communicate with CMS (%s)') % http_reason_phrase + self.error('%s.request_certificate(): %s', self.fullname, err_msg) + raise CertificateOperationError(error=err_msg) parse_result = self.get_parse_result_xml(http_body, parse_profile_submit_result_xml) # Note different status return, it's not request_status, it's error_code error_code = parse_result['error_code'] if error_code != CMS_SUCCESS: - raise CertificateOperationError(error='%s (%s)' % \ - (cms_error_code_to_string(error_code), parse_result.get('error_string'))) + err_msg = '%s (%s)' % \ + (cms_error_code_to_string(error_code), parse_result.get('error_string')) + self.error('%s.request_certificate(): %s', self.fullname, err_msg) + raise CertificateOperationError(error=err_msg) # Return command result cmd_result = {} @@ -1602,14 +1611,17 @@ class ra(rabase.rabase): # Parse and handle errors if (http_status != 200): - raise CertificateOperationError(error=_('Unable to communicate with CMS (%s)') % \ - http_reason_phrase) + err_msg = _('Unable to communicate with CMS (%s)') % http_reason_phrase + self.error('%s.revoke_certificate(): %s', self.fullname, err_msg) + raise CertificateOperationError(error=err_msg) parse_result = self.get_parse_result_xml(http_body, parse_revoke_cert_xml) request_status = parse_result['request_status'] if request_status != CMS_STATUS_SUCCESS: - raise CertificateOperationError(error='%s (%s)' % \ - (cms_request_status_to_string(request_status), parse_result.get('error_string'))) + err_msg = '%s (%s)' % \ + (cms_request_status_to_string(request_status), parse_result.get('error_string')) + self.error('%s.revoke_certificate(): %s', self.fullname, err_msg) + raise CertificateOperationError(error=err_msg) # Return command result cmd_result = {} @@ -1661,14 +1673,17 @@ class ra(rabase.rabase): # Parse and handle errors if (http_status != 200): - raise CertificateOperationError(error=_('Unable to communicate with CMS (%s)') % \ - http_reason_phrase) + err_msg = _('Unable to communicate with CMS (%s)') % http_reason_phrase + self.error('%s.take_certificate_off_hold(): %s', self.fullname, err_msg) + raise CertificateOperationError(error=err_msg) parse_result = self.get_parse_result_xml(http_body, parse_unrevoke_cert_xml) request_status = parse_result['request_status'] if request_status != CMS_STATUS_SUCCESS: - raise CertificateOperationError(error='%s (%s)' % \ - (cms_request_status_to_string(request_status), parse_result.get('error_string'))) + err_msg = '%s (%s)' % \ + (cms_request_status_to_string(request_status), parse_result.get('error_string')) + self.error('%s.take_certificate_off_hold(): %s', self.fullname, err_msg) + raise CertificateOperationError(error=err_msg) # Return command result cmd_result = {} -- 1.7.7.6
_______________________________________________ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel