def forward_check():
    """
        Check the forward events for consistence issues

        Returns:
            bool: True if successful, False otherwhise
            Message (str): Error description (if any)
    """
    logger.info("Forward consistence check")
    (success, local_id) = get_server_id_from_local()
    if not success:
        logger.error("Can't retrieve system_id.")
        return False, "Can't retrieve system_id."

    success, server_list = get_children_servers(local_id)
    if not server_list:
        return True, ''
    if not success:
        logger.error("Can't retrieve children system list.")
        return False, "Can't retrieve children system list."
    # Get the current alarms
    # Check 8 hours back
    success, local_alarms = get_local_alarms(delay=1, delta=3)

    # local_alarms => hash, key => event_id data => server_id
    if not success:
        logger.error("Can't retrieve local alarms")
        return False, "Can't retrieve local alarms"
    for server in server_list:
        success, child_alarms = get_child_alarms(server, delay=1, delta=3)

        if not success:
            logger.error(
                "Can't retrieve remote alarms for server '%s'. Skiping" %
                str(server))
            continue
        missing_alarms = [
            event_id for event_id in child_alarms
            if event_id not in local_alarms
        ]

        if missing_alarms:  # This check is list is empty
            success, message = resend_alarms(server, missing_alarms)
            if not success:
                logger.error(
                    "Can't resend remote alarams from server '%s': %s. Skiping"
                    % (message, str(server)))

    return True, ""
Ejemplo n.º 2
0
def forward_check():
    """
        Check the forward events for consistence issues

        Returns:
            bool: True if successful, False otherwhise
            Message (str): Error description (if any)
    """
    logger.info("Forward consistence check")
    (success, local_id) = get_server_id_from_local()
    if not success:
        logger.error("Can't retrieve system_id.")
        return False, "Can't retrieve system_id."

    success, server_list = get_children_servers(local_id)
    if not server_list:
        return True, ''
    if not success:
        logger.error("Can't retrieve children system list.")
        return False, "Can't retrieve children system list."
    # Get the current alarms
    # Check 8 hours back
    success, local_alarms = get_local_alarms(delay=1, delta=3)

    # local_alarms => hash, key => event_id data => server_id
    if not success:
        logger.error("Can't retrieve local alarms")
        return False, "Can't retrieve local alarms"
    for server in server_list:
        success, child_alarms = get_child_alarms(server, delay=1, delta=3)

        if not success:
            logger.error("Can't retrieve remote alarms for server '%s'. Skiping" % str(server))
            continue
        missing_alarms = [event_id for event_id in child_alarms if event_id not in local_alarms]
    
        if missing_alarms:  # This check is list is empty
            success, message = resend_alarms(server, missing_alarms)
            if not success:
                logger.error("Can't resend remote alarams from server '%s': %s. Skiping" % (message, str(server)))

    return True, ""
Ejemplo n.º 3
0
                prior_task = True
                break
    except Exception, e:
        logger.error("An error occurred running sync_databases: %s" % (str(e)))
        return False, str(e)

    if prior_task:
        logger.info("Sync Databases: A sync task is already running. Bailing out")
        return True, "A sync task is already running. Bailing out"

    (success, local_id) = get_server_id_from_local()
    if not success:
        logger.error("Can't retrieve system_id.")
        return False, "Can't retrieve system_id."

    success, server_list = get_children_servers(local_id)
    if not success:
        logger.error("Can't retrieve children system list.")
        return False, "Can't retrieve children system list."

    for server_id in server_list:
        try:
            logger.debug("Trying to sync database from server %s" % server_id)
            (success, msg) = sync_database_from_child(server_id)
            if not success:
                logger.debug("Sync database from server %s failed: %s" % (server_id, str(msg)))
            rt &= success
        except Exception, e:
            logger.error("An error occurred while tryng to sync database from server %s: %s" % (server_id, str(e)))
            rt = False