'Write out the named.conf main config file from the template.'

def __write_named_conf(self):

    settings_file = (self.settings.bind_chroot_path + self.settings_file)
    template_file = '/etc/cobbler/named.template'
    metadata = {'forward_zones': self.__forward_zones().keys(), 'reverse_zones': [], 'zone_include': ''}
    for zone in metadata['forward_zones']:
        txt = ('\nzone    "%(zone)s."    {\n                type    master;\n                file    "%(zone)s";\n};\n' % {'zone': zone})
        metadata['zone_include'] = (metadata['zone_include'] + txt)
    for zone in self.__reverse_zones().keys():
        if (':' in zone):
            long_zone = self.__expand_IPv6((zone + '::1'))[:19]
            tokens = list(re.sub(':', '', long_zone))
            tokens.reverse()
            arpa = ('.'.join(tokens) + '.ip6.arpa')
        else:
            tokens = zone.split('.')
            tokens.reverse()
            arpa = ('.'.join(tokens) + '.in-addr.arpa')
        metadata['reverse_zones'].append((zone, arpa))
        txt = ('\nzone    "%(arpa)s."    {\n                type    master;\n                file    "%(zone)s";\n};\n' % {'arpa': arpa, 'zone': zone})
        metadata['zone_include'] = (metadata['zone_include'] + txt)
    try:
        f2 = open(template_file, 'r')
    except:
        raise CX((_('error    reading    template    from    file:    %s') % template_file))
    template_data = ''
    template_data = f2.read()
    f2.close()
    if (self.logger is not None):
        self.logger.info(('generating    %s' % settings_file))
    self.templar.render(template_data, metadata, settings_file, None)
