diff options
author | Michael Elkins <melkins@tislabs.com> | 2015-03-04 23:53:01 +0000 |
---|---|---|
committer | Michael Elkins <melkins@tislabs.com> | 2015-03-04 23:53:01 +0000 |
commit | dc9b65ec2ebac99eae264a4761ed68e1c7156810 (patch) | |
tree | 35216b6d3afbc3078de56c5d0f3586ae4715f24f /rpki/gui/app/models.py | |
parent | 8bc4171157cee26f08c3e131e1f7f905b9e1efb6 (diff) |
add checkbox to ROA creation form to optionally create additional ROAs for child routes that will become invalid as the result the parent creating a ROA.
see #719
svn path=/trunk/; revision=6066
Diffstat (limited to 'rpki/gui/app/models.py')
-rw-r--r-- | rpki/gui/app/models.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/rpki/gui/app/models.py b/rpki/gui/app/models.py index d3b0733d..40bdbe2c 100644 --- a/rpki/gui/app/models.py +++ b/rpki/gui/app/models.py @@ -18,6 +18,7 @@ __version__ = '$Id$' from django.db import models from django.contrib.auth.models import User from django.core.mail import send_mail +from django.db.models import Q import rpki.resource_set import rpki.exceptions @@ -65,6 +66,15 @@ class Child(rpki.irdb.models.Child): proxy = True verbose_name_plural = 'children' + @property + def routes(self): + "Return a list of RouteOrigin objects (potentially) originated by this child." + query = Q() + for r in self.address_ranges.filter(version='IPv4'): + rng = r.as_resource_range() + query |= Q(prefix_min__gte=rng.min, prefix_max__lte=rng.max) + return RouteOrigin.objects.filter(query) + class ChildASN(rpki.irdb.models.ChildASN): """Proxy model for irdb ChildASN.""" @@ -130,8 +140,21 @@ class Conf(rpki.irdb.models.ResourceHolderCA): """Simulates irdb.models.Child.objects, but returns app.models.Child proxy objects. + When running rootd, we need to exclude the Child object for self. + + """ + return Child.objects.filter(issuer=self).exclude(handle=self.handle) + + @property + def child_routes(self): + """Return currently announced routes for prefixes covered by child + sub-allocations. """ - return Child.objects.filter(issuer=self) + query = Q() + for pfx in ChildNet.objects.filter(child__issuer=self, version='IPv4'): + rng = pfx.as_resource_range() + query |= Q(prefix_min__gte=rng.min, prefix_max__lte=rng.max) + return RouteOrigin.objects.filter(query) @property def ghostbusters(self): |