diff --git a/binder/bcommon/views.py b/binder/bcommon/views.py index 45fb71b..1ed9597 100644 --- a/binder/bcommon/views.py +++ b/binder/bcommon/views.py @@ -4,7 +4,29 @@ from bcommon.models import BindServer from django.template import Context from django.shortcuts import render_to_response +import urllib2 +from BeautifulSoup import BeautifulStoneSoup as BS +import re + def list_servers(request): server_list = BindServer.objects.all().order_by('hostname') return render_to_response('bcommon/list_servers.htm', { 'server_list' : server_list }) + + +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) + xmloutput = http_request.read() + mysoup = BS(xmloutput) + zones = mysoup.findAll('zone') + zone_array = [] + for current_zone in zones: + zone_name = current_zone.find('name').contents[0] + if re.search(r".*\/IN", zone_name): + zone_array.append(zone_name) + + return render_to_response('bcommon/list_server_zones.htm', + { 'zone_array' : zone_array }) diff --git a/binder/templates/bcommon/list_server_zones.htm b/binder/templates/bcommon/list_server_zones.htm new file mode 100644 index 0000000..bdfa1ad --- /dev/null +++ b/binder/templates/bcommon/list_server_zones.htm @@ -0,0 +1,12 @@ +{% extends "base.htm" %} + +{% block body %} +DNS Server Zone List: + +