1 from pathlib import Path
3 from typing import TextIO
5 from nsconfig.core import NscZonePrimary, NscZoneSecondary
6 from nsconfig.daemon import NscDaemon
9 class NscDaemonBind(NscDaemon):
10 config_path: Path = Path('named.conf.nsc')
12 def dump_config(self, file: TextIO = sys.stdout) -> None:
13 file.write('# Domains managed by NSC\n')
14 file.write('# This file was automatically generated by NSC, please do not edit manually.\n\n')
15 for z in self.nsc.get_zones():
16 file.write(f'zone "{z.name}" in {{\n') # broken editor: }}
17 if isinstance(z, NscZonePrimary):
18 file.write('\ttype master;\n')
19 file.write(f'\tfile "{z.zone_file}";\n')
20 elif isinstance(z, NscZoneSecondary):
21 file.write('\ttype slave;\n')
22 file.write(f'\tfile "zone/{z.secondary_file}";\n')
23 file.write(f'\tmasters {{ {z.primary_server}; }};\n')
25 raise NotImplementedError()