+ @property
+ def requires_update(self):
+ # If the IP addresses have changed, an update is required
+ if self.ip_address_changed(self.protocols):
+ logger.debug(_("An update for %(hostname)s (%(provider)s)"
+ " is performed because of an IP address change") % \
+ { "hostname" : self.hostname, "provider" : self.name })
+
+ return True
+
+ # If the holdoff time has expired, an update is required, too
+ if self.holdoff_time_expired():
+ logger.debug(_("An update for %(hostname)s (%(provider)s)"
+ " is performed because the holdoff time has expired") % \
+ { "hostname" : self.hostname, "provider" : self.name })
+
+ return True
+
+ # Otherwise, we don't need to perform an update
+ logger.debug(_("No update required for %(hostname)s (%(provider)s)") % \
+ { "hostname" : self.hostname, "provider" : self.name })
+
+ return False
+
+ @property
+ def has_failure(self):
+ """
+ Returns True when the last update has failed and no retry
+ should be performed, yet.
+ """
+ last_status = self.db.last_update_status(self.hostname)
+
+ # Return False if the last update has not failed.
+ if not last_status == "failure":
+ return False
+
+ # If there is no holdoff time, we won't update ever again.
+ if self.holdoff_failure_days is None:
+ logger.warning(_("An update has not been performed because earlier updates failed for %s") \
+ % self.hostname)
+ logger.warning(_("There will be no retries"))
+
+ return True
+
+ # Determine when the holdoff time ends
+ last_update = self.db.last_update(self.hostname, status=last_status)
+ holdoff_end = last_update + datetime.timedelta(days=self.holdoff_failure_days)
+
+ now = datetime.datetime.utcnow()
+ if now < holdoff_end:
+ failure_message = self.db.last_update_failure_message(self.hostname)
+
+ logger.warning(_("An update has not been performed because earlier updates failed for %s") \
+ % self.hostname)
+
+ if failure_message:
+ logger.warning(_("Last failure message:"))
+
+ for line in failure_message.splitlines():
+ logger.warning(" %s" % line)
+
+ logger.warning(_("Further updates will be withheld until %s") % holdoff_end)
+
+ return True
+
+ return False
+
+ def ip_address_changed(self, protos):