from pathlib import Path
from texttable import Texttable
-from nsconfig.core import Nsc
+from nsconfig.core import Nsc, ZoneType
def do_test(nsc: Nsc) -> None:
test_dir.mkdir(exist_ok=True)
for z in nsc.get_zones():
print(f'Zone: {z.name}')
- print(f'Old serial: {z.prev_state.serial}')
- print(f'Old hash: {z.prev_state.hash}')
- print(f'New serial: {z.state.serial}')
- print(f'New hash: {z.state.hash}')
- out_file = test_dir / z.safe_name
- print(f'Dumping to: {out_file}')
- with open(out_file, 'w') as f:
- z.dump(file=f)
+ print(f'Type: {z.zone_type.name}')
+ if z.zone_type == ZoneType.primary:
+ print(f'Old serial: {z.prev_state.serial}')
+ print(f'Old hash: {z.prev_state.hash}')
+ print(f'New serial: {z.state.serial}')
+ print(f'New hash: {z.state.hash}')
+ out_file = test_dir / z.safe_name
+ print(f'Dumping to: {out_file}')
+ with open(out_file, 'w') as f:
+ z.dump(file=f)
+ else:
+ print(f'Primary: {z.primary_server}')
print()
table.set_deco(Texttable.HEADER)
for z in nsc.get_zones():
+ if z.zone_type != ZoneType.primary:
+ table.add_row([z.name, 'secondary', "", "", "", ""])
+ continue
if z.state.serial == z.prev_state.serial:
action = ""
else:
def do_update(nsc: Nsc) -> None:
for z in nsc.get_zones():
- if z.state.serial != z.prev_state.serial:
+ if z.zone_type == ZoneType.primary and z.state.serial != z.prev_state.serial:
print(f'Updating zone {z.name} (serial {z.state.serial})')
z.write_zone()
z.write_state()