From 2fd3698a920105ffa759f546666a1793c8c46c14 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 8 Nov 2014 22:10:37 +0100 Subject: [PATCH 1/1] initial commit --- zone-maker | 20 ++++++++++++++++++++ zonemaker/__init__.py | 0 zonemaker/zone.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100755 zone-maker create mode 100644 zonemaker/__init__.py create mode 100644 zonemaker/zone.py diff --git a/zone-maker b/zone-maker new file mode 100755 index 0000000..ddfb195 --- /dev/null +++ b/zone-maker @@ -0,0 +1,20 @@ +#!/usr/bin/python3 +import sys, os + +def load_module(name, path, write_bytecode = False): + import importlib.machinery + old_val = sys.dont_write_bytecode + sys.dont_write_bytecode = not write_bytecode + module = importlib.machinery.SourceFileLoader(name, path).load_module() + sys.dont_write_bytecode = old_val + return module + +def make_zone(filename): + zonefile = load_module(os.path.basename(filename), filename) + zones = zonefile.__zones__ + # TODO do something with the zones + +if __name__ == "__main__": + for name in sys.argv[1:]: + make_zone(name) + diff --git a/zonemaker/__init__.py b/zonemaker/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/zonemaker/zone.py b/zonemaker/zone.py new file mode 100644 index 0000000..6319505 --- /dev/null +++ b/zonemaker/zone.py @@ -0,0 +1,42 @@ +second = 1 +minute = 60*second +hour = 60*minute +day = 24*hour + +class Address: + def __init__(self, IPv4 = None, IPv6 = None): + self._IPv4 = IPv4 + self._IPv6 = IPv6 + + def IPv4(self): + return Address(IPv4 = self._IPv4) + + def IPv6(self): + return Address(IPv6 = self._IPv6) + +class Name: + def __init__(self, address = None, MX = None, TCP = None, UDP = None): + self._address = address + +class Service: + def __init__(self, SRV = None, TLSA=None): + self._SRV = SRV + self._TLSA = TLSA + +class CName: + def __init__(self, name): + self._name = name + +class Delegation(): + def __init__(self, NS, DS = None): + pass + +class Zone: + def __init__(self, name, mail, NS, + secondary_refresh, secondary_retry, secondary_discard, + NX_TTL = None, A_TTL = None, other_TTL = None, + domains = []): + assert other_TTL is not None + self._NX_TTL = other_TTL if NX_TTL is None else NX_TTL + self._A_TTL = other_TTL if A_TTL is None else A_TTL + self._other_TTL = other_TTL -- 2.30.2