def myrpki_xml(request, self_handle): """ Handles POST of the myrpki.xml file for a given resource handle. As a special case for resource handles hosted by APNIC, stash a copy of the first xml message in the rpki inbox mailbox as this will be required to complete the parent-child setup. """ conf = handle_or_404(request, self_handle) log = request.META['wsgi.errors'] if request.method == 'POST': fname = glue.confpath(self_handle, '/myrpki.xml') if not os.path.exists(fname): print >>log, 'Saving a copy of myrpki.xml for handle %s to inbox' % conf.handle save_to_inbox(conf, 'myrpki', request.POST['content']) print >>log, 'writing %s' % fname with open(fname, 'w') as myrpki_xml : myrpki_xml.write(request.POST['content']) # FIXME: used to run configure_daemons here, but it takes too # long with many hosted handles. rpkidemo still needs a way # to do initial bpki setup with rpkid! return http.HttpResponse('<p>success</p>') else: return serve_file(self_handle, 'myrpki.xml', 'application/xml')
def myrpki_xml(request, self_handle): """ Handles POST of the myrpki.xml file for a given resource handle. As a special case for resource handles hosted by APNIC, stash a copy of the first xml message in the rpki inbox mailbox as this will be required to complete the parent-child setup. """ conf = handle_or_404(request, self_handle) log = request.META['wsgi.errors'] if request.method == 'POST': fname = glue.confpath(self_handle, '/myrpki.xml') if not os.path.exists(fname): print >> log, 'Saving a copy of myrpki.xml for handle %s to inbox' % conf.handle save_to_inbox(conf, 'myrpki', request.POST['content']) print >> log, 'writing %s' % fname with open(fname, 'w') as myrpki_xml: myrpki_xml.write(request.POST['content']) # FIXME: used to run configure_daemons here, but it takes too # long with many hosted handles. rpkidemo still needs a way # to do initial bpki setup with rpkid! return http.HttpResponse('<p>success</p>') else: return serve_file(self_handle, 'myrpki.xml', 'application/xml')
def get_response(conf, request_type): """ If there is cached response for the given request type, simply return it. Otherwise, look in the outbox mailbox for a response. """ filename = glue.confpath(conf.handle) + '/' + request_type + '.xml' if not os.path.exists(filename): box = mailbox.Maildir(settings.OUTBOX, factory=None) for key, msg in box.iteritems(): # look for parent responses for this child if msg.get('x-rpki-type') == request_type and msg.get('x-rpki-self-handle') == conf.handle: with open(filename, 'w') as f: f.write(msg.get_payload()) break else: return http.HttpResponse('no response found', status=503) box.remove(key) # remove the msg from the outbox return serve_file(conf.handle, request_type + '.xml', 'application/xml')
def get_response(conf, request_type): """ If there is cached response for the given request type, simply return it. Otherwise, look in the outbox mailbox for a response. """ filename = glue.confpath(conf.handle) + '/' + request_type + '.xml' if not os.path.exists(filename): box = mailbox.Maildir(settings.OUTBOX, factory=None) for key, msg in box.iteritems(): # look for parent responses for this child if msg.get('x-rpki-type') == request_type and msg.get( 'x-rpki-self-handle') == conf.handle: with open(filename, 'w') as f: f.write(msg.get_payload()) break else: return http.HttpResponse('no response found', status=503) box.remove(key) # remove the msg from the outbox return serve_file(conf.handle, request_type + '.xml', 'application/xml')