diff options
Diffstat (limited to 'portal-gui/rpkigui')
-rw-r--r-- | portal-gui/rpkigui/myrpki/glue.py | 29 | ||||
-rw-r--r-- | portal-gui/rpkigui/myrpki/models.py | 3 | ||||
-rw-r--r-- | portal-gui/rpkigui/myrpki/views.py | 15 |
3 files changed, 26 insertions, 21 deletions
diff --git a/portal-gui/rpkigui/myrpki/glue.py b/portal-gui/rpkigui/myrpki/glue.py index 959a8da6..bca536df 100644 --- a/portal-gui/rpkigui/myrpki/glue.py +++ b/portal-gui/rpkigui/myrpki/glue.py @@ -49,11 +49,11 @@ from rpkigui.myrpki import models def invoke_rpki(handle, args): """Invoke the myrpki cli for the specified configuration.""" config = settings.MYRPKI_DATA_DIR + '/' + handle + '/myrpki.conf' + myrpki_dir = settings.MYRPKI_DATA_DIR + '/' + handle # default myrpki.conf uses relative paths, so chdir() to the repo first - os.chdir(settings.MYRPKI_DATA_DIR + '/' + handle) - cmd = '%s %s %s' % (sys.executable, settings.MYRPKI_PATH, + cmd = 'cd %s && %s %s %s' % (myrpki_dir, sys.executable, settings.MYRPKI_PATH, ' '.join(['--config=' + config] + args)) - print 'invoking', cmd + print >>sys.stderr, 'invoking', cmd os.system(cmd) def read_file_from_handle(handle, fname): @@ -104,6 +104,12 @@ def output_roas(path, handle): w.writerows([req.as_roa_prefix(), req.roa.asn, '%s-group-%d' % (handle.handle, req.roa.pk)] for req in qs) +def configure_daemons(handle): + args = ['configure_daemons'] + for hosted in handle.hosting.all(): + args.append(settings.MYRPKI_DATA_DIR + '/' + hosted.handle + '/myrpki.xml') + invoke_rpki(handle.handle, args) + def configure_resources(handle): '''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 @@ -116,17 +122,14 @@ def configure_resources(handle): run_rpkidemo = cfg.getboolean('run_rpkidemo', False) if not run_rpkidemo: 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) + if run_rpkid: + configure_daemons(handle) + else: + invoke_rpki(handle.handle, ['configure_resources']) + # send the myrpki.xml to the rpkid hosting me - invoke_rpki(handle.parents.all()[0].handle, ['configure_daemons', xml_path]) + configure_daemons(handle.host) + # process the response invoke_rpki(handle.handle, ['configure_resources']) diff --git a/portal-gui/rpkigui/myrpki/models.py b/portal-gui/rpkigui/myrpki/models.py index dfa4db04..c78e9792 100644 --- a/portal-gui/rpkigui/myrpki/models.py +++ b/portal-gui/rpkigui/myrpki/models.py @@ -40,6 +40,9 @@ class Conf(models.Model): handle = HandleField(unique=True, db_index=True) owner = models.ManyToManyField(User) + # NULL if self-hosted, otherwise the conf that is hosting us + host = models.ForeignKey('Conf', related_name='hosting', null=True) + def __unicode__(self): return self.handle diff --git a/portal-gui/rpkigui/myrpki/views.py b/portal-gui/rpkigui/myrpki/views.py index 674d5af1..b3c69013 100644 --- a/portal-gui/rpkigui/myrpki/views.py +++ b/portal-gui/rpkigui/myrpki/views.py @@ -539,19 +539,18 @@ def upload_repository_request(request, self_handle): def upload_myrpki_xml(request, self_handle): "handles POST of the myrpki.xml file for a given resource handle." conf = handle_or_404(request, self_handle) - parent_handle = get_parent_handle(conf) if request.method == 'POST': try: - fname = '%s/%s/myrpki.xml' % (settings.MYRPKI_DATA_DIR, self_handle,) - print >>sys.stderr, 'writing ', fname - myrpki_xml = open(fname, 'w') - myrpki_xml.write(request.raw_post_data) - myrpki_xml.close() + fname = '%s/%s/myrpki.xml' % (settings.MYRPKI_DATA_DIR, self_handle,) + print >>sys.stderr, 'writing ', fname + myrpki_xml = open(fname, 'w') + myrpki_xml.write(request.raw_post_data) + myrpki_xml.close() - glue.invoke_rpki(parent_handle, [ 'configure_daemons', myrpki_xml.name ]) + glue.configure_daemons(conf.host) except: - print >>sys.stderr, ''.join(sys.exc_info()) + print >>sys.stderr, ''.join(sys.exc_info()) return serve_file(self_handle, 'myrpki.xml', 'application/xml') |