Handles listing dns servers and zones within
This commit is contained in:
parent
03ce6bb7db
commit
8f21491f3a
|
@ -4,7 +4,29 @@ from bcommon.models import BindServer
|
||||||
from django.template import Context
|
from django.template import Context
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render_to_response
|
||||||
|
|
||||||
|
import urllib2
|
||||||
|
from BeautifulSoup import BeautifulStoneSoup as BS
|
||||||
|
import re
|
||||||
|
|
||||||
def list_servers(request):
|
def list_servers(request):
|
||||||
server_list = BindServer.objects.all().order_by('hostname')
|
server_list = BindServer.objects.all().order_by('hostname')
|
||||||
return render_to_response('bcommon/list_servers.htm',
|
return render_to_response('bcommon/list_servers.htm',
|
||||||
{ 'server_list' : server_list })
|
{ '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 })
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
{% extends "base.htm" %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
DNS Server Zone List:
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
{% for current_zone in zone_array %}
|
||||||
|
<li> {{ current_zone }} </li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{% endblock body %}
|
|
@ -1,7 +1,7 @@
|
||||||
{% extends "base.htm" %}
|
{% extends "base.htm" %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
list servers body
|
DNS Server List:
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{% for current_server in server_list %}
|
{% for current_server in server_list %}
|
||||||
|
|
|
@ -8,6 +8,5 @@ urlpatterns = patterns('',
|
||||||
(r'^admin/', include(admin.site.urls)),
|
(r'^admin/', include(admin.site.urls)),
|
||||||
|
|
||||||
(r'^info/$', 'bcommon.views.list_servers'),
|
(r'^info/$', 'bcommon.views.list_servers'),
|
||||||
# (r'^info/(?P<dns_hostname>[a-zA-Z0-9.]+)$', 'bcommon.views.list_server_zones'),
|
(r'^info/(?P<dns_hostname>[a-zA-Z0-9.]+)$', 'bcommon.views.list_server_zones'),
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue