diff --git a/README.markdown b/README.markdown index a68e329..8252feb 100644 --- a/README.markdown +++ b/README.markdown @@ -10,6 +10,7 @@ Packages: * [Django](http://www.djangoproject.com) * Python Modules + * [pybindxml](https://pypi.python.org/pypi?name=pybindxml&:action=display): This is a shared library I wrote to scrape and stick into Python dict objects various server/zone data from a BIND DNS server. * [python-beautifulsoup](http://www.crummy.com/software/BeautifulSoup/) * [python-dnspython](http://www.dnspython.org/) * [python-sqlite](http://docs.python.org/2/library/sqlite3.html) (If you will be using Sqlite for server and key storage) diff --git a/binder/models.py b/binder/models.py index 2169c2d..835210b 100644 --- a/binder/models.py +++ b/binder/models.py @@ -6,6 +6,7 @@ import urllib2 # 3rd Party from BeautifulSoup import BeautifulStoneSoup as BS +from pybindxml import reader as bindreader import dns.exception import dns.query import dns.tsig @@ -70,28 +71,9 @@ class BindServer(models.Model): String zone_class, String zone_serial } """ - zone_req = urllib2.Request("http://%s:%s" % (self.hostname, self.statistics_port)) - try: - http_request = urllib2.urlopen(zone_req) - except urllib2.URLError, err: - raise exceptions.ZoneException(err) - - return_array = [] - xmloutput = http_request.read() - mysoup = BS(xmloutput) - 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 + zone_data = bindreader.BindXmlReader(host=self.hostname, port=self.statistics_port) + zone_data.get_stats() + return zone_data def list_zone_records(self, zone_name): """ List all records in a specific zone. diff --git a/binder/templates/bcommon/list_server_zones.htm b/binder/templates/bcommon/list_server_zones.htm index b1f278d..ebd5f95 100644 --- a/binder/templates/bcommon/list_server_zones.htm +++ b/binder/templates/bcommon/list_server_zones.htm @@ -10,18 +10,18 @@ Server Zone List for {{ dns_server }} Zone View - Class Serial Number -{% for current_zone in zone_array %} - - - {{ current_zone.zone_name }} - - {{ current_zone.view_name }} - {{ current_zone.zone_class }} - {{ current_zone.zone_serial }} - +{% for current_zone, cz_data in zone_array.stats.zone_stats.iteritems %} + {% for current_view, cv_data in cz_data.iteritems %} + + + {{ current_zone }} + + {{ current_view }} + {{ cv_data.serial }} + + {% endfor %} {% endfor %} diff --git a/check-dependencies.py b/check-dependencies.py index 3103797..3ebbb8f 100755 --- a/check-dependencies.py +++ b/check-dependencies.py @@ -23,6 +23,12 @@ except ImportError: print "Package is typically called 'python-dnspython.'\n" errors += 1 +try: + import pybindxml +except ImportError: + print "Could not import pybindxml. This is a required module for Binder.\n" + errors += 1 + try: import flup except ImportError: