from .pidfile import PidFileError, InvalidPidFileError, PidFileInUseError, PidFile
-__version__ = '0.5.6'
+__version__ = '0.6.1'
LOG = logging.getLogger(__name__)
self.generate_acl_file()
self.generate_named_conf()
self.generate_log_cfg_file()
+ self.generate_slave_cfg_file()
time.sleep(2)
content += '\n'.join(lines) + '\n'
-
content += '\n};\n'
content += '\n// vim: ts=8 filetype=named noet noai\n'
if self.verbose > 2:
LOG.debug("Generated {!r}:\n{}".format(self.temp_log_cfg_file, content.strip()))
+ # -------------------------------------------------------------------------
+ def generate_slave_cfg_file(self):
+
+ LOG.info("Generating {} ...".format(self.default_named_zones_cfg_file))
+
+ cur_date = datetime.datetime.now().isoformat(' ')
+ re_rev = re.compile(r'^rev\.', re.IGNORECASE)
+ re_trail_dot = re.compile(r'\.+$')
+
+ lines = []
+ lines.append('###############################################################')
+ lines.append('')
+ lines.append(' Bind9 configuration file for slave sones')
+ lines.append(' {}'.format(self.named_zones_cfg_file))
+ lines.append('')
+ lines.append(' Generated at: {}'.format(cur_date))
+ lines.append('')
+ lines.append('###############################################################')
+ header = textwrap.indent('\n'.join(lines), '//', lambda line: True) + '\n'
+
+ content = header
+
+ for zone in self.zones:
+
+ account = str(zone['account']).lower().strip()
+
+ zname = re_trail_dot.sub('', zone['name'])
+ show_name = zone['canonical_name']
+ show_name = re_rev.sub('Reverse ', show_name)
+ show_name = re_trail_dot.sub('', show_name)
+ if account.startswith('intern') or account.startswith('local'):
+ if not self.is_internal:
+ LOG.debug("Ignoring zone {!r}, because it's an internal zone.".format(zname))
+ continue
+ else:
+ if self.is_internal:
+ LOG.debug("Ignoring zone {!r}, because it's a public zone.".format(zname))
+ continue
+
+ zfile = os.path.join(
+ self.named_slavedir_rel, re_trail_dot.sub('', zone['canonical_name']) + '.zone')
+
+ lines = []
+ lines.append('')
+ lines.append('// {}'.format(show_name))
+ lines.append('zone "{}" in {{'.format(zname))
+ lines.append('\tmasters {')
+ for master in self.zone_masters:
+ lines.append('\t\t{};'.format(master))
+ lines.append('\t};')
+ lines.append('\ttype slave;')
+ lines.append('\tfile "{}";'.format(zfile))
+ lines.append('};')
+
+ content += '\n'.join(lines) + '\n'
+
+ content += '\n// vim: ts=8 filetype=named noet noai\n'
+
+ with open(self.temp_zones_cfg_file, 'w', **self.open_args) as fh:
+ fh.write(content)
+
+ if self.verbose > 2:
+ LOG.debug("Generated {!r}:\n{}".format(self.temp_zones_cfg_file, content.strip()))
+
+
# -------------------------------------------------------------------------
def get_api_zones(self):
if match:
prefix = self._get_ipv4_prefix(match.group(1))
if prefix:
+ if prefix == '127.0.0':
+ LOG.debug("Pure local zone {!r} will not be considered.".format(prefix))
+ continue
uni_name = 'rev.' + prefix
if not uni_name: