X-Git-Url: https://git.llucax.com/software/pymin.git/blobdiff_plain/7012b07c7b88ece1a0a08c53ca5a07c81209d2e6..b9f71ad8a238ed93c7e515cc9602d11700f183ae:/pymin/services/dns/__init__.py?ds=sidebyside diff --git a/pymin/services/dns/__init__.py b/pymin/services/dns/__init__.py index 3736a25..13aaa08 100644 --- a/pymin/services/dns/__init__.py +++ b/pymin/services/dns/__init__.py @@ -8,7 +8,8 @@ from new import instancemethod 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', @@ -177,13 +178,10 @@ class Host(Sequence): 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: @@ -229,13 +227,10 @@ class MailExchange(Sequence): 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: @@ -280,13 +275,10 @@ class NameServer(Sequence): 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: @@ -327,7 +319,7 @@ class Zone(Sequence): 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 @@ -338,9 +330,6 @@ class ZoneHandler(Handler): 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: @@ -352,7 +341,6 @@ class ZoneHandler(Handler): 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."