+from pathlib import Path
+import sys
+from typing import TextIO
+
+from nsconfig.core import NscZonePrimary, NscZoneSecondary
+from nsconfig.daemon import NscDaemon
+
+
+class NscDaemonBind(NscDaemon):
+ config_path: Path = Path('named.conf.nsc')
+
+ def dump_config(self, file: TextIO = sys.stdout) -> None:
+ file.write('# Domains managed by NSC\n')
+ file.write('# This file was automatically generated by NSC, please do not edit manually.\n\n')
+ for z in self.nsc.get_zones():
+ file.write(f'zone "{z.name}" in {{\n') # broken editor: }}
+ if isinstance(z, NscZonePrimary):
+ file.write('\ttype master;\n')
+ file.write(f'\tfile "{z.zone_file}";\n')
+ elif isinstance(z, NscZoneSecondary):
+ file.write('\ttype slave;\n')
+ file.write(f'\tfile "zone/{z.secondary_file}";\n')
+ file.write(f'\tmasters {{ {z.primary_server}; }};\n')
+ else:
+ raise NotImplementedError()
+ file.write('}\n\n')