add zone class and view name to server zone list view

This commit is contained in:
Jeffrey Forman 2012-11-25 14:59:05 -05:00
parent 518f250036
commit b80719c7ea
2 changed files with 22 additions and 9 deletions

View File

@ -45,7 +45,10 @@ class BindServer(models.Model):
TODO: Parse these XML more intelligently. Grab the view name. Any other data available?
Returns:
List of Dicts { String zone_name, String zone_serial }
List of Dicts { String view_name,
String zone_name,
String zone_class,
String zone_serial }
"""
zone_req = urllib2.Request("http://%s:%s" % (self.hostname, self.statistics_port))
try:
@ -56,13 +59,17 @@ class BindServer(models.Model):
return_array = []
xmloutput = http_request.read()
mysoup = BS(xmloutput)
zones = mysoup.findAll('zone')
for current_zone in zones:
zone_name = current_zone.find("name").string.split("/IN")[0]
zone_serial = current_zone.find("serial").string
zone_class = current_zone.find("rdataclass").string
if zone_class == "IN":
return_array.append({"zone_name" : zone_name, "zone_serial" : zone_serial })
views = mysoup.findAll("view")
for view in views:
view_name = view.find("name").string
for zone in view.findAll("zone"):
zone_name, zone_class = zone.find("name").string.split("/")
zone_serial = zone.find("serial").string
if zone_class == "IN":
return_array.append({"view_name" : view_name,
"zone_name" : zone_name,
"zone_class" : zone_class,
"zone_serial" : zone_serial })
return return_array

View File

@ -9,11 +9,17 @@ Server Zone List for {{ dns_server }}
<table class="table">
<tr>
<th>Zone</th>
<th>View</th>
<th>Class</th>
<th>Serial Number</th>
</tr>
{% for current_zone in zone_array %}
<tr>
<td><a href="/info/{{ dns_server }}/{{ current_zone.zone_name }}/"> {{ current_zone.zone_name }}</td>
<td>
<a href="/info/{{ dns_server }}/{{ current_zone.zone_name }}/"> {{ current_zone.zone_name }}</a>
</td>
<td>{{ current_zone.view_name }}</td>
<td>{{ current_zone.zone_class }}</td>
<td>{{ current_zone.zone_serial }}</td>
</tr>
{% endfor %}