PR feedback
This commit is contained in:
parent
645b45401d
commit
20b8c2fd93
|
@ -108,7 +108,7 @@ def send_plugin_notification(event_type, data, recipients, notification):
|
||||||
}
|
}
|
||||||
status = FAILURE_METRIC_STATUS
|
status = FAILURE_METRIC_STATUS
|
||||||
try:
|
try:
|
||||||
current_app.logger.debug(log_data)
|
current_app.logger.info(log_data)
|
||||||
notification.plugin.send(event_type, data, recipients, notification.options)
|
notification.plugin.send(event_type, data, recipients, notification.options)
|
||||||
status = SUCCESS_METRIC_STATUS
|
status = SUCCESS_METRIC_STATUS
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -453,5 +453,5 @@ class SNSNotificationPlugin(ExpirationNotificationPlugin):
|
||||||
f"{self.get_option('accountNumber', options)}:" \
|
f"{self.get_option('accountNumber', options)}:" \
|
||||||
f"{self.get_option('topicName', options)}"
|
f"{self.get_option('topicName', options)}"
|
||||||
|
|
||||||
current_app.logger.debug(f"Publishing {notification_type} notification to topic {topic_arn}")
|
current_app.logger.info(f"Publishing {notification_type} notification to topic {topic_arn}")
|
||||||
sns.publish(topic_arn, message, notification_type, region_name=self.get_option("region", options))
|
sns.publish(topic_arn, message, notification_type, region_name=self.get_option("region", options))
|
||||||
|
|
|
@ -32,6 +32,7 @@ def publish_single(sns_client, topic_arn, certificate, notification_type):
|
||||||
raise Exception(f"Failed to publish {notification_type} notification to SNS topic {topic_arn}. "
|
raise Exception(f"Failed to publish {notification_type} notification to SNS topic {topic_arn}. "
|
||||||
f"SNS response: {response_code} {response}")
|
f"SNS response: {response_code} {response}")
|
||||||
|
|
||||||
|
current_app.logger.info(f"AWS SNS message published to topic [{topic_arn}] with message ID {response['MessageId']}")
|
||||||
current_app.logger.debug(f"AWS SNS message published to topic [{topic_arn}]: [{response}]")
|
current_app.logger.debug(f"AWS SNS message published to topic [{topic_arn}]: [{response}]")
|
||||||
|
|
||||||
return response["MessageId"]
|
return response["MessageId"]
|
||||||
|
@ -47,7 +48,7 @@ def format_message(certificate, notification_type):
|
||||||
json_message = {
|
json_message = {
|
||||||
"notification_type": notification_type,
|
"notification_type": notification_type,
|
||||||
"certificate_name": certificate["name"],
|
"certificate_name": certificate["name"],
|
||||||
"expires": arrow.get(certificate["validityEnd"]).format("dddd, MMMM D, YYYY"),
|
"expires": arrow.get(certificate["validityEnd"]).format("YYYY-MM-ddTHH:mm:ss"), # 2047-12-T22:00:00
|
||||||
"endpoints_detected": len(certificate["endpoints"]),
|
"endpoints_detected": len(certificate["endpoints"]),
|
||||||
"details": create_certificate_url(certificate["name"])
|
"details": create_certificate_url(certificate["name"])
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ def test_format(certificate, endpoint):
|
||||||
expected_message = {
|
expected_message = {
|
||||||
"notification_type": "expiration",
|
"notification_type": "expiration",
|
||||||
"certificate_name": certificate["name"],
|
"certificate_name": certificate["name"],
|
||||||
"expires": arrow.get(certificate["validityEnd"]).format("dddd, MMMM D, YYYY"),
|
"expires": arrow.get(certificate["validityEnd"]).format("YYYY-MM-ddTHH:mm:ss"),
|
||||||
"endpoints_detected": 0,
|
"endpoints_detected": 0,
|
||||||
"details": "https://lemur.example.com/#/certificates/{name}".format(name=certificate["name"])
|
"details": "https://lemur.example.com/#/certificates/{name}".format(name=certificate["name"])
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue