diff options
author | Michael Elkins <melkins@tislabs.com> | 2013-01-08 17:46:22 +0000 |
---|---|---|
committer | Michael Elkins <melkins@tislabs.com> | 2013-01-08 17:46:22 +0000 |
commit | 8609ad03805edb0b71f401aee46f80f898a59098 (patch) | |
tree | 5c33bad580087142f7abf40eaa8e9729cb67f012 /rpkid | |
parent | 53b7d85d9724585afbcb36d008597910ff4aa8fa (diff) |
merge ^/branches/tk325
svn path=/trunk/; revision=4957
Diffstat (limited to 'rpkid')
-rw-r--r-- | rpkid/rpki/gui/app/templates/app/dashboard.html | 33 | ||||
-rw-r--r-- | rpkid/rpki/gui/app/views.py | 18 |
2 files changed, 44 insertions, 7 deletions
diff --git a/rpkid/rpki/gui/app/templates/app/dashboard.html b/rpkid/rpki/gui/app/templates/app/dashboard.html index b6a7a9cb..0af4bae6 100644 --- a/rpkid/rpki/gui/app/templates/app/dashboard.html +++ b/rpkid/rpki/gui/app/templates/app/dashboard.html @@ -65,6 +65,7 @@ <p>The following resources have not been allocated to a child, nor appear in a ROA. {% if unused_asns %} + <h3>ASNs</h3> <ul> {% for asn in unused_asns %} <li>AS{{ asn }} @@ -73,19 +74,39 @@ {% endif %} {% if unused_prefixes %} - <ul> + <h3>IPv4</h3> + <table class="table table-condensed table-striped"> + <tr><th>Prefix</th><th>Action</th></tr> {% for addr in unused_prefixes %} - <li>{{ addr }} + <tr> + <td>{{ addr }}</td> + <td> + {# if addr can be represented as a prefix, add a button for issuing a roa #} + {% if addr.is_prefix %} + <a class="btn btn-mini" title="Create ROA using this prefix" href="{% url rpki.gui.app.views.roa_create %}?prefix={{ addr }}">ROA</a> + {% endif %} + </td> + </tr> {% endfor %} <!-- addrs --> - </ul> + </table> {% endif %} {% if unused_prefixes_v6 %} - <ul> + <h3>IPv6</h3> + <table class="table table-condensed table-striped"> + <tr><th>Prefix</th><th></th></tr> {% for addr in unused_prefixes_v6 %} - <li>{{ addr }} + <tr> + <td>{{ addr }}</td> + <td> + {# if addr can be represented as a prefix, add a button for issuing a roa #} + {% if addr.is_prefix %} + <a class="btn btn-mini" title='create roa using this prefix' href="{% url rpki.gui.app.views.roa_create %}?prefix={{ addr }}">roa</a> + {% endif %} + </td> + </tr> {% endfor %} <!-- addrs --> - </ul> + </table> {% endif %} </div><!-- /span --> diff --git a/rpkid/rpki/gui/app/views.py b/rpkid/rpki/gui/app/views.py index fc1e9cce..535ffe6c 100644 --- a/rpkid/rpki/gui/app/views.py +++ b/rpkid/rpki/gui/app/views.py @@ -38,6 +38,7 @@ from rpki.gui.app import models, forms, glue, range_list from rpki.resource_set import (resource_range_as, resource_range_ipv4, resource_range_ipv6, roa_prefix_ipv4) from rpki import sundial +import rpki.exceptions from rpki.gui.cacheview.models import ROAPrefixV4, ROA from rpki.gui.routeview.models import RouteOrigin @@ -195,6 +196,16 @@ def dashboard(request): my_prefixes_v6 = range_list.RangeList([obj.as_resource_range() for obj in prefixes_v6]) unused_prefixes = my_prefixes.difference(used_prefixes) + # monkey-patch each object with a boolean value indicating whether or not + # it is a prefix. We have to do this here because in the template there is + # no way to catch the MustBePrefix exception. + for x in unused_prefixes: + try: + x.prefixlen() + x.is_prefix = True + except rpki.exceptions.MustBePrefix: + x.is_prefix = False + unused_prefixes_v6 = my_prefixes_v6.difference(used_prefixes_v6) clients = models.Client.objects.all() if request.user.is_superuser else None @@ -487,7 +498,12 @@ def roa_create(request): 'max_prefixlen': max_prefixlen, 'routes': routes}) else: - form = forms.ROARequest() + # pull initial values from query parameters + d = {} + for s in ('asn', 'prefix'): + if s in request.GET: + d[s] = request.GET[s] + form = forms.ROARequest(initial=d) return render(request, 'app/roarequest_form.html', {'form': form}) |