Preliminary error handling around key errors when adding a record
This commit is contained in:
parent
a981711c22
commit
5523e79ded
|
@ -62,5 +62,9 @@ def add_record(clean_data):
|
|||
keyring = dns.tsigkeyring.from_text({ key_name : key_data })
|
||||
dns_update = dns.update.Update(clean_data['rr_domain'], keyring = keyring, keyalgorithm=key_algorithm)
|
||||
dns_update.replace(str(clean_data['rr_name']), 10, str(clean_data['rr_type']), str(clean_data['rr_data']))
|
||||
try:
|
||||
response = dns.query.tcp(dns_update, clean_data['dns_hostname'])
|
||||
except dns.tsig.PeerBadKey:
|
||||
return {'errors' : "There was a problem adding your record due to a TSIG key issue. Please resolve that first." }
|
||||
|
||||
return response
|
||||
|
|
|
@ -74,6 +74,12 @@ def add_record_result(request):
|
|||
if form.is_valid():
|
||||
cd = form.cleaned_data
|
||||
response = add_record(cd)
|
||||
|
||||
if 'errors' in response:
|
||||
return render_to_response('bcommon/add_record_result.htm',
|
||||
{ 'errors' : response['errors'] },
|
||||
context_instance=RequestContext(request))
|
||||
else:
|
||||
return render_to_response('bcommon/add_record_result.htm',
|
||||
{ 'response' : response },
|
||||
context_instance=RequestContext(request))
|
||||
|
|
|
@ -2,11 +2,14 @@
|
|||
|
||||
|
||||
{% block pageheader %}
|
||||
Result:
|
||||
|
||||
{% endblock pageheader %}
|
||||
|
||||
{% block body %}
|
||||
<pre>
|
||||
{% if not errors %}
|
||||
Result:
|
||||
<pre>
|
||||
{{ response }}
|
||||
</pre>
|
||||
</pre>
|
||||
{% endif %}
|
||||
{% endblock body %}
|
||||
|
|
Loading…
Reference in New Issue