Handle errors when trying to retrieve zone list from NS server
This commit is contained in:
parent
162c10e262
commit
885b1068fe
|
@ -25,7 +25,15 @@ def list_server_zones(request, dns_hostname):
|
||||||
# I should take the dns_hostname here, get the object from the DB,
|
# I should take the dns_hostname here, get the object from the DB,
|
||||||
# and use the status port attribute for the urllib2 query.
|
# and use the status port attribute for the urllib2 query.
|
||||||
myreq = urllib2.Request("http://%s:853" % dns_hostname)
|
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()
|
xmloutput = http_request.read()
|
||||||
mysoup = BS(xmloutput)
|
mysoup = BS(xmloutput)
|
||||||
zones = mysoup.findAll('zone')
|
zones = mysoup.findAll('zone')
|
||||||
|
|
|
@ -8,6 +8,28 @@
|
||||||
{% endblock header %}
|
{% endblock header %}
|
||||||
|
|
||||||
<body>
|
<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 %}
|
{% block body %}
|
||||||
|
|
||||||
{% endblock body %}
|
{% endblock body %}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
DNS Server List:
|
DNS Server List:
|
||||||
|
<br>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{% for current_server in server_list %}
|
{% for current_server in server_list %}
|
||||||
|
|
Loading…
Reference in New Issue