aboutsummaryrefslogtreecommitdiff
path: root/rpkid
diff options
context:
space:
mode:
Diffstat (limited to 'rpkid')
-rw-r--r--rpkid/rpki/gui/app/check_expired.py22
-rw-r--r--rpkid/rpki/gui/app/glue.py22
-rw-r--r--rpkid/rpki/gui/cacheview/util.py7
3 files changed, 11 insertions, 40 deletions
diff --git a/rpkid/rpki/gui/app/check_expired.py b/rpkid/rpki/gui/app/check_expired.py
index 418e031a..fcf5ecae 100644
--- a/rpkid/rpki/gui/app/check_expired.py
+++ b/rpkid/rpki/gui/app/check_expired.py
@@ -22,8 +22,8 @@ import logging
import datetime
from rpki.gui.cacheview.models import Cert
-from rpki.gui.app.models import Conf, ResourceCert, Timestamp
-from rpki.gui.app.glue import list_received_resources, get_email_list
+from rpki.gui.app.models import Conf, ResourceCert, Timestamp, Alert
+from rpki.gui.app.glue import list_received_resources
from rpki.irdb import Zookeeper
from rpki.left_right import report_error_elt, list_published_objects_elt
from rpki.x509 import X509
@@ -200,14 +200,10 @@ def notify_expired(expire_days=14, from_email=None):
if s:
logger.info(s)
- notify_emails = get_email_list(h)
-
- if notify_emails:
- t = """This is an automated notice about the upcoming expiration of RPKI resources for the handle %s on %s. You are receiving this notification because your email address is either registered in a Ghostbuster record, or as the default email address for the account.\n\n""" % (h.handle, host)
-
- send_mail(
- subject='RPKI expiration notice for %s' % h.handle,
- message=t + s,
- from_email=from_email,
- recipient_list=notify_emails
- )
+ t = """This is an automated notice about the upcoming expiration of RPKI resources for the handle %s on %s. You are receiving this notification because your email address is either registered in a Ghostbuster record, or as the default email address for the account.\n\n""" % (h.handle, host)
+ h.send_alert(
+ subject='RPKI expiration notice for %s' % h.handle,
+ message=t + s,
+ from_email=from_email,
+ severity=Alert.WARNING
+ )
diff --git a/rpkid/rpki/gui/app/glue.py b/rpkid/rpki/gui/app/glue.py
index 03225de7..f6ec4344 100644
--- a/rpkid/rpki/gui/app/glue.py
+++ b/rpkid/rpki/gui/app/glue.py
@@ -108,25 +108,3 @@ def list_received_resources(log, conf):
prefix_max=rng.max)
else:
print >>log, "error: unexpected pdu from rpkid type=%s" % type(pdu)
-
-
-def get_email_list(conf):
- """Return a list of the contact emails for this user.
-
- Contact emails are extract from any ghostbuster requests, and if there are
- none, returns the default email for the web portal account.
-
- """
- notify_emails = []
- qs = models.GhostbusterRequest.objects.filter(issuer=conf)
- for gbr in qs:
- if gbr.email_address:
- notify_emails.append(gbr.email_address)
-
- if len(notify_emails) == 0:
- # fall back to the email address registered for this user
- user = User.objects.get(username=conf.handle)
- if user.email:
- notify_emails.append(user.email)
-
- return notify_emails
diff --git a/rpkid/rpki/gui/cacheview/util.py b/rpkid/rpki/gui/cacheview/util.py
index 8ba7d89f..fdb3e370 100644
--- a/rpkid/rpki/gui/cacheview/util.py
+++ b/rpkid/rpki/gui/cacheview/util.py
@@ -29,12 +29,10 @@ from cStringIO import StringIO
from django.db import transaction
import django.db.models
-from django.core.mail import send_mail
import rpki
import rpki.gui.app.timestamp
-from rpki.gui.app.models import Conf
-from rpki.gui.app.glue import get_email_list
+from rpki.gui.app.models import Conf, Alert
from rpki.gui.cacheview import models
from rpki.rcynic import rcynic_xml_iterator, label_iterator
from rpki.sundial import datetime
@@ -358,7 +356,6 @@ def notify_invalid():
for handle, v in notify.iteritems():
conf = Conf.objects.get(handle)
- emails = get_email_list(conf)
msg = StringIO()
msg.write('This is an alert about problems with objects published by '
@@ -394,7 +391,7 @@ record, or is the default email address for this resource holder account on
from_email = 'root@' + getfqdn()
subj = 'invalid RPKI object alert for resource handle %s' % conf.handle
- send_mail(subj, msg.getvalue(), from_email, emails)
+ conf.send_alert(subj, msg.getvalue(), from_email, severity=Alert.ERROR)
def import_rcynic_xml(root=default_root, logfile=default_logfile):