diff options
author | Michael Elkins <melkins@tislabs.com> | 2010-07-03 00:06:02 +0000 |
---|---|---|
committer | Michael Elkins <melkins@tislabs.com> | 2010-07-03 00:06:02 +0000 |
commit | 3a5267e69ae9955c2b01d299df09f67603801fbe (patch) | |
tree | 8b280b09d61f7548a647a88d968750d8ad189894 | |
parent | 017d58b323d21a10af6480f32da0ead3ad46b519 (diff) |
invoke glue.configure_resources upon changes
svn path=/portal-gui/rpkigui/myrpki/glue.py; revision=3312
-rw-r--r-- | portal-gui/rpkigui/myrpki/glue.py | 20 | ||||
-rw-r--r-- | portal-gui/rpkigui/myrpki/urls.py | 6 | ||||
-rw-r--r-- | portal-gui/rpkigui/myrpki/views.py | 4 | ||||
-rw-r--r-- | portal-gui/rpkigui/templates/myrpki/dashboard.html | 10 | ||||
-rw-r--r-- | portal-gui/rpkigui/urls.py | 2 |
5 files changed, 36 insertions, 6 deletions
diff --git a/portal-gui/rpkigui/myrpki/glue.py b/portal-gui/rpkigui/myrpki/glue.py index a8abac89..88963904 100644 --- a/portal-gui/rpkigui/myrpki/glue.py +++ b/portal-gui/rpkigui/myrpki/glue.py @@ -1,3 +1,5 @@ +# $Id: $ + from __future__ import with_statement import os @@ -26,6 +28,7 @@ from django.conf import settings def invoke_rpki(handle, args): """Invoke the myrpki cli for the specified configuration.""" config = settings.MYRPKI_DATA_DIR + '/' + handle + '/myrpki.conf' + # default myrpki.conf uses relative paths, so chdir() to the repo first os.chdir(settings.MYRPKI_DATA_DIR + '/' + handle) cmd = 'python ' + settings.MYRPKI_SRC_DIR + '/myrpki.py ' + ' '.join(['--config=' + config] + args) print 'invoking', cmd @@ -69,7 +72,7 @@ def output_roas(path, handle): '%s-group-%d' % (handle.handle, r.pk)]) def configure_resources(handle): - '''write out the .csv files and invoke the myrpki command line tool.''' + '''Write out the csv files and invoke the myrpki.py command line tool.''' # chdir to the repo dir since the default myrpki.conf uses relative # pathnames.. os.chdir(settings.MYRPKI_DATA_DIR + '/' + handle.handle) @@ -77,6 +80,19 @@ def configure_resources(handle): output_asns(cfg.get('asn_csv'), handle) output_prefixes(cfg.get('prefix_csv'), handle) output_roas(cfg.get('roa_csv'), handle) - #invoke_rpki(handle.handle, ['configure_daemons']) + run_rpkid = cfg.getboolean('run_rpkid') + cmd = 'daemons' if run_rpkid else 'resources' + invoke_rpki(handle.handle, ['configure_' + cmd]) + # handle the hosted case where some communication between rpkid operator + # and resource holder is required + if not run_rpkid: + xml_path = cfg.get('xml_filename') + if xml_path[0] != '/': + # convert to full path + xml_path = '%s/%s/%s' % (settings.MYRPKI_DATA_DIR, handle.handle, xml_path) + # send the myrpki.xml to the rpkid hosting me + invoke_rpki(handle.parents.all()[0].handle, ['configure_daemons', xml_path]) + # process the response + invoke_rpki(handle.handle, ['configure_resources']) # vim:sw=4 ts=8 expandtab diff --git a/portal-gui/rpkigui/myrpki/urls.py b/portal-gui/rpkigui/myrpki/urls.py index 2247c738..a2c5b5da 100644 --- a/portal-gui/rpkigui/myrpki/urls.py +++ b/portal-gui/rpkigui/myrpki/urls.py @@ -1,3 +1,5 @@ +# $Id: $ + from django.conf.urls.defaults import * from django.views.generic.list_detail import object_list import views @@ -8,8 +10,8 @@ urlpatterns = patterns('', (r'^conf/export$', views.conf_export), (r'^conf/list$', views.conf_list), (r'^conf/select$', views.conf_select), - (r'^import/parent$', views.parent_import), - (r'^import/child$', views.child_import), +# (r'^import/parent$', views.parent_import), +# (r'^import/child$', views.child_import), (r'^parent/(?P<parent_handle>[^/]+)$', views.parent_view), (r'^child/(?P<child_handle>[^/]+)$', views.child_view), # (r'^parent/(?P<parent_handle>[^/]+)/address$', views.parent_address), diff --git a/portal-gui/rpkigui/myrpki/views.py b/portal-gui/rpkigui/myrpki/views.py index 70c453c1..fef79e9a 100644 --- a/portal-gui/rpkigui/myrpki/views.py +++ b/portal-gui/rpkigui/myrpki/views.py @@ -1,3 +1,5 @@ +# $Id: $ + import os import tempfile from django.views.generic.create_update import create_object, update_object, \ @@ -463,6 +465,7 @@ def prefix_allocate_view(request, pk): if form.is_valid(): prefix.allocated = form.cleaned_data['child'] prefix.save() + glue.configure_resources(handle) return http.HttpResponseRedirect(prefix.get_absolute_url()) else: form = forms.PrefixAllocateForm(prefix.allocated.pk if prefix.allocated else None, @@ -547,6 +550,7 @@ def asn_allocate_view(request, pk): if form.is_valid(): obj.allocated = form.cleaned_data['child'] obj.save() + glue.configure_resources(handle) return http.HttpResponseRedirect(obj.get_absolute_url()) else: form = forms.PrefixAllocateForm(obj.allocated.pk if obj.allocated else None, diff --git a/portal-gui/rpkigui/templates/myrpki/dashboard.html b/portal-gui/rpkigui/templates/myrpki/dashboard.html index 7485c700..8abe7f82 100644 --- a/portal-gui/rpkigui/templates/myrpki/dashboard.html +++ b/portal-gui/rpkigui/templates/myrpki/dashboard.html @@ -37,13 +37,15 @@ {% endfor %} </ul> +<!-- <a href="/myrpki/import/parent">[add]</a> +--> </div> <span> <div style="border: outset"> <h1 style="text-align: center">Children</h1> -<p> +{% if request.session.handle.children.all %} <ul> {% for child in request.session.handle.children.all %} <li><a href="/myrpki/child/{{ child.handle }}">{{ child.handle }}</a> @@ -60,7 +62,13 @@ {% endif %} {% endfor %} </ul> +<!-- <a href="/myrpki/import/child">[add]</a> +--> +{% else %} +<p>-- none -- +{% endif %} + </div> <div style="border: outset"> diff --git a/portal-gui/rpkigui/urls.py b/portal-gui/rpkigui/urls.py index b5947c91..dddb6a0a 100644 --- a/portal-gui/rpkigui/urls.py +++ b/portal-gui/rpkigui/urls.py @@ -23,6 +23,6 @@ urlpatterns = patterns('', #XXX (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', #{'document_root': '/Users/fenner/src/portal-gui/media/'}), - {'document_root': '/home/me/src/rpki/portal-gui/media/'}), + {'document_root': '/home/melkins/src/rpki/portal-gui/media/'}), ) |