def update_node(pod, response): """Update Node in database :param pod: Hostname :param response: Dictionary with booleans "result" and "https" """ try: Node.get_or_create(host=pod) if response["result"]: # Update delivered_count and last_success, nullify failure_count Node.update( last_success=datetime.datetime.now(), total_delivered=Node.total_delivered + 1, failure_count=0, https=response["https"]).where(Node.host==pod).execute() else: # Update failure_count Node.update( failure_count=Node.failure_count + 1).where(Node.host==pod).execute() except Exception as ex: logging.warning("Exception when trying to save or update Node {node} into database: {exc}".format( node=pod, exc=ex) )
def update_node(node, success): """Update Node in database :param node: Hostname :param success: Was the last call a success (bool) """ try: Node.get_or_create(host=node) if success: # Update delivered_count and last_success, nullify failure_count # TODO: remove the whole https tracking - we're only delivering to https now Node.update( last_success=datetime.datetime.now(), total_delivered=Node.total_delivered + 1, failure_count=0, https=True).where(Node.host == node).execute() else: # Update failure_count Node.update( failure_count=Node.failure_count + 1).where(Node.host == node).execute() except Exception as ex: logging.warning("Exception when trying to save or update Node {node} into database: {exc}".format( node=node, exc=ex) )