def roa_create_multi_confirm(request):
"""This function is called when the user confirms the creation of a ROA
request. It is responsible for updating the IRDB.
"""
conf = get_conf(request.user, request.session['handle'])
log = request.META['wsgi.errors']
if request.method == 'POST':
formset = formset_factory(forms.ROARequestConfirm, extra=0)(request.POST, request.FILES)
if formset.is_valid():
for cleaned_data in formset.cleaned_data:
asn = cleaned_data.get('asn')
prefix = cleaned_data.get('prefix')
rng = resource_range_ip.parse_str(prefix)
max_prefixlen = cleaned_data.get('max_prefixlen')
# Always create ROA requests with a single prefix.
# https://trac.rpki.net/ticket/32
roa = models.ROARequest.objects.create(issuer=conf, asn=asn)
v = 'IPv%d' % rng.version
roa.prefixes.create(version=v, prefix=str(rng.min),
prefixlen=rng.prefixlen(),
max_prefixlen=max_prefixlen)
Zookeeper(handle=conf.handle, logstream=log, disable_signal_handlers=True).run_rpkid_now()
return redirect(dashboard)
# What should happen when the submission form isn't valid? For now
# just fall through and redirect back to the ROA creation form
return http.HttpResponseRedirect(reverse(roa_create_multi))
评论列表
文章目录