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

View File

@ -9,11 +9,17 @@ Server Zone List for {{ dns_server }}
<table class="table"> <table class="table">
<tr> <tr>
<th>Zone</th> <th>Zone</th>
<th>View</th>
<th>Class</th>
<th>Serial Number</th> <th>Serial Number</th>
</tr> </tr>
{% for current_zone in zone_array %} {% for current_zone in zone_array %}
<tr> <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> <td>{{ current_zone.zone_serial }}</td>
</tr> </tr>
{% endfor %} {% endfor %}