Handle errors when trying to retrieve zone list from NS server

This commit is contained in:
Jeffrey Forman 2011-04-17 07:35:02 -04:00
parent 162c10e262
commit 885b1068fe
3 changed files with 32 additions and 1 deletions

View File

@ -25,7 +25,15 @@ def list_server_zones(request, dns_hostname):
# I should take the dns_hostname here, get the object from the DB,
# and use the status port attribute for the urllib2 query.
myreq = urllib2.Request("http://%s:853" % dns_hostname)
http_request = urllib2.urlopen(myreq)
try:
http_request = urllib2.urlopen(myreq)
except urllib2.URLError, err_reason: # Error retrieving zone list.
server_list = BindServer.objects.all().order_by('hostname')
return render_to_response('bcommon/list_servers.htm',
{ 'server_list' : server_list,
'errors' : err_reason,
'error_context' : "Trying to retrieve zone list from %s" % dns_hostname})
xmloutput = http_request.read()
mysoup = BS(xmloutput)
zones = mysoup.findAll('zone')

View File

@ -8,6 +8,28 @@
{% endblock header %}
<body>
{% block errors %}
{% if errors %}
<div class="errors">
Errors were encountered:
<br>
{{ errors }}
{% if error_context %}
<br>
{{ error_context }}
{% endif %}
<hr>
{% endif %}
{% endblock errors %}
<br>
{% block body %}
{% endblock body %}

View File

@ -2,6 +2,7 @@
{% block body %}
DNS Server List:
<br>
<ul>
{% for current_server in server_list %}