Allow forcing an update.
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 10 Jun 2014 22:09:06 +0000 (00:09 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 10 Jun 2014 22:09:06 +0000 (00:09 +0200)
src/ddns/__init__.py
src/ddns/providers.py

index 673ba27..2fb5e02 100644 (file)
@@ -133,7 +133,7 @@ class DDNSCore(object):
                        if not entry in self.entries:
                                self.entries.append(entry)
 
-       def updateall(self):
+       def updateall(self, force=False):
                # If there are no entries, there is nothing to do.
                if not self.entries:
                        logger.debug(_("Found no entries in the configuration file. Exiting."))
@@ -141,11 +141,11 @@ class DDNSCore(object):
 
                # Update them all.
                for entry in self.entries:
-                       self.update(entry)
+                       self.update(entry, force=force)
 
-       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:") % \
index 2115972..03201ba 100644 (file)
@@ -115,9 +115,12 @@ class DDNSProvider(object):
        def protocols(self):
                return self.INFO.get("protocols")
 
-       def __call__(self):
+       def __call__(self, force=False):
+               if force:
+                       logger.info(_("Updating %s forced") % self.hostname)
+
                # Check if we actually need to update this host.
-               if self.is_uptodate(self.protocols):
+               elif self.is_uptodate(self.protocols):
                        logger.info(_("%s is already up to date") % self.hostname)
                        return