message - A descriptive error message.
"""
-
- def __init__(self, message):
- r"Initialize the Error object. See class documentation for more info."
- self.message = message
-
- def __str__(self):
- return self.message
+ pass
class ZoneError(Error, KeyError):
r"""
def __init__(self, zonename):
r"Initialize the object. See class documentation for more info."
- self.message = 'Zone error: "%s"' % zonename
+ self.message = u'Zone error: "%s"' % zonename
class ZoneNotFoundError(ZoneError):
r"""
def __init__(self, zonename):
r"Initialize the object. See class documentation for more info."
- self.message = 'zone not found: "%s"' % zonename
+ self.message = u'zone not found: "%s"' % zonename
class ZoneAlreadyExistsError(ZoneError):
r"""
def __init__(self, zonename):
r"Initialize the object. See class documentation for more info."
- self.message = 'Zone already exists: "%s"' % zonename
+ self.message = u'Zone already exists: "%s"' % zonename
class HostError(Error, KeyError):
r"""
def __init__(self, hostname):
r"Initialize the object. See class documentation for more info."
- self.message = 'Host error: "%s"' % hostname
+ self.message = u'Host error: "%s"' % hostname
class HostAlreadyExistsError(HostError):
r"""
def __init__(self, hostname):
r"Initialize the object. See class documentation for more info."
- self.message = 'Host already exists: "%s"' % hostname
+ self.message = u'Host already exists: "%s"' % hostname
class HostNotFoundError(HostError):
r"""
- HostNotFoundError(hostname) -> HostNotFoundError instance
+ HostNotFoundError(hostname) -> HostNotFoundError instance.
This exception is raised when trying to operate on a hostname that doesn't
exists.
def __init__(self, hostname):
r"Initialize the object. See class documentation for more info."
- self.message = 'Host not found: "%s"' % hostname
+ self.message = u'Host not found: "%s"' % hostname
class MailExchangeError(Error, KeyError):
r"""
- MailExchangeError(hostname) -> MailExchangeError instance
+ MailExchangeError(hostname) -> MailExchangeError instance.
This is the base exception for all mail exchange related errors.
"""
def __init__(self, mx):
r"Initialize the object. See class documentation for more info."
- self.message = 'Mail Exchange error: "%s"' % mx
+ self.message = u'Mail Exchange error: "%s"' % mx
class MailExchangeAlreadyExistsError(MailExchangeError):
r"""
- MailExchangeAlreadyExistsError(hostname) -> MailExchangeAlreadyExistsError instance
+ MailExchangeAlreadyExistsError(hostname) -> MailExchangeAlreadyExistsError.
This exception is raised when trying to add a mail exchange that already exists.
"""
def __init__(self, mx):
r"Initialize the object. See class documentation for more info."
- self.message = 'Mail Exchange already exists: "%s"' % mx
+ self.message = u'Mail Exchange already exists: "%s"' % mx
class MailExchangeNotFoundError(MailExchangeError):
r"""
- MailExchangeNotFoundError(hostname) -> MailExchangeNotFoundError instance
+ MailExchangeNotFoundError(hostname) -> MailExchangeNotFoundError instance.
- This exception is raised when trying to operate on a mail exchange that doesn't
- exists.
+ This exception is raised when trying to operate on a mail exchange that
+ doesn't exists.
"""
def __init__(self, mx):
class NameServerAlreadyExistsError(NameServerError):
r"""
- NameServerAlreadyExistsError(hostname) -> NameServerAlreadyExistsError instance
+ NameServerAlreadyExistsError(hostname) -> NameServerAlreadyExistsError.
- This exception is raised when trying to add a name server that already exists.
+ This exception is raised when trying to add a name server that already
+ exists.
"""
def __init__(self, ns):
class NameServerNotFoundError(NameServerError):
r"""
- NameServerNotFoundError(hostname) -> NameServerNotFoundError instance
+ NameServerNotFoundError(hostname) -> NameServerNotFoundError instance.
- This exception is raised when trying to operate on a name server that doesn't
- exists.
+ This exception is raised when trying to operate on a name server that
+ doesn't exists.
"""
def __init__(self, ns):
return (self.name, self.ip)
class HostHandler(Handler):
+
+ handler_help = u"Manage DNS hosts"
+
def __init__(self,zones):
self.zones = zones
class MailExchangeHandler(Handler):
+ handler_help = u"Manage DNS mail exchangers (MX)"
+
def __init__(self, zones):
self.zones = zones
class NameServerHandler(Handler):
+ handler_help = u"Manage DNS name servers (NS)"
+
def __init__(self, zones):
self.zones = zones
return (self.name, self.hosts, self.mxs, self.nss)
class ZoneHandler(Handler):
-
r"""ZoneHandler(zones) -> ZoneHandler instance :: Handle a list of zones.
This class is a helper for DnsHandler to do all the work related to zone
zones - A dictionary with string keys (zone name) and Zone instances values.
"""
+
+ handler_help = u"Manage DNS zones"
+
def __init__(self, zones):
self.zones = zones
Both defaults to the current working directory.
"""
- _initd_name = 'bind'
+ handler_help = u"Manage DNS service"
+
+ _initd_name = 'named'
_persistent_attrs = ('params', 'zones')
self.mod = False
self._config_build_templates()
self._restore()
+ # FIXME self.mod = True
+ #if not self._restore():
+ #r = self._restore()
+ #print r
+ #if not r:
+ # self.mod = True
self.host = HostHandler(self.zones)
self.zone = ZoneHandler(self.zones)
self.mx = MailExchangeHandler(self.zones)
if a_zone.mod:
if not a_zone.new:
# TODO freeze de la zona
- call(('dns', 'freeze', a_zone.name))
+ call(('rndc', 'freeze', a_zone.name))
vars = dict(
zone = a_zone,
hosts = a_zone.hosts.values(),
a_zone.mod = False
if not a_zone.new:
# TODO unfreeze de la zona
- call(('dns', 'unfreeze', a_zone.name))
+ call(('rndc', 'thaw', a_zone.name))
else :
self.mod = True
a_zone.new = False