diff options
author | Michael Elkins <melkins@tislabs.com> | 2012-07-12 17:46:16 +0000 |
---|---|---|
committer | Michael Elkins <melkins@tislabs.com> | 2012-07-12 17:46:16 +0000 |
commit | 6c70c689f230d39499c43cb5b1c94f86d55aad64 (patch) | |
tree | 3154dc912247be3cd8ab7022a5522a6a2343e22b | |
parent | 12121997af0bbfabd1eb375d01bfb6e6b178451a (diff) |
move fetching of admin email addresses to the glue library so it can be used by rpkigui-rcynic as well
svn path=/trunk/; revision=4598
-rw-r--r-- | rpkid/portal-gui/scripts/rpkigui-check-expired.py | 13 | ||||
-rw-r--r-- | rpkid/rpki/gui/app/glue.py | 22 |
2 files changed, 24 insertions, 11 deletions
diff --git a/rpkid/portal-gui/scripts/rpkigui-check-expired.py b/rpkid/portal-gui/scripts/rpkigui-check-expired.py index 1573de4d..64e334bf 100644 --- a/rpkid/portal-gui/scripts/rpkigui-check-expired.py +++ b/rpkid/portal-gui/scripts/rpkigui-check-expired.py @@ -17,7 +17,7 @@ __version__ = '$Id$' from rpki.gui.cacheview.models import Cert from rpki.gui.cacheview.views import cert_chain from rpki.gui.app.models import ResourceCert, GhostbusterRequest -from rpki.gui.app.glue import list_received_resources +from rpki.gui.app.glue import list_received_resources, get_email_list from rpki.irdb.models import ResourceHolderCA from rpki.irdb import Zookeeper from rpki.left_right import report_error_elt, list_published_objects_elt @@ -184,16 +184,7 @@ for h in qs: print s if options.email: - notify_emails = [] - qs = GhostbusterRequest.objects.filter(issuer=h) - 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 = Users.objects.get(username=h.handle) - notify_emails.append(user.email) + notify_emails = get_email_list(h) 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) diff --git a/rpkid/rpki/gui/app/glue.py b/rpkid/rpki/gui/app/glue.py index 577f9c7b..66d4c368 100644 --- a/rpkid/rpki/gui/app/glue.py +++ b/rpkid/rpki/gui/app/glue.py @@ -121,9 +121,31 @@ def config_from_template(dest, a): else: print >>f, r, + def str_to_resource_range(prefix): try: r = resource_range_ipv4.parse_str(prefix) except BadIPResource: r = resource_range_ipv6.parse_str(prefix) return r + + +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) + notify_emails.append(user.email) + + return notify_emails |