from pymin.seqtools import Sequence
from pymin.dispatcher import handler, HandlerError, Handler
from pymin.services.util import Restorable, ConfigWriter, InitdHandler, \
- TransactionalHandler, ParametersHandler, call
+ TransactionalHandler, ParametersHandler, \
+ SubHandler, call
__ALL__ = ('DnsHandler', 'Error',
'ZoneError', 'ZoneNotFoundError', 'ZoneAlreadyExistsError',
def as_tuple(self):
return (self.name, self.ip)
-class HostHandler(Handler):
+class HostHandler(SubHandler):
handler_help = u"Manage DNS hosts"
- def __init__(self, parent):
- self.parent = parent
-
@handler(u'Adds a host to a zone')
def add(self, name, hostname, ip):
if not name in self.parent.zones:
def as_tuple(self):
return (self.mx, self.prio)
-class MailExchangeHandler(Handler):
+class MailExchangeHandler(SubHandler):
handler_help = u"Manage DNS mail exchangers (MX)"
- def __init__(self, parent):
- self.parent = parent
-
@handler(u'Adds a mail exchange to a zone')
def add(self, zonename, mx, prio):
if not zonename in self.parent.zones:
def as_tuple(self):
return (self.name)
-class NameServerHandler(Handler):
+class NameServerHandler(SubHandler):
handler_help = u"Manage DNS name servers (NS)"
- def __init__(self, parent):
- self.parent = parent
-
@handler(u'Adds a name server to a zone')
def add(self, zone, ns):
if not zone in self.parent.zones:
def as_tuple(self):
return (self.name, self.hosts, self.mxs, self.nss)
-class ZoneHandler(Handler):
+class ZoneHandler(SubHandler):
r"""ZoneHandler(parent.zones) -> ZoneHandler instance :: Handle a list of zones.
This class is a helper for DnsHandler to do all the work related to zone
handler_help = u"Manage DNS zones"
- def __init__(self, parent):
- self.parent = parent
-
@handler(u'Adds a zone')
def add(self, name):
if name in self.parent.zones:
self.parent.zones[name].mod = True
self.parent.zones[name].new = True
-
@handler(u'Deletes a zone')
def delete(self, name):
r"delete(name) -> None :: Delete a zone from the zone list."
_config_writer_files = ('named.conf', 'zoneX.zone')
_config_writer_tpl_dir = path.join(path.dirname(__file__), 'templates')
- def __init__(self, pickle_dir='.', config_dir='.'):
+ def __init__(self, pickle_dir='.', config_dir={'named.conf':'.', 'zoneX.zone':'.'}):
r"Initialize DnsHandler object, see class documentation for details."
self._persistent_dir = pickle_dir
self._config_writer_cfg_dir = config_dir