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 })
|
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 = 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']))
|
dns_update.replace(str(clean_data['rr_name']), 10, str(clean_data['rr_type']), str(clean_data['rr_data']))
|
||||||
response = dns.query.tcp(dns_update, clean_data['dns_hostname'])
|
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
|
return response
|
||||||
|
|
|
@ -74,6 +74,12 @@ def add_record_result(request):
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
cd = form.cleaned_data
|
cd = form.cleaned_data
|
||||||
response = add_record(cd)
|
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',
|
return render_to_response('bcommon/add_record_result.htm',
|
||||||
{ 'response' : response },
|
{ 'response' : response },
|
||||||
context_instance=RequestContext(request))
|
context_instance=RequestContext(request))
|
||||||
|
|
|
@ -2,11 +2,14 @@
|
||||||
|
|
||||||
|
|
||||||
{% block pageheader %}
|
{% block pageheader %}
|
||||||
Result:
|
|
||||||
{% endblock pageheader %}
|
{% endblock pageheader %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<pre>
|
{% if not errors %}
|
||||||
{{ response }}
|
Result:
|
||||||
</pre>
|
<pre>
|
||||||
|
{{ response }}
|
||||||
|
</pre>
|
||||||
|
{% endif %}
|
||||||
{% endblock body %}
|
{% endblock body %}
|
||||||
|
|
Loading…
Reference in New Issue