Remove list_server_zones method. Now an object attribute
This commit is contained in:
parent
a512d82ffd
commit
546ae82e22
|
@ -2,33 +2,9 @@ import urllib2
|
||||||
from BeautifulSoup import BeautifulStoneSoup as BS
|
from BeautifulSoup import BeautifulStoneSoup as BS
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from bcommon.models import Key
|
from bcommon.models import Key, BindServer
|
||||||
import dns.query
|
import dns.query
|
||||||
|
|
||||||
def list_server_zones(dns_hostname):
|
|
||||||
""" Take a DNS server, and list the DNS zones it provides resolution for. """
|
|
||||||
# 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)
|
|
||||||
try:
|
|
||||||
http_request = urllib2.urlopen(myreq)
|
|
||||||
except urllib2.URLError, err_reason: # Error retrieving zone list.
|
|
||||||
return { 'errors' : err_reason, 'error_context' : "Trying to retrieve zone list from %s" % dns_hostname }
|
|
||||||
|
|
||||||
return_array = []
|
|
||||||
xmloutput = http_request.read()
|
|
||||||
mysoup = BS(xmloutput)
|
|
||||||
zones = mysoup.findAll('zone')
|
|
||||||
for current_zone in zones: # Interate over found zones
|
|
||||||
zone_name = current_zone.find('name').contents[0]
|
|
||||||
try: # Is this zone of 'IN' type?
|
|
||||||
in_zone = re.search(r"(.*)\/IN", zone_name).group(1)
|
|
||||||
return_array.append(in_zone)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return return_array
|
|
||||||
|
|
||||||
def list_zone_records(dns_hostname, zone_name):
|
def list_zone_records(dns_hostname, zone_name):
|
||||||
""" Take a DNS zone, and list all the records it contains. """
|
""" Take a DNS zone, and list all the records it contains. """
|
||||||
# Need to move most of this logic into a helper method.
|
# Need to move most of this logic into a helper method.
|
||||||
|
|
Loading…
Reference in New Issue