summaryrefslogtreecommitdiffstats
path: root/cobbler/modules/manage_bind.py
diff options
context:
space:
mode:
Diffstat (limited to 'cobbler/modules/manage_bind.py')
-rw-r--r--cobbler/modules/manage_bind.py31
1 files changed, 21 insertions, 10 deletions
diff --git a/cobbler/modules/manage_bind.py b/cobbler/modules/manage_bind.py
index e7cdc3a7..657a9a77 100644
--- a/cobbler/modules/manage_bind.py
+++ b/cobbler/modules/manage_bind.py
@@ -30,7 +30,6 @@ import sys
import glob
import traceback
import errno
-import popen2
import re
from shlex import shlex
@@ -82,7 +81,13 @@ class BindManager:
in them
"""
zones = {}
- for zone in self.settings.manage_forward_zones:
+ forward_zones = self.settings.manage_forward_zones
+ if type(forward_zones) != type([]):
+ # gracefully handle when user inputs only a single zone
+ # as a string instead of a list with only a single item
+ forward_zones = [forward_zones]
+
+ for zone in forward_zones:
zones[zone] = {}
for system in self.systems:
@@ -126,7 +131,13 @@ class BindManager:
in them
"""
zones = {}
- for zone in self.settings.manage_reverse_zones:
+ reverse_zones = self.settings.manage_reverse_zones
+ if type(reverse_zones) != type([]):
+ # gracefully handle when user inputs only a single zone
+ # as a string instead of a list with only a single item
+ reverse_zones = [reverse_zones]
+
+ for zone in reverse_zones:
zones[zone] = {}
for sys in self.systems:
@@ -223,14 +234,14 @@ zone "%(arpa)s." {
octets = map(lambda x: [str(i) for i in x], octets)
return ['.'.join(i) for i in octets]
- def __pretty_print_host_records(self, hosts, type='A', rclass='IN'):
+ def __pretty_print_host_records(self, hosts, rectype='A', rclass='IN'):
"""
Format host records by order and with consistent indentation
"""
names = [k for k,v in hosts.iteritems()]
if not names: return '' # zones with no hosts
- if type == 'PTR':
+ if rectype == 'PTR':
names = self.__ip_sort(names)
else:
names.sort()
@@ -239,10 +250,10 @@ zone "%(arpa)s." {
s = ""
for name in names:
- s += "%s %s %s %s\n" % (name + (" " * (max_name - len(name))),
- rclass,
- type,
- hosts[name])
+ spacing = " " * (max_name - len(name))
+ my_name = "%s%s" % (name, spacing)
+ my_host = hosts[name]
+ s += "%s %s %s %s\n" % (my_name, rclass, rectype, my_host)
return s
def __write_zone_files(self):
@@ -297,7 +308,7 @@ zone "%(arpa)s." {
except:
template_data = default_template_data
- metadata['host_record'] = self.__pretty_print_host_records(hosts, type='PTR')
+ metadata['host_record'] = self.__pretty_print_host_records(hosts, rectype='PTR')
self.templar.render(template_data, metadata, '/var/named/' + zone, None)