- DictComposedSubHandler, DictSubHandler, call
-
-__all__ = ('DnsHandler', 'get_service')
-
-
-def get_service(config):
- return DnsHandler(config.dns.pickle_dir, config.dns.config_dir)
-
-
-class Host(Sequence):
- def __init__(self, name, ip):
- self.name = name
- self.ip = ip
- def update(self, ip=None):
- if ip is not None: self.ip = ip
- def as_tuple(self):
- return (self.name, self.ip)
-
-class HostHandler(DictComposedSubHandler):
- handler_help = u"Manage DNS hosts"
- _comp_subhandler_cont = 'zones'
- _comp_subhandler_attr = 'hosts'
- _comp_subhandler_class = Host
-
-class MailExchange(Sequence):
- def __init__(self, mx, prio):
- self.mx = mx
- self.prio = prio
- def update(self, prio=None):
- if prio is not None: self.prio = prio
- def as_tuple(self):
- return (self.mx, self.prio)
-
-class MailExchangeHandler(DictComposedSubHandler):
- handler_help = u"Manage DNS mail exchangers (MX)"
- _comp_subhandler_cont = 'zones'
- _comp_subhandler_attr = 'mxs'
- _comp_subhandler_class = MailExchange
-
-class NameServer(Sequence):
- def __init__(self, name):
- self.name = name
- def as_tuple(self):
- return (self.name,)
-
-class NameServerHandler(DictComposedSubHandler):
- handler_help = u"Manage DNS name servers (NS)"
- _comp_subhandler_cont = 'zones'
- _comp_subhandler_attr = 'nss'
- _comp_subhandler_class = NameServer
-
-class Zone(Sequence):
- def __init__(self, name):
- self.name = name
- self.hosts = dict()
- self.mxs = dict()
- self.nss = dict()
- self._add = False
- self._update = False
- self._delete = False
- def as_tuple(self):
- return (self.name, self.hosts, self.mxs, self.nss)