1
0
mirror of https://github.com/oskar456/dzonegit.git synced 2024-05-11 05:55:41 +00:00

Issue a warning when duplicate zone file is found

This commit is contained in:
Ondřej Caletka
2018-07-16 16:05:32 +02:00
parent 74b256168d
commit 37101104ed

View File

@ -295,14 +295,21 @@ def template_config(checkoutpath, template):
defaultvar = tpl.get("defaultvar", "")
zonevars = tpl.get("zonevars", dict())
out = list()
zones = set()
zones = dict()
mapping = {"datetime": datetime.datetime.now().strftime("%c")}
out.append(headertpl.substitute(mapping))
for f in sorted(Path(checkoutpath).glob("**/*.zone")):
zonename = get_zone_name(f, f.read_bytes())
if zonename in zones:
continue # Safety net in case duplicate zone file is found
zones.add(zonename)
print(
"WARNING: Duplicate zone file found for zone {}. "
"Using file {}, ignoring {}.".format(
zonename, zones[zonename],
f.relative_to(checkoutpath),
),
)
continue
zones[zonename] = f.relative_to(checkoutpath)
zonevar = zonevars[zonename] if zonename in zonevars else defaultvar
out.append(itemtpl.substitute(
mapping, zonename=zonename,