# Setup the logger.
def setup_logging():
rootlogger = logging.getLogger("ddns")
- rootlogger.setLevel(logging.DEBUG)
+ rootlogger.setLevel(logging.INFO)
# Setup a logger that logs to syslog.
- #handler = logging.handlers.SysLogHandler(address="/dev/log")
+ handler = logging.handlers.SysLogHandler(address="/dev/log",
+ facility=logging.handlers.SysLogHandler.LOG_DAEMON
+ )
+ handler.setLevel(logging.INFO)
+ rootlogger.addHandler(handler)
handler = logging.StreamHandler()
rootlogger.addHandler(handler)
# In debug mode, enable debug logging.
if debug:
logger.setLevel(logging.DEBUG)
+ logger.debug(_("Debugging mode enabled"))
# Initialize the settings array.
self.settings = {}
Simply registers all providers.
"""
for provider in (
+ DDNSProviderAllInkl,
DDNSProviderDHS,
DDNSProviderDNSpark,
+ DDNSProviderDtDNS,
+ DDNSProviderDynDNS,
+ DDNSProviderDynU,
+ DDNSProviderEasyDNS,
+ DDNSProviderFreeDNSAfraidOrg,
+ DDNSProviderNamecheap,
DDNSProviderNOIP,
DDNSProviderLightningWireLabs,
+ DDNSProviderOVH,
+ DDNSProviderRegfish,
DDNSProviderSelfhost,
+ DDNSProviderSPDNS,
+ DDNSProviderStrato,
+ DDNSProviderVariomedia,
):
self.register_provider(provider)
+ def get_provider_names(self):
+ """
+ Returns a list of names of all registered providers.
+ """
+ return sorted(self.providers.keys())
+
def load_configuration(self, filename):
+ logger.debug(_("Loading configuration file %s") % filename)
+
configs = ConfigParser.SafeConfigParser()
configs.read([filename,])
if not entry in self.entries:
self.entries.append(entry)
- def updateall(self):
+ def updateone(self, hostname, **kwargs):
+ for entry in self.entries:
+ if not entry.hostname == hostname:
+ continue
+
+ return self._update(entry, **kwargs)
+
+ raise DDNSHostNotFoundError(hostname)
+
+ def updateall(self, **kwargs):
+ """
+ Update all configured entries.
+ """
# If there are no entries, there is nothing to do.
if not self.entries:
logger.debug(_("Found no entries in the configuration file. Exiting."))
return
- # Update them all.
for entry in self.entries:
- self.update(entry)
+ self._update(entry, **kwargs)
- def update(self, entry):
+ def _update(self, entry, force=False):
try:
- entry()
+ entry(force=force)
except DDNSUpdateError, e:
logger.error(_("Dynamic DNS update for %(hostname)s (%(provider)s) failed:") % \
{ "hostname" : entry.hostname, "provider" : entry.name })
logger.error(" %s" % e)
- logger.info(_("Dynamic DNS update for %(hostname)s (%(provider)s) successful") % \
- { "hostname" : entry.hostname, "provider" : entry.name })
+ else:
+ logger.info(_("Dynamic DNS update for %(hostname)s (%(provider)s) successful") % \
+ { "hostname" : entry.hostname, "provider" : entry.name })