From 8f21491f3a8fa055cba4b043a1aad9dc1131fb13 Mon Sep 17 00:00:00 2001 From: Jeffrey Forman Date: Wed, 13 Apr 2011 22:27:40 -0400 Subject: [PATCH] Handles listing dns servers and zones within --- binder/bcommon/views.py | 22 +++++++++++++++++++ .../templates/bcommon/list_server_zones.htm | 12 ++++++++++ binder/templates/bcommon/list_servers.htm | 2 +- binder/urls.py | 3 +-- 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 binder/templates/bcommon/list_server_zones.htm 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: + + + +{% endblock body %} diff --git a/binder/templates/bcommon/list_servers.htm b/binder/templates/bcommon/list_servers.htm index 1423793..d04d85b 100644 --- a/binder/templates/bcommon/list_servers.htm +++ b/binder/templates/bcommon/list_servers.htm @@ -1,7 +1,7 @@ {% extends "base.htm" %} {% block body %} -list servers body +DNS Server List: