def make_zone(filename: str) -> None:
zonefile = load_module(os.path.basename(filename), filename)
- zones = zonefile.__zones__ # type: Sequence[Zone]
- for zone in zones:
- zone.write()
+ zone = zonefile.__zone__ # type: Zone
+ zone.write()
if __name__ == "__main__":
for name in sys.argv[1:]:
-import re
+import re, datetime
from ipaddress import IPv4Address, IPv6Address
from typing import List, Dict, Any, Iterator, Tuple, Sequence
class Zone:
- def __init__(self, name: str, serialfile: str, dbfile: str, mail: str, NS: List[str],
+ def __init__(self, name: str, serialfile: str, mail: str, NS: List[str],
secondary_refresh: int, secondary_retry: int, secondary_expire: int,
NX_TTL: int = None, A_TTL: int = None, other_TTL: int = None,
domains: Dict[str, Any] = {}) -> None:
self._serialfile = serialfile
- self._dbfile = dbfile
if not name.endswith('.'): raise Exception("Expected an absolute hostname")
self._name = check_hostname(name)
yield rr
def write(self) -> None:
- with open(self._dbfile, 'w') as f:
- for rr in self.generate_rrs():
- f.write(rr+"\n")
- print(rr)
+ print(";; {0} zone file, generated by zonemaker <https://www.ralfj.de/projects/zonemaker> on {1}".format(self._name, datetime.datetime.now()))
+ for rr in self.generate_rrs():
+ print(rr)