error handling around viewing unresponsive dns servers in zones. add try/except when adding cname
This commit is contained in:
parent
0c35125777
commit
0736eb3eb5
|
@ -1,4 +1,5 @@
|
||||||
from django.shortcuts import redirect, render
|
from django.shortcuts import redirect, render
|
||||||
|
|
||||||
from binder import exceptions, forms, helpers, models
|
from binder import exceptions, forms, helpers, models
|
||||||
|
|
||||||
# Views
|
# Views
|
||||||
|
@ -32,18 +33,24 @@ def view_server_zones(request, dns_server):
|
||||||
|
|
||||||
def view_zone_records(request, dns_server, zone_name):
|
def view_zone_records(request, dns_server, zone_name):
|
||||||
""" Display the list of records for a particular zone. """
|
""" Display the list of records for a particular zone. """
|
||||||
|
errors = ""
|
||||||
|
zone_array = {}
|
||||||
try:
|
try:
|
||||||
this_server = models.BindServer.objects.get(hostname=dns_server)
|
this_server = models.BindServer.objects.get(hostname=dns_server)
|
||||||
zone_array = this_server.list_zone_records(zone_name)
|
zone_array = this_server.list_zone_records(zone_name)
|
||||||
except exceptions.TransferException, err:
|
except exceptions.TransferException, err:
|
||||||
return render(request, "bcommon/list_zone.htm",
|
return render(request, "bcommon/list_zone.htm",
|
||||||
{ "errors" : err,
|
{ "errors" : err,
|
||||||
"zone_name" : zone_name})
|
"zone_name" : zone_name,
|
||||||
|
"dns_server" : dns_server})
|
||||||
|
except models.BindServer.DoesNotExist:
|
||||||
|
errors = "Requesting a zone listing for a Bind server that is not configured: %s" % dns_server
|
||||||
|
|
||||||
return render(request, "bcommon/list_zone.htm",
|
return render(request, "bcommon/list_zone.htm",
|
||||||
{ "zone_array" : zone_array,
|
{ "zone_array" : zone_array,
|
||||||
"dns_server" : dns_server,
|
"dns_server" : dns_server,
|
||||||
"zone_name" : zone_name})
|
"zone_name" : zone_name,
|
||||||
|
"errors" : errors})
|
||||||
|
|
||||||
def view_add_record(request, dns_server, zone_name):
|
def view_add_record(request, dns_server, zone_name):
|
||||||
""" View to provide form to add a DNS record. """
|
""" View to provide form to add a DNS record. """
|
||||||
|
@ -72,6 +79,8 @@ def view_add_record_result(request):
|
||||||
form_cleaned["create_reverse"])
|
form_cleaned["create_reverse"])
|
||||||
except exceptions.RecordException, err:
|
except exceptions.RecordException, err:
|
||||||
# TODO: Start using this exception.
|
# TODO: Start using this exception.
|
||||||
|
# What would cause this?
|
||||||
|
print "In view_add_record_result, catching RecordException: %s" % err
|
||||||
errors = err
|
errors = err
|
||||||
|
|
||||||
return render(request, "bcommon/response_result.htm",
|
return render(request, "bcommon/response_result.htm",
|
||||||
|
@ -98,19 +107,24 @@ def view_add_cname_result(request):
|
||||||
return redirect("/")
|
return redirect("/")
|
||||||
|
|
||||||
errors = ""
|
errors = ""
|
||||||
|
add_cname_response = ""
|
||||||
form = forms.FormAddCnameRecord(request.POST)
|
form = forms.FormAddCnameRecord(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
cd = form.cleaned_data
|
cd = form.cleaned_data
|
||||||
add_cname_response = helpers.add_cname_record(
|
try:
|
||||||
cd["dns_server"],
|
add_cname_response = helpers.add_cname_record(
|
||||||
cd["zone_name"],
|
cd["dns_server"],
|
||||||
str(cd["originating_record"]),
|
cd["zone_name"],
|
||||||
cd["cname"],
|
str(cd["originating_record"]),
|
||||||
cd["ttl"],
|
cd["cname"],
|
||||||
cd["key_name"])
|
cd["ttl"],
|
||||||
|
cd["key_name"])
|
||||||
|
except exceptions.RecordException, err:
|
||||||
|
errors = err
|
||||||
|
|
||||||
return render(request, "bcommon/response_result.htm",
|
return render(request, "bcommon/response_result.htm",
|
||||||
{"response" : add_cname_response })
|
{"response" : add_cname_response,
|
||||||
|
"errors" : errors })
|
||||||
|
|
||||||
return render(request, "bcommon/add_cname_record_form.htm",
|
return render(request, "bcommon/add_cname_record_form.htm",
|
||||||
{ "dns_server" : request.POST["dns_server"],
|
{ "dns_server" : request.POST["dns_server"],
|
||||||
|
|
Loading…
Reference in New Issue